diff --git a/mod/chat/index.php b/mod/chat/index.php
index 127aa6ecf1b..a9a365fe9bb 100644
--- a/mod/chat/index.php
+++ b/mod/chat/index.php
@@ -30,7 +30,7 @@
/// Get all the appropriate data
- if (!$cms = get_coursemodules_in_course('chat', $course->id)) {
+ if (! $chats = get_all_instances_in_course('chat', $course)) {
notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
die();
}
@@ -54,25 +54,23 @@
}
$currentsection = '';
-
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['chat'] as $cm) {
- if (!$cm->uservisible) {
- continue;
+ foreach ($chats as $chat) {
+ if (!$chat->visible) {
+ //Show dimmed if the mod is hidden
+ $link = "coursemodule\">".format_string($chat->name,true)."";
+ } else {
+ //Show normal if the mod is visible
+ $link = "coursemodule\">".format_string($chat->name,true)."";
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "id\">".format_string($cm->name)."";
-
$printsection = '';
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($chat->section !== $currentsection) {
+ if ($chat->section) {
+ $printsection = $chat->section;
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $chat->section;
}
if ($course->format == 'weeks' or $course->format == 'topics') {
$table->data[] = array ($printsection, $link);
diff --git a/mod/choice/index.php b/mod/choice/index.php
index e7283147876..f60fda7b4d4 100644
--- a/mod/choice/index.php
+++ b/mod/choice/index.php
@@ -22,7 +22,7 @@
print_header_simple("$strchoices", "", $navigation, "", "", true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('choice', $course->id)) {
+ if (! $choices = get_all_instances_in_course("choice", $course)) {
notice(get_string('thereareno', 'moodle', $strchoices), "../../course/view.php?id=$course->id");
}
@@ -51,37 +51,36 @@
$currentsection = "";
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['choice'] as $cm) {
- if (!$cm->uservisible) {
- continue;
- }
-
- $printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
- }
- if ($currentsection !== "") {
- $table->data[] = 'hr';
- }
- $currentsection = $cm->sectionnum;
- }
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $tt_href = "id\">".format_string($cm->name)."";
-
- if (!empty($answers[$cm->instance])) {
- $answer = $answers[$cm->instance];
+ foreach ($choices as $choice) {
+ if (!empty($answers[$choice->id])) {
+ $answer = $answers[$choice->id];
} else {
$answer = "";
}
if (!empty($answer->optionid)) {
- $aa = format_string(choice_get_option_text(null, $answer->optionid));
+ $aa = format_string(choice_get_option_text($choice, $answer->optionid));
} else {
$aa = "";
}
-
+ $printsection = "";
+ if ($choice->section !== $currentsection) {
+ if ($choice->section) {
+ $printsection = $choice->section;
+ }
+ if ($currentsection !== "") {
+ $table->data[] = 'hr';
+ }
+ $currentsection = $choice->section;
+ }
+
+ //Calculate the href
+ if (!$choice->visible) {
+ //Show dimmed if the mod is hidden
+ $tt_href = "coursemodule\">".format_string($choice->name,true)."";
+ } else {
+ //Show normal if the mod is visible
+ $tt_href = "coursemodule\">".format_string($choice->name,true)."";
+ }
if ($course->format == "weeks" || $course->format == "topics") {
$table->data[] = array ($printsection, $tt_href, $aa);
} else {
diff --git a/mod/data/index.php b/mod/data/index.php
index cd3cd813c5e..2e0be42a854 100755
--- a/mod/data/index.php
+++ b/mod/data/index.php
@@ -49,7 +49,7 @@
print_header_simple($strdata, '', $navigation, '', '', true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('data', $course->id, 'm.intro, m.approval, m.rssarticles')) {
+ if (! $datas = get_all_instances_in_course("data", $course)) {
notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id");
}
@@ -82,53 +82,51 @@
$currentsection = "";
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['data'] as $cm) {
- if (!$cm->uservisible) {
- continue;
- }
-
- $cm->intro = $cms[$cm->id]->intro;
- $cm->approval = $cms[$cm->id]->approval;
- $cm->rssarticles = $cms[$cm->id]->rssarticles;
+ foreach ($datas as $data) {
$printsection = "";
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "id\">".format_string($cm->name,true)."";
+ //Calculate the href
+ if (!$data->visible) {
+ //Show dimmed if the mod is hidden
+ $link = "coursemodule\">".format_string($data->name,true)."";
+ } else {
+ //Show normal if the mod is visible
+ $link = "coursemodule\">".format_string($data->name,true)."";
+ }
// TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page
$numrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix.
- 'data_records r WHERE r.dataid ='.$cm->instance);
+ 'data_records r WHERE r.dataid ='.$data->id);
- if ($cm->approval == 1) {
+ if ($data->approval == 1) {
$numunapprovedrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix.
- 'data_records r WHERE r.dataid ='.$cm->instance.
+ 'data_records r WHERE r.dataid ='.$data->id.
' AND r.approved <> 1');
} else {
$numunapprovedrecords = '-';
}
$rsslink = '';
- if ($rss && $cm->rssarticles > 0) {
- $rsslink = rss_get_link($course->id, $USER->id, 'data', $cm->instance, 'RSS');
+ if ($rss && $data->rssarticles > 0) {
+ $rsslink = rss_get_link($course->id, $USER->id, 'data', $data->id, 'RSS');
}
if ($course->format == 'weeks' or $course->format == 'topics') {
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($data->section !== $currentsection) {
+ if ($data->section) {
+ $printsection = $data->section;
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $data->section;
}
- $row = array ($printsection, $link, $cm->intro, $numrecords, $numunapprovedrecords);
+ $row = array ($printsection, $link, $data->intro, $numrecords, $numunapprovedrecords);
} else {
- $row = array ($link, $cm->intro, $numrecords, $numunapprovedrecords);
+ $row = array ($link, $data->intro, $numrecords, $numunapprovedrecords);
}
if ($rss) {
diff --git a/mod/glossary/index.php b/mod/glossary/index.php
index a6b1db3fcf5..6b53b9e2669 100644
--- a/mod/glossary/index.php
+++ b/mod/glossary/index.php
@@ -36,7 +36,7 @@
/// Get all the appropriate data
- if (!$cms = get_coursemodules_in_course('glossary', $course->id, 'm.rsstype, m.rssarticles')) {
+ if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
notice(get_string('thereareno', 'moodle', $strglossarys), "../../course/view.php?id=$course->id");
die;
}
@@ -68,46 +68,45 @@
$currentsection = "";
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['glossary'] as $cm) {
- if (!$cm->uservisible) {
+ foreach ($glossarys as $glossary) {
+ if (!$glossary->visible && has_capability('moodle/course:viewhiddenactivities', $context)) {
+ // Show dimmed if the mod is hidden.
+ $link = "coursemodule\">".format_string($glossary->name,true)."";
+ } else if ($glossary->visible) {
+ // Show normal if the mod is visible.
+ $link = "coursemodule\">".format_string($glossary->name,true)."";
+ } else {
+ // Don't show the glossary.
continue;
}
-
- $cm->rsstype = $cms[$cm->id]->rsstype;
- $cm->rssarticles = $cms[$cm->id]->rssarticles;
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "id\">".format_string($cm->name)."";
-
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($glossary->section !== $currentsection) {
+ if ($glossary->section) {
+ $printsection = $glossary->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $glossary->section;
}
// TODO: count only approved if not allowed to see them
- $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $cm->instance or sourceglossaryid = $cm->instance)");
+ $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");
//If this glossary has RSS activated, calculate it
if ($show_rss) {
$rsslink = '';
- if ($cm->rsstype and $cm->rssarticles) {
+ if ($glossary->rsstype and $glossary->rssarticles) {
//Calculate the tolltip text
- $tooltiptext = get_string("rsssubscriberss","glossary",format_string($cm->name));
+ $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name));
if (empty($USER->id)) {
$userid = 0;
} else {
$userid = $USER->id;
}
//Get html code for RSS link
- $rsslink = rss_get_link($course->id, $userid, "glossary", $cm->instance, $tooltiptext);
+ $rsslink = rss_get_link($course->id, $userid, "glossary", $glossary->id, $tooltiptext);
}
}
diff --git a/mod/journal/index.php b/mod/journal/index.php
index 051190a5b5e..0a9a90791d8 100644
--- a/mod/journal/index.php
+++ b/mod/journal/index.php
@@ -41,12 +41,6 @@
}
foreach ($journals as $journal) {
- $cm = get_coursemodule_from_instance('journal', $journal->id, $course->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
$journal->timestart = $course->startdate + (($journal->section - 1) * 608400);
if (!empty($journal->daysopen)) {
diff --git a/mod/lesson/index.php b/mod/lesson/index.php
index 725acca7f39..0dd0c97d633 100644
--- a/mod/lesson/index.php
+++ b/mod/lesson/index.php
@@ -65,15 +65,15 @@
}
foreach ($lessons as $lesson) {
- $cm = get_coursemodule_from_instance('lesson', $lesson->id, $course->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
+ if (!$lesson->visible) {
+ //Show dimmed if the mod is hidden
+ $link = "coursemodule\">".format_string($lesson->name,true)."";
+ } else {
+ //Show normal if the mod is visible
+ $link = "coursemodule\">".format_string($lesson->name,true)."";
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "coursemodule\">".format_string($lesson->name)."";
+ $cm = get_coursemodule_from_instance('lesson', $lesson->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($lesson->deadline > $timenow) {
$due = userdate($lesson->deadline);
diff --git a/mod/quiz/index.php b/mod/quiz/index.php
index ea0ce369b8a..da8a4eed1fa 100644
--- a/mod/quiz/index.php
+++ b/mod/quiz/index.php
@@ -71,11 +71,6 @@
foreach ($quizzes as $quiz) {
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
-
$data = array();
// Section number if necessary.
diff --git a/mod/resource/index.php b/mod/resource/index.php
index e9e71dc3751..807c029d1b3 100644
--- a/mod/resource/index.php
+++ b/mod/resource/index.php
@@ -30,7 +30,7 @@
print_header("$course->shortname: $strresources", $course->fullname, $navigation,
"", "", true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('resource', $course->id, 'm.timemodified, m.summary')) {
+ if (! $resources = get_all_instances_in_course("resource", $course)) {
notice(get_string('thereareno', 'moodle', $strresources), "../../course/view.php?id=$course->id");
exit;
}
@@ -48,35 +48,36 @@
$currentsection = "";
$options->para = false;
-
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['resource'] as $cm) {
- if (!$cm->uservisible) {
- continue;
- }
-
- $cm->summary = $cms[$cm->id]->summary;
- $cm->timemodified = $cms[$cm->id]->timemodified;
-
+ foreach ($resources as $resource) {
if ($course->format == "weeks" or $course->format == "topics") {
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($resource->section !== $currentsection) {
+ if ($resource->section) {
+ $printsection = $resource->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $resource->section;
}
} else {
- $printsection = ''.userdate($cm->timemodified)."";
+ $printsection = ''.userdate($resource->timemodified)."";
}
+ if (!empty($resource->extra)) {
+ $extra = urldecode($resource->extra);
+ } else {
+ $extra = "";
+ }
+ if (!$resource->visible) { // Show dimmed if the mod is hidden
+ $table->data[] = array ($printsection,
+ "coursemodule\">".format_string($resource->name,true)."",
+ format_text($resource->summary, FORMAT_MOODLE, $options) );
- $class = $cm->visible ? '' : 'class="dimmed"';
- $table->data[] = array ($printsection,
- "id\">".format_string($cm->name)."",
- format_text($cm->summary, FORMAT_MOODLE, $options) );
+ } else { //Show normal if the mod is visible
+ $table->data[] = array ($printsection,
+ "coursemodule\">".format_string($resource->name,true)."",
+ format_text($resource->summary, FORMAT_MOODLE, $options) );
+ }
}
echo "
";
diff --git a/mod/scorm/index.php b/mod/scorm/index.php
index 9be62c359f9..cdd8ae6d048 100755
--- a/mod/scorm/index.php
+++ b/mod/scorm/index.php
@@ -56,13 +56,8 @@
}
foreach ($scorms as $scorm) {
- $cm = get_coursemodule_from_instance('scorm', $forum->id, $course->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
+ $context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);
$tt = "";
if ($course->format == "weeks" or $course->format == "topics") {
if ($scorm->section) {
@@ -84,10 +79,15 @@
$report = scorm_grade_user($scorm, $USER->id);
$reportshow = get_string('score','scorm').": ".$report;
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $table->data[] = array ($tt, "coursemodule\">".format_string($scorm->name)."",
- format_text($scorm->summary), $reportshow);
+ if (!$scorm->visible) {
+ //Show dimmed if the mod is hidden
+ $table->data[] = array ($tt, "coursemodule\">".format_string($scorm->name)."",
+ format_text($scorm->summary), $reportshow);
+ } else {
+ //Show normal if the mod is visible
+ $table->data[] = array ($tt, "coursemodule\">".format_string($scorm->name)."",
+ format_text($scorm->summary), $reportshow);
+ }
}
echo "
";
diff --git a/mod/survey/index.php b/mod/survey/index.php
index da203dcccec..217bb13ae8a 100644
--- a/mod/survey/index.php
+++ b/mod/survey/index.php
@@ -28,7 +28,7 @@
print_header_simple("$strsurveys", "", $navigation,
"", "", true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('survey', $course->id)) {
+ if (! $surveys = get_all_instances_in_course("survey", $course)) {
notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id");
}
@@ -45,35 +45,35 @@
$currentsection = '';
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['survey'] as $cm) {
- if (!$cm->uservisible) {
- continue;
- }
-
- if (!empty($USER->id) and survey_already_done($cm->instance, $USER->id)) {
+ foreach ($surveys as $survey) {
+ if (!empty($USER->id) and survey_already_done($survey->id, $USER->id)) {
$ss = $strdone;
} else {
$ss = $strnotdone;
}
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($survey->section !== $currentsection) {
+ if ($survey->section) {
+ $printsection = $survey->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $survey->section;
}
//Calculate the href
- $class = $cm->visible ? '' : 'class="dimmed"';
- $tt_href = "id\">".format_string($cm->name,true)."";
+ if (!$survey->visible) {
+ //Show dimmed if the mod is hidden
+ $tt_href = "coursemodule\">".format_string($survey->name,true)."";
+ } else {
+ //Show normal if the mod is visible
+ $tt_href = "coursemodule\">".format_string($survey->name,true)."";
+ }
if ($course->format == "weeks" or $course->format == "topics") {
- $table->data[] = array ($printsection, $tt_href, "id\">$ss");
+ $table->data[] = array ($printsection, $tt_href, "coursemodule\">$ss");
} else {
- $table->data[] = array ($tt_href, "id\">$ss");
+ $table->data[] = array ($tt_href, "coursemodule\">$ss");
}
}
diff --git a/mod/wiki/index.php b/mod/wiki/index.php
index 9bb4cc93cf0..313891df4ad 100644
--- a/mod/wiki/index.php
+++ b/mod/wiki/index.php
@@ -32,7 +32,7 @@
/// Get all the appropriate data
- if (!$cms = get_coursemodules_in_course('wiki', $course->id, 'm.summary, m.wtype, m.timemodified')) {
+ if (! $wikis = get_all_instances_in_course("wiki", $course)) {
notice(get_string('thereareno', 'moodle', $strwikis), "../../course/view.php?id=$course->id");
die;
}
@@ -58,24 +58,20 @@
$table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT');
}
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['wiki'] as $cm) {
- if (!$cm->uservisible) {
- continue;
+ foreach ($wikis as $wiki) {
+ if (!$wiki->visible) {
+ //Show dimmed if the mod is hidden
+ $link = ''.format_string($wiki->name,true).'';
+ } else {
+ //Show normal if the mod is visible
+ $link = ''.format_string($wiki->name,true).'';
}
- $cm->summary = $cms[$cm->id]->summary;
- $cm->wtype = $cms[$cm->id]->wtype;
- $cm->timemodified = $cms[$cm->id]->timemodified;
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = ''.format_string($cm->name).'';
-
- $timmod = ''.userdate($cm->timemodified).'';
- $summary = ''.format_text($cm->summary).'';
+ $timmod = ''.userdate($wiki->timemodified).'';
+ $summary = ''.format_text($wiki->summary).'';
$site = get_site();
- switch ($cm->wtype) {
+ switch ($wiki->wtype) {
case 'teacher':
$wtype = $site->teacher;
@@ -94,7 +90,7 @@
$wtype = ''.$wtype.'';
if ($course->format == "weeks" or $course->format == "topics") {
- $table->data[] = array ($cm->sectionnum, $link, $summary, $wtype, $timmod);
+ $table->data[] = array ($wiki->section, $link, $summary, $wtype, $timmod);
} else {
$table->data[] = array ($link, $summary, $wtype, $timmod);
}
diff --git a/mod/workshop/index.php b/mod/workshop/index.php
index 5873eb909d9..5bc2ad7572c 100644
--- a/mod/workshop/index.php
+++ b/mod/workshop/index.php
@@ -22,11 +22,11 @@
$strinfo = get_string("grade")."/".$strinfo = get_string("phase", "workshop");
$strdeadline = get_string("deadline", "workshop");
$strsubmitted = get_string("submitted", "assignment");
-
+
$navlinks = array();
$navlinks[] = array('name' => $strworkshops, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
-
+
print_header_simple("$strworkshops", "", $navigation, "", "", true, "", navmenu($course));
if (! $workshops = get_all_instances_in_course("workshop", $course)) {
@@ -48,13 +48,6 @@
}
foreach ($workshops as $workshop) {
- $cm = get_coursemodule_from_instance('workshop', $workshop->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
-
if (workshop_is_teacher($workshop, $USER->id)) { // teacher see info (students see grade)
$info = workshop_phase($workshop, 'short');
if (time() > $workshop->submissionstart) {