MDL-35339 avoid using get_all_sections(), get_all_mods() and field section.sequence directly

This commit is contained in:
Marina Glancy 2012-09-13 16:18:11 +08:00
parent ecfe814e0f
commit 71a56e08c8
31 changed files with 65 additions and 154 deletions

View File

@ -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.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
}
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) {

View File

@ -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.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
}
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) {

View File

@ -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;
}

View File

@ -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)) {

View File

@ -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) {

View File

@ -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';

View File

@ -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';

View File

@ -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;

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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 = '<a '.$dimmedclass.' href="'.$viewurl->out().'">'.$feedback->name.'</a>';
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);
}

View File

@ -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';

View File

@ -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());
}

View File

@ -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';
}

View File

@ -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';

View File

@ -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';

View File

@ -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);
}

View File

@ -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 = "<a href=\"view.php?id=$basiclti->coursemodule\">$basiclti->name</a>";
}
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);
}

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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);

View File

@ -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';

View File

@ -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';

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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));

View File

@ -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;

View File

@ -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 '<div class="section">';
echo '<h2>';
@ -93,14 +87,10 @@ for ($i=0; $i<=$course->numsections; $i++) {
echo "<table cellpadding=\"4\" cellspacing=\"0\">";
}
$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 '</div>'; // section
}
}
}
}
if (!$itemsprinted) {