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) {
/// 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;
$this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&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) {
/// 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);
$this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&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) {
//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;
}
$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;
}
}
}
} 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';
$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) {
continue;
}
+ if (!empty($filter_modid) and $cmid != $filter_modid) {
+ continue;
+ }
+
$libfile = "$CFG->dirroot/mod/$cm->modname/lib.php";
if (file_exists($libfile)) {
$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
}
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) {
$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) {
$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';
}
$usesections = course_format_uses_sections($course->format);
-if ($usesections) {
- $sections = get_all_sections($course->id);
-}
$timenow = time();
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';
// 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();
$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;
}
$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';
$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';
}
$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)
$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';
}
$usesections = course_format_uses_sections($course->format);
- if ($usesections) {
- $sections = get_all_sections($course->id);
- }
$sql = "SELECT cha.*
FROM {choice} ch, {choice_answers} cha
$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';
}
$usesections = course_format_uses_sections($course->format);
-if ($usesections) {
- $sections = get_all_sections($course->id);
-}
$timenow = time();
$strname = get_string('name');
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';
}
$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)
$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);
}
}
$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';
$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';
$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) {
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());
}
}
$usesections = course_format_uses_sections($course->format);
-$sections = get_all_sections($course->id);
$table = new html_table();
$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';
}
}
$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)
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';
}
$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';
$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';
}
$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)
$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);
}
$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';
$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);
}
}
$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';
$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';
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;
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';
}
$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';
$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';
echo $OUTPUT->header();
$usesections = course_format_uses_sections($course->format);
-if ($usesections) {
- $sections = get_all_sections($course->id);
-}
if ($usesections) {
$sortorder = "cw.section ASC";
$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);
}
$usesections = course_format_uses_sections($course->format);
- if ($usesections) {
- $sections = get_all_sections($course->id);
- }
$table = new html_table();
$table->width = '100%';
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';
}
$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';
$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';
}
$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)
$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);
}
}
$usesections = course_format_uses_sections($course->format);
-if ($usesections) {
- $sections = get_all_sections($course->id);
-}
$timenow = time();
$strsectionname = get_string('sectionname', 'format_'.$course->format);
}
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);
}
/// 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));
/// 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));
}
$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
$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;
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>';
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;
}
echo '</div>'; // section
}
}
- }
}
if (!$itemsprinted) {