From: skodak Date: Fri, 1 Feb 2008 09:09:04 +0000 (+0000) Subject: MDL-12945 fixing mod indexes broken by previous commit; merged from MOODLE_19_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=52ae8c057a95c143b23b5dec72c12ca666b7be37;p=moodle.git MDL-12945 fixing mod indexes broken by previous commit; merged from MOODLE_19_STABLE --- diff --git a/mod/assignment/index.php b/mod/assignment/index.php index dbae8289d2..7409f57847 100644 --- a/mod/assignment/index.php +++ b/mod/assignment/index.php @@ -51,27 +51,14 @@ $types = assignment_types(); - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + $modinfo = get_fast_modinfo($course); + foreach ($modinfo->instances['assignment'] as $cm) { + if (!$cm->uservisible) { continue; } - if (!file_exists($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php')) { - continue; - } - - require_once ($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php'); - $assignmentclass = 'assignment_'.$cm->assignmenttype; - $assignmentinstance = new $assignmentclass($cm->id, NULL, $cm, $course); - - $submitted = $assignmentinstance->submittedlink(true); - - $grading_info = grade_get_grades($course->id, 'mod', 'assignment', $cm->instance, $USER->id); - $grade = $grading_info->items[0]->grades[$USER->id]->str_grade; - - $type = $types[$cm->assignmenttype]; - - $due = $cm->timedue ? userdate($cm->timedue) : '-'; + $cm->timedue = $cms[$cm->id]->timedue; + $cm->assignmenttype = $cms[$cm->id]->assignmenttype; //Show dimmed if the mod is hidden $class = $cm->visible ? '' : 'class="dimmed"'; @@ -89,6 +76,23 @@ $currentsection = $cm->section; } + if (!file_exists($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php')) { + continue; + } + + require_once ($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php'); + $assignmentclass = 'assignment_'.$cm->assignmenttype; + $assignmentinstance = new $assignmentclass($cm->id, NULL, $cm, $course); + + $submitted = $assignmentinstance->submittedlink(true); + + $grading_info = grade_get_grades($course->id, 'mod', 'assignment', $cm->instance, $USER->id); + $grade = $grading_info->items[0]->grades[$USER->id]->str_grade; + + $type = $types[$cm->assignmenttype]; + + $due = $cm->timedue ? userdate($cm->timedue) : '-'; + if ($course->format == "weeks" or $course->format == "topics") { $table->data[] = array ($printsection, $link, $type, $due, $submitted, $grade); } else { diff --git a/mod/chat/index.php b/mod/chat/index.php index c43730b7ea..bd20bc172e 100644 --- a/mod/chat/index.php +++ b/mod/chat/index.php @@ -54,8 +54,10 @@ } $currentsection = ''; - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + + $modinfo = get_fast_modinfo($course); + foreach ($modinfo->instances['chat'] as $cm) { + if (!$cm->uservisible) { continue; } diff --git a/mod/choice/index.php b/mod/choice/index.php index 85ebfc9fc4..670dcfef74 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -51,21 +51,12 @@ $currentsection = ""; - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + $modinfo = get_fast_modinfo($course); + foreach ($modinfo->instances['choice'] as $cm) { + if (!$cm->uservisible) { continue; } - if (!empty($answers[$cm->instance])) { - $answer = $answers[$cm->instance]; - } else { - $answer = ""; - } - if (!empty($answer->optionid)) { - $aa = format_string(choice_get_option_text(null, $answer->optionid)); - } else { - $aa = ""; - } $printsection = ""; if ($cm->section !== $currentsection) { if ($cm->section) { @@ -80,6 +71,17 @@ $class = $cm->visible ? '' : 'class="dimmed"'; $tt_href = "id\">".format_string($cm->name).""; + if (!empty($answers[$cm->instance])) { + $answer = $answers[$cm->instance]; + } else { + $answer = ""; + } + if (!empty($answer->optionid)) { + $aa = format_string(choice_get_option_text(null, $answer->optionid)); + } else { + $aa = ""; + } + 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 bff07217ca..60b4b7fcf8 100755 --- a/mod/data/index.php +++ b/mod/data/index.php @@ -82,11 +82,16 @@ $currentsection = ""; - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + $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; + $printsection = ""; $class = $cm->visible ? '' : 'class="dimmed"'; diff --git a/mod/glossary/index.php b/mod/glossary/index.php index 47da6082f9..f71afc818a 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -6,6 +6,7 @@ require_once("../../config.php"); require_once("lib.php"); require_once("$CFG->libdir/rsslib.php"); + require_once("$CFG->dirroot/course/lib.php"); $id = required_param('id', PARAM_INT); // course @@ -67,13 +68,17 @@ $currentsection = ""; - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + $modinfo = get_fast_modinfo($course); + foreach ($modinfo->instances['glossary'] as $cm) { + if (!$cm->uservisible) { continue; } + $cm->rsstype = $cms[$cm->id]->rsstype; + $cm->rssarticles = $cms[$cm->id]->rssarticles; + $class = $cm->visible ? '' : 'class="dimmed"'; - $link = "id\">".format_string($cm->name).""; + $link = "id\">".format_string($cm->name).""; $printsection = ""; if ($cm->section !== $currentsection) { diff --git a/mod/resource/index.php b/mod/resource/index.php index d02b70036a..574e4cde82 100644 --- a/mod/resource/index.php +++ b/mod/resource/index.php @@ -48,11 +48,16 @@ $currentsection = ""; $options->para = false; - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + + $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; + if ($course->format == "weeks" or $course->format == "topics") { $printsection = ""; if ($cm->section !== $currentsection) { diff --git a/mod/survey/index.php b/mod/survey/index.php index beabb84883..fcbf432c32 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -45,8 +45,9 @@ $currentsection = ''; - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + $modinfo = get_fast_modinfo($course); + foreach ($modinfo->instances['survey'] as $cm) { + if (!$cm->uservisible) { continue; } diff --git a/mod/wiki/index.php b/mod/wiki/index.php index 1734b30b93..883e76c4de 100644 --- a/mod/wiki/index.php +++ b/mod/wiki/index.php @@ -58,11 +58,16 @@ $table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT'); } - foreach ($cms as $cm) { - if (!coursemodule_visible_for_user($cm)) { + $modinfo = get_fast_modinfo($course); + foreach ($modinfo->instances['wiki'] as $cm) { + if (!$cm->uservisible) { continue; } + $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).'';