diff --git a/blocks/site_main_menu/block_site_main_menu.php b/blocks/site_main_menu/block_site_main_menu.php index 5d2c515bbc0..38c2db3d9d5 100644 --- a/blocks/site_main_menu/block_site_main_menu.php +++ b/blocks/site_main_menu/block_site_main_menu.php @@ -29,10 +29,10 @@ class block_site_main_menu extends block_list { require_once($CFG->dirroot.'/course/lib.php'); $context = context_course::instance($course->id); $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context); - $modinfo = get_fast_modinfo($course); /// extra fast view mode if (!$isediting) { + $modinfo = get_fast_modinfo($course); if (!empty($modinfo->sections[0])) { $options = array('overflowdiv'=>true); foreach($modinfo->sections[0] as $cmid) { @@ -62,7 +62,7 @@ class block_site_main_menu extends block_list { /// slow & hacky editing mode $ismoving = ismoving($course->id); $section = get_course_section(0, $course->id); - + $modinfo = get_fast_modinfo($course); get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); $groupbuttons = $course->groupmode; @@ -82,14 +82,13 @@ class block_site_main_menu extends block_list { $this->content->items[] = $USER->activitycopyname.' ('.$strcancel.')'; } - if (!empty($section->sequence)) { - $sectionmods = explode(',', $section->sequence); + if (!empty($modinfo->sections[0])) { $options = array('overflowdiv'=>true); - foreach ($sectionmods as $modnumber) { - if (empty($mods[$modnumber])) { + foreach ($modinfo->sections[0] as $modnumber) { + $mod = $modinfo->cms[$modnumber]; + if (!$mod->uservisible) { continue; } - $mod = $mods[$modnumber]; if (!$ismoving) { if ($groupbuttons) { if (! $mod->groupmodelink = $groupbuttonslink) { diff --git a/blocks/social_activities/block_social_activities.php b/blocks/social_activities/block_social_activities.php index d9f98b01107..f87ae7fb5e0 100644 --- a/blocks/social_activities/block_social_activities.php +++ b/blocks/social_activities/block_social_activities.php @@ -64,11 +64,8 @@ class block_social_activities extends block_list { /// slow & hacky editing mode $ismoving = ismoving($course->id); - $sections = get_all_sections($course->id); - - if(!empty($sections) && isset($sections[0])) { - $section = $sections[0]; - } + $modinfo = get_fast_modinfo($course); + $section = $modinfo->get_section_info(0); if (!empty($section)) { get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); @@ -91,14 +88,13 @@ class block_social_activities extends block_list { $this->content->items[] = $USER->activitycopyname.' ('.$strcancel.')'; } - if (!empty($section) && !empty($section->sequence)) { - $sectionmods = explode(',', $section->sequence); + if (!empty($modinfo->sections[0])) { $options = array('overflowdiv'=>true); - foreach ($sectionmods as $modnumber) { - if (empty($mods[$modnumber])) { + foreach ($modinfo->sections[0] as $modnumber) { + $mod = $modinfo->cms[$modnumber]; + if (!$mod->uservisible) { continue; } - $mod = $mods[$modnumber]; if (!$ismoving) { if ($groupbuttons) { if (! $mod->groupmodelink = $groupbuttonslink) { diff --git a/course/externallib.php b/course/externallib.php index 22e2e4ef9f0..c2a5c94e709 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -105,13 +105,12 @@ class core_course_external extends external_api { //retrieve sections $modinfo = get_fast_modinfo($course); - $sections = get_all_sections($course->id); + $sections = $modinfo->get_section_info_all(); //for each sections (first displayed to last displayed) foreach ($sections as $key => $section) { - $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $section->visible or !$course->hiddensections); - if (!$showsection) { + if (!$section->uservisible) { continue; } diff --git a/course/recent.php b/course/recent.php index 71c83f52568..a7deb367dde 100644 --- a/course/recent.php +++ b/course/recent.php @@ -91,11 +91,9 @@ if (has_capability('moodle/course:viewhiddensections', $context)) { $hiddenfilter = "AND cs.visible = 1"; } $sections = array(); -$rawsections = array_slice(get_all_sections($course->id), 0, $course->numsections+1, true); -$canviewhidden = has_capability('moodle/course:viewhiddensections', $context); -foreach ($rawsections as $section) { - if ($canviewhidden || !empty($section->visible)) { - $sections[$section->section] = $section; +foreach ($modinfo->get_section_info_all() as $i => $section) { + if (!empty($section->uservisible)) { + $sections[$i] = $section; } } @@ -115,20 +113,18 @@ if ($param->modid === 'all') { } } else if (is_numeric($param->modid)) { - $section = $sections[$modinfo->cms[$param->modid]->sectionnum]; - $section->sequence = $param->modid; - $sections = array($section->sequence=>$section); + $sectionnum = $modinfo->cms[$param->modid]->sectionnum; + $filter_modid = $param->modid; + $sections = array($sectionnum => $sections[$sectionnum]); } -if (is_null($modinfo->groups)) { - $modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo -} +$modinfo->get_groups(); // load all my groups and cache it in modinfo $activities = array(); $index = 0; -foreach ($sections as $section) { +foreach ($sections as $sectionnum => $section) { $activity = new stdClass(); $activity->type = 'section'; @@ -141,17 +137,11 @@ foreach ($sections as $section) { $activity->visible = $section->visible; $activities[$index++] = $activity; - if (empty($section->sequence)) { + if (empty($modinfo->sections[$sectionnum])) { continue; } - $sectionmods = explode(",", $section->sequence); - - foreach ($sectionmods as $cmid) { - if (!isset($mods[$cmid]) or !isset($modinfo->cms[$cmid])) { - continue; - } - + foreach($modinfo->sections[$sectionnum] as $cmid) { $cm = $modinfo->cms[$cmid]; if (!$cm->uservisible) { @@ -162,6 +152,10 @@ foreach ($sections as $section) { continue; } + if (!empty($filter_modid) and $cmid != $filter_modid) { + continue; + } + $libfile = "$CFG->dirroot/mod/$cm->modname/lib.php"; if (file_exists($libfile)) { diff --git a/course/recent_form.php b/course/recent_form.php index 46a31374242..349fd58a8f2 100644 --- a/course/recent_form.php +++ b/course/recent_form.php @@ -36,7 +36,6 @@ class recent_form extends moodleform { $mform =& $this->_form; $context = context_course::instance($COURSE->id); $modinfo = get_fast_modinfo($COURSE); - $sections = get_all_sections($COURSE->id); $mform->addElement('header', 'filters', get_string('managefilters')); //TODO: add better string @@ -127,7 +126,7 @@ class recent_form extends moodleform { } foreach ($modinfo->sections as $section=>$cmids) { - $options["section/$section"] = "-- ".get_section_name($COURSE, $sections[$section])." --"; + $options["section/$section"] = "-- ".get_section_name($COURSE, $section)." --"; foreach ($cmids as $cmid) { $cm = $modinfo->cms[$cmid]; if (empty($modsused[$cm->modname]) or !$cm->uservisible) { diff --git a/course/resources.php b/course/resources.php index abf50b28d12..6debe853d08 100644 --- a/course/resources.php +++ b/course/resources.php @@ -65,9 +65,6 @@ echo $OUTPUT->header(); $modinfo = get_fast_modinfo($course); $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $cms = array(); $resources = array(); foreach ($modinfo->cms as $cm) { @@ -116,7 +113,7 @@ foreach ($cms as $cm) { $printsection = ''; if ($cm->sectionnum !== $currentsection) { if ($cm->sectionnum) { - $printsection = get_section_name($course, $sections[$cm->sectionnum]); + $printsection = get_section_name($course, $cm->sectionnum); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/assignment/index.php b/mod/assignment/index.php index 71eb0237ed3..5adcbf2b91c 100644 --- a/mod/assignment/index.php +++ b/mod/assignment/index.php @@ -37,9 +37,6 @@ if (!$cms = get_coursemodules_in_course('assignment', $course->id, 'cm.idnumber, } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $timenow = time(); @@ -74,7 +71,7 @@ foreach ($modinfo->instances['assignment'] as $cm) { if ($usesections) { if ($cm->sectionnum !== $currentsection) { if ($cm->sectionnum) { - $printsection = get_section_name($course, $sections[$cm->sectionnum]); + $printsection = get_section_name($course, $cm->sectionnum); } if ($currentsection !== "") { $table->data[] = 'hr'; diff --git a/mod/assignment/type/online/all.php b/mod/assignment/type/online/all.php index 4b0ab8c46c0..ceef73d236a 100644 --- a/mod/assignment/type/online/all.php +++ b/mod/assignment/type/online/all.php @@ -47,8 +47,6 @@ $PAGE->navbar->add($str->onlinetext); // get all the assignments in the course $assignments = get_all_instances_in_course('assignment',$course, $USER->id ); -$sections = get_all_sections($course->id); - // array to hold display data $views = array(); @@ -98,7 +96,7 @@ foreach( $assignments as $assignment ) { $view = new stdClass; // start to build view object - $view->section = get_section_name($course, $sections[$assignment->section]); + $view->section = get_section_name($course, $assignment->section); $view->name = $assignment->name; $view->submitted = $submitted; diff --git a/mod/book/index.php b/mod/book/index.php index b413ba3cc2c..75461889413 100644 --- a/mod/book/index.php +++ b/mod/book/index.php @@ -57,9 +57,6 @@ if (!$books = get_all_instances_in_course('book', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -80,7 +77,7 @@ foreach ($books as $book) { $printsection = ''; if ($book->section !== $currentsection) { if ($book->section) { - $printsection = get_section_name($course, $sections[$book->section]); + $printsection = get_section_name($course, $book->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/chat/index.php b/mod/chat/index.php index e000978bbf1..a56e489e971 100644 --- a/mod/chat/index.php +++ b/mod/chat/index.php @@ -38,9 +38,6 @@ if (! $chats = get_all_instances_in_course('chat', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} /// Print the list of instances (your module will probably extend this) @@ -69,7 +66,7 @@ foreach ($chats as $chat) { $printsection = ''; if ($chat->section !== $currentsection) { if ($chat->section) { - $printsection = get_section_name($course, $sections[$chat->section]); + $printsection = get_section_name($course, $chat->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/choice/index.php b/mod/choice/index.php index e63b8763593..1d0ca001cf0 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -29,9 +29,6 @@ } $usesections = course_format_uses_sections($course->format); - if ($usesections) { - $sections = get_all_sections($course->id); - } $sql = "SELECT cha.* FROM {choice} ch, {choice_answers} cha @@ -76,7 +73,7 @@ $printsection = ""; if ($choice->section !== $currentsection) { if ($choice->section) { - $printsection = get_section_name($course, $sections[$choice->section]); + $printsection = get_section_name($course, $choice->section); } if ($currentsection !== "") { $table->data[] = 'hr'; diff --git a/mod/data/index.php b/mod/data/index.php index f443b7e37fb..94a7323f394 100644 --- a/mod/data/index.php +++ b/mod/data/index.php @@ -56,9 +56,6 @@ if (! $datas = get_all_instances_in_course("data", $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $timenow = time(); $strname = get_string('name'); @@ -120,7 +117,7 @@ foreach ($datas as $data) { if ($usesections) { if ($data->section !== $currentsection) { if ($data->section) { - $printsection = get_section_name($course, $sections[$data->section]); + $printsection = get_section_name($course, $data->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/feedback/index.php b/mod/feedback/index.php index 327264f642c..a1a42ff9cbb 100644 --- a/mod/feedback/index.php +++ b/mod/feedback/index.php @@ -61,9 +61,6 @@ if (! $feedbacks = get_all_instances_in_course("feedback", $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} /// Print the list of instances (your module will probably extend this) @@ -105,7 +102,7 @@ foreach ($feedbacks as $feedback) { $link = ''.$feedback->name.''; if ($usesections) { - $tabledata = array (get_section_name($course, $sections[$feedback->section]), $link); + $tabledata = array (get_section_name($course, $feedback->section), $link); } else { $tabledata = array ($link); } diff --git a/mod/folder/index.php b/mod/folder/index.php index 5a3597dd795..9cbe696bdc7 100644 --- a/mod/folder/index.php +++ b/mod/folder/index.php @@ -54,9 +54,6 @@ if (!$folders = get_all_instances_in_course('folder', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -77,7 +74,7 @@ foreach ($folders as $folder) { $printsection = ''; if ($folder->section !== $currentsection) { if ($folder->section) { - $printsection = get_section_name($course, $sections[$folder->section]); + $printsection = get_section_name($course, $folder->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 84132a6dc0b..efbb8df0457 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -219,7 +219,6 @@ $modinfo = get_fast_modinfo($course); if (isset($modinfo->instances['forum'])) { $forummenu = array(); - $sections = get_all_sections($course->id); // Check forum types and eliminate simple discussions. $forumcheck = $DB->get_records('forum', array('course' => $course->id),'', 'id, type'); foreach ($modinfo->instances['forum'] as $forumcm) { @@ -228,7 +227,7 @@ continue; } $section = $forumcm->sectionnum; - $sectionname = get_section_name($course, $sections[$section]); + $sectionname = get_section_name($course, $section); if (empty($forummenu[$section])) { $forummenu[$section] = array($sectionname => array()); } diff --git a/mod/forum/index.php b/mod/forum/index.php index 5d0b5c53bfe..fd91cc5fb6b 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -104,7 +104,6 @@ if ($show_rss = (($can_subscribe || $course->id == SITEID) && } $usesections = course_format_uses_sections($course->format); -$sections = get_all_sections($course->id); $table = new html_table(); @@ -358,7 +357,7 @@ if ($course->id != SITEID) { // Only real courses have learning forums $forum->intro = shorten_text(format_module_intro('forum', $forum, $cm->id), $CFG->forum_shortpost); if ($cm->sectionnum != $currentsection) { - $printsection = get_section_name($course, $sections[$cm->sectionnum]); + $printsection = get_section_name($course, $cm->sectionnum); if ($currentsection) { $learningtable->data[] = 'hr'; } diff --git a/mod/glossary/index.php b/mod/glossary/index.php index 7979c29c3c3..b20829d1315 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -44,9 +44,6 @@ if (! $glossarys = get_all_instances_in_course("glossary", $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} /// Print the list of instances (your module will probably extend this) @@ -88,7 +85,7 @@ foreach ($glossarys as $glossary) { if ($usesections) { if ($glossary->section !== $currentsection) { if ($glossary->section) { - $printsection = get_section_name($course, $sections[$glossary->section]); + $printsection = get_section_name($course, $glossary->section); } if ($currentsection !== "") { $table->data[] = 'hr'; diff --git a/mod/imscp/index.php b/mod/imscp/index.php index be1d4fa05d1..53505da6c4d 100644 --- a/mod/imscp/index.php +++ b/mod/imscp/index.php @@ -54,9 +54,6 @@ if (!$imscps = get_all_instances_in_course('imscp', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -77,7 +74,7 @@ foreach ($imscps as $imscp) { $printsection = ''; if ($imscp->section !== $currentsection) { if ($imscp->section) { - $printsection = get_section_name($course, $sections[$imscp->section]); + $printsection = get_section_name($course, $imscp->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/lesson/index.php b/mod/lesson/index.php index 27ae03aa2b6..67b717a80ad 100644 --- a/mod/lesson/index.php +++ b/mod/lesson/index.php @@ -62,9 +62,6 @@ if (! $lessons = get_all_instances_in_course("lesson", $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} /// Print the list of instances (your module will probably extend this) @@ -113,7 +110,7 @@ foreach ($lessons as $lesson) { $grade_value = $return[$USER->id]->rawgrade; } } - $table->data[] = array (get_section_name($course, $sections[$lesson->section]), $link, $grade_value, $due); + $table->data[] = array (get_section_name($course, $lesson->section), $link, $grade_value, $due); } else { $table->data[] = array ($link, $lesson->grade, $due); } diff --git a/mod/lti/index.php b/mod/lti/index.php index 65f59897303..346f6e1c3b8 100644 --- a/mod/lti/index.php +++ b/mod/lti/index.php @@ -79,9 +79,6 @@ $timenow = time(); $strname = get_string("name"); $strsectionname = get_string('sectionname', 'format_'.$course->format); $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -102,8 +99,8 @@ foreach ($basicltis as $basiclti) { $link = "coursemodule\">$basiclti->name"; } - if ($course->format == "weeks" or $course->format == "topics") { - $table->data[] = array ($basiclti->section, $link); + if ($usesections) { + $table->data[] = array (get_section_name($course, $basiclti->section), $link); } else { $table->data[] = array ($link); } diff --git a/mod/page/index.php b/mod/page/index.php index 8ea91657171..9843372b9f6 100644 --- a/mod/page/index.php +++ b/mod/page/index.php @@ -54,9 +54,6 @@ if (!$pages = get_all_instances_in_course('page', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -77,7 +74,7 @@ foreach ($pages as $page) { $printsection = ''; if ($page->section !== $currentsection) { if ($page->section) { - $printsection = get_section_name($course, $sections[$page->section]); + $printsection = get_section_name($course, $page->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/quiz/index.php b/mod/quiz/index.php index 8249d68e6ed..1d3063906cc 100644 --- a/mod/quiz/index.php +++ b/mod/quiz/index.php @@ -62,7 +62,6 @@ if (!$quizzes = get_all_instances_in_course("quiz", $course)) { notice(get_string('thereareno', 'moodle', $strquizzes), "../../course/view.php?id=$course->id"); die; } -$sections = get_all_sections($course->id); // Check if we need the closing date header. $showclosingheader = false; @@ -132,7 +131,7 @@ foreach ($quizzes as $quiz) { if ($quiz->section != $currentsection) { if ($quiz->section) { $strsection = $quiz->section; - $strsection = get_section_name($course, $sections[$quiz->section]); + $strsection = get_section_name($course, $quiz->section); } if ($currentsection) { $learningtable->data[] = 'hr'; diff --git a/mod/resource/index.php b/mod/resource/index.php index f3c516ca76d..3e9baf3d7d7 100644 --- a/mod/resource/index.php +++ b/mod/resource/index.php @@ -54,9 +54,6 @@ if (!$resources = get_all_instances_in_course('resource', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -77,7 +74,7 @@ foreach ($resources as $resource) { $printsection = ''; if ($resource->section !== $currentsection) { if ($resource->section) { - $printsection = get_section_name($course, $sections[$resource->section]); + $printsection = get_section_name($course, $resource->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/scorm/index.php b/mod/scorm/index.php index eb0428c4656..4daa0b45cb4 100644 --- a/mod/scorm/index.php +++ b/mod/scorm/index.php @@ -48,9 +48,6 @@ $PAGE->navbar->add($strscorms); echo $OUTPUT->header(); $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} if ($usesections) { $sortorder = "cw.section ASC"; @@ -78,7 +75,7 @@ foreach ($scorms as $scorm) { $tt = ""; if ($usesections) { if ($scorm->section) { - $tt = get_section_name($course, $sections[$scorm->section]); + $tt = get_section_name($course, $scorm->section); } } else { $tt = userdate($scorm->timemodified); diff --git a/mod/survey/index.php b/mod/survey/index.php index 6154acfa2f5..e9f2f3f5b39 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -33,9 +33,6 @@ } $usesections = course_format_uses_sections($course->format); - if ($usesections) { - $sections = get_all_sections($course->id); - } $table = new html_table(); $table->width = '100%'; @@ -58,7 +55,7 @@ if ($usesections) { if ($survey->section !== $currentsection) { if ($survey->section) { - $printsection = get_section_name($course, $sections[$survey->section]); + $printsection = get_section_name($course, $survey->section); } if ($currentsection !== "") { $table->data[] = 'hr'; diff --git a/mod/url/index.php b/mod/url/index.php index 524bda829ff..e5d096dd42c 100644 --- a/mod/url/index.php +++ b/mod/url/index.php @@ -54,9 +54,6 @@ if (!$urls = get_all_instances_in_course('url', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -77,7 +74,7 @@ foreach ($urls as $url) { $printsection = ''; if ($url->section !== $currentsection) { if ($url->section) { - $printsection = get_section_name($course, $sections[$url->section]); + $printsection = get_section_name($course, $url->section); } if ($currentsection !== '') { $table->data[] = 'hr'; diff --git a/mod/wiki/index.php b/mod/wiki/index.php index 411aaa1a894..c2e3c6e328b 100644 --- a/mod/wiki/index.php +++ b/mod/wiki/index.php @@ -64,9 +64,6 @@ if (!$wikis = get_all_instances_in_course("wiki", $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} /// Print the list of instances (your module will probably extend this) @@ -89,7 +86,7 @@ foreach ($wikis as $wiki) { $link = html_writer::link(new moodle_url('/mod/wiki/view.php', array('id' => $wiki->coursemodule)), $wiki->name, $linkcss); if ($usesections) { - $table->data[] = array(get_section_name($course, $sections[$wiki->section]), $link); + $table->data[] = array(get_section_name($course, $wiki->section), $link); } else { $table->data[] = array($link); } diff --git a/mod/workshop/index.php b/mod/workshop/index.php index 7a7ea2774cd..263807a87aa 100644 --- a/mod/workshop/index.php +++ b/mod/workshop/index.php @@ -55,9 +55,6 @@ if (! $workshops = get_all_instances_in_course('workshop', $course)) { } $usesections = course_format_uses_sections($course->format); -if ($usesections) { - $sections = get_all_sections($course->id); -} $timenow = time(); $strsectionname = get_string('sectionname', 'format_'.$course->format); @@ -82,7 +79,7 @@ foreach ($workshops as $workshop) { } if ($usesections) { - $table->data[] = array(get_section_name($course, $sections[$workshop->section]), $link); + $table->data[] = array(get_section_name($course, $workshop->section), $link); } else { $table->data[] = array($link); } diff --git a/report/log/locallib.php b/report/log/locallib.php index fc08362349d..5fda822e387 100644 --- a/report/log/locallib.php +++ b/report/log/locallib.php @@ -226,13 +226,12 @@ function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0, /// Casting $course->modinfo to string prevents one notice when the field is null if ($modinfo = unserialize((string)$course->modinfo)) { $section = 0; - $sections = get_all_sections($course->id); foreach ($modinfo as $mod) { if ($mod->mod == "label") { continue; } if ($mod->section > 0 and $section <> $mod->section) { - $activities["section/$mod->section"] = '--- '.get_section_name($course, $sections[$mod->section]).' ---'; + $activities["section/$mod->section"] = '--- '.get_section_name($course, $mod->section).' ---'; } $section = $mod->section; $mod->name = strip_tags(format_string($mod->name, true)); @@ -476,13 +475,12 @@ function report_log_print_selector_form($course, $selecteduser=0, $selecteddate= /// Casting $course->modinfo to string prevents one notice when the field is null if ($modinfo = unserialize((string)$course->modinfo)) { $section = 0; - $sections = get_all_sections($course->id); foreach ($modinfo as $mod) { if ($mod->mod == "label") { continue; } if ($mod->section > 0 and $section <> $mod->section) { - $activities["section/$mod->section"] = '--- '.get_section_name($course, $sections[$mod->section]).' ---'; + $activities["section/$mod->section"] = '--- '.get_section_name($course, $mod->section).' ---'; } $section = $mod->section; $mod->name = strip_tags(format_string($mod->name, true)); diff --git a/report/outline/index.php b/report/outline/index.php index f652ddf5bbb..15c7296d8f0 100644 --- a/report/outline/index.php +++ b/report/outline/index.php @@ -79,7 +79,6 @@ if ($showlastaccess) { } $modinfo = get_fast_modinfo($course); -$sections = get_all_sections($course->id); $sql = "SELECT cm.id, COUNT('x') AS numviews, MAX(time) AS lasttime FROM {course_modules} cm @@ -105,7 +104,7 @@ foreach ($modinfo->sections as $sectionnum=>$section) { $sectioncell = new html_table_cell(); $sectioncell->colspan = count($outlinetable->head); - $sectiontitle = get_section_name($course, $sections[$sectionnum]); + $sectiontitle = get_section_name($course, $sectionnum); $sectioncell->text = $OUTPUT->heading($sectiontitle, 3); $sectionrow->cells[] = $sectioncell; diff --git a/report/outline/user.php b/report/outline/user.php index 2921c0cd774..2e34a2cfe89 100644 --- a/report/outline/user.php +++ b/report/outline/user.php @@ -66,21 +66,15 @@ $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); -get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); -$sections = get_all_sections($course->id); +$modinfo = get_fast_modinfo($course); +$sections = $modinfo->get_section_info_all(); $itemsprinted = false; -for ($i=0; $i<=$course->numsections; $i++) { +foreach ($sections as $i => $section) { - if (isset($sections[$i])) { // should always be true - - $section = $sections[$i]; - $showsection = (has_capability('moodle/course:viewhiddensections', $coursecontext) or $section->visible or !$course->hiddensections); - - if ($showsection) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert! - // Check the section has a sequence. This is the sequence of modules/resources. - // If there is no sequence there is nothing to display. - if ($section->sequence) { + if ($section->uservisible) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert! + // Check the section has modules/resources, if not there is nothing to display. + if (!empty($modinfo->sections[$i])) { $itemsprinted = true; echo '
'; echo '

'; @@ -93,14 +87,10 @@ for ($i=0; $i<=$course->numsections; $i++) { echo ""; } - $sectionmods = explode(",", $section->sequence); - foreach ($sectionmods as $sectionmod) { - if (empty($mods[$sectionmod])) { - continue; - } - $mod = $mods[$sectionmod]; + foreach($modinfo->sections[$i] as $cmid) { + $mod = $modinfo->cms[$cmid]; - if (empty($mod->visible)) { + if (empty($mod->uservisible)) { continue; } @@ -151,7 +141,6 @@ for ($i=0; $i<=$course->numsections; $i++) { echo ''; // section } } - } } if (!$itemsprinted) {