";
+ echo get_section_name($course, $section);
+ echo "";
echo '
';
diff --git a/lib/navigationlib.php b/lib/navigationlib.php
index 607fdc04e9b..e99a73c8056 100644
--- a/lib/navigationlib.php
+++ b/lib/navigationlib.php
@@ -1320,8 +1320,9 @@ class global_navigation extends navigation_node {
} else {
$activeparam = 'section';
}
-
- foreach ($sections as &$section) {
+ $navigationsections = array();
+ foreach ($sections as $sectionid=>$section) {
+ $section = clone($section);
if ($course->id == SITEID) {
$this->load_section_activities($coursenode, $section->section, $modinfo);
} else {
@@ -1342,9 +1343,10 @@ class global_navigation extends navigation_node {
$this->load_section_activities($sectionnode, $section->section, $modinfo);
}
$section->sectionnode = $sectionnode;
+ $navigationsections[$sectionid] = $section;
}
}
- return $sections;
+ return $navigationsections;
}
/**
* Loads all of the activities for a section into the navigation structure.
@@ -2580,10 +2582,8 @@ class settings_navigation extends navigation_node {
$formatstring = get_string('topic');
$formatidentifier = optional_param('topic', 0, PARAM_INT);
}
- if (!$this->cache->cached('coursesections'.$course->id)) {
- $this->cache->{'coursesections'.$course->id} = get_all_sections($course->id);
- }
- $sections = $this->cache->{'coursesections'.$course->id};
+
+ $sections = get_all_sections($course->id);
$addresource = $this->add(get_string('addresource'));
$addactivity = $this->add(get_string('addactivity'));
diff --git a/mod/assignment/index.php b/mod/assignment/index.php
index e4668637a3f..467bcbaee0d 100644
--- a/mod/assignment/index.php
+++ b/mod/assignment/index.php
@@ -18,8 +18,7 @@ add_to_log($course->id, "assignment", "view all", "index.php?id=$course->id", ""
$strassignments = get_string("modulenameplural", "assignment");
$strassignment = get_string("modulename", "assignment");
$strassignmenttype = get_string("assignmenttype", "assignment");
-$strweek = get_string("week");
-$strtopic = get_string("topic");
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
$strduedate = get_string("duedate", "assignment");
$strsubmitted = get_string("submitted", "assignment");
@@ -37,15 +36,17 @@ if (!$cms = get_coursemodules_in_course('assignment', $course->id, 'cm.idnumber,
die;
}
+$usesections = course_format_uses_sections($course->format);
+if ($usesections) {
+ $sections = get_all_sections($course->id);
+}
+
$timenow = time();
$table = new html_table();
-if ($course->format == "weeks") {
- $table->head = array ($strweek, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
- $table->align = array ("center", "left", "left", "left", "right");
-} else if ($course->format == "topics") {
- $table->head = array ($strtopic, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
$table->align = array ("center", "left", "left", "left", "right");
} else {
$table->head = array ($strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
@@ -72,14 +73,16 @@ foreach ($modinfo->instances['assignment'] as $cm) {
$link = "
id\">".format_string($cm->name)."";
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($usesections) {
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = get_section_name($course, $sections[$cm->sectionnum]);
+ }
+ if ($currentsection !== "") {
+ $table->data[] = 'hr';
+ }
+ $currentsection = $cm->sectionnum;
}
- if ($currentsection !== "") {
- $table->data[] = 'hr';
- }
- $currentsection = $cm->sectionnum;
}
if (!file_exists($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php')) {
@@ -111,7 +114,7 @@ foreach ($modinfo->instances['assignment'] as $cm) {
$due = $cm->timedue ? userdate($cm->timedue) : '-';
- if ($course->format == "weeks" or $course->format == "topics") {
+ if ($usesections) {
$table->data[] = array ($printsection, $link, $type, $due, $submitted, $grade);
} else {
$table->data[] = array ($link, $type, $due, $submitted, $grade);
diff --git a/mod/assignment/type/online/all.php b/mod/assignment/type/online/all.php
index 3c8a6702a1f..d2861bee2f3 100644
--- a/mod/assignment/type/online/all.php
+++ b/mod/assignment/type/online/all.php
@@ -40,8 +40,6 @@ $str->emptysubmission = get_string('emptysubmission','assignment');
$str->noassignments = get_string('noassignments','assignment');
$str->onlinetext = get_string('typeonline','assignment');
$str->submitted = get_string('submitted','assignment');
-$str->topic = get_string('topic');
-$str->week = get_string('week');
$PAGE->navbar->add($str->assignments, new moodle_url('/mod/assignment/index.php', array('id'=>$id)));
$PAGE->navbar->add($str->onlinetext);
@@ -49,16 +47,7 @@ $PAGE->navbar->add($str->onlinetext);
// get all the assignments in the course
$assignments = get_all_instances_in_course('assignment',$course, $USER->id );
-// get correct text for course type
-if ($course->format=='weeks') {
- $courseformat = $str->week;
-
-} else if ($course->format=='topics') {
- $courseformat = $str->topic;
-
-} else {
- $courseformat = '';
-}
+$sections = get_all_sections($course->id);
// array to hold display data
$views = array();
@@ -109,11 +98,7 @@ foreach( $assignments as $assignment ) {
$view = new stdClass;
// start to build view object
- if (!empty($courseformat)) {
- $view->section = "$courseformat {$assignment->section}";
- } else {
- $view->section = '';
- }
+ $view->section = get_section_name($course, $sections[$assignment->section]);
$view->name = $assignment->name;
$view->submitted = $submitted;
diff --git a/mod/chat/index.php b/mod/chat/index.php
index 2a773c108b4..c3c70c75f64 100644
--- a/mod/chat/index.php
+++ b/mod/chat/index.php
@@ -19,6 +19,7 @@ add_to_log($course->id, 'chat', 'view all', "index.php?id=$course->id", '');
/// Get all required strings
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strchats = get_string('modulenameplural', 'chat');
$strchat = get_string('modulename', 'chat');
@@ -35,24 +36,24 @@ if (! $chats = get_all_instances_in_course('chat', $course)) {
die();
}
+$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)
$timenow = time();
$strname = get_string('name');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
$table = new html_table();
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname);
$table->align = array ('center', 'left');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname);
- $table->align = array ('center', 'left', 'left', 'left');
} else {
$table->head = array ($strname);
- $table->align = array ('left', 'left', 'left');
+ $table->align = array ('left');
}
$currentsection = '';
@@ -67,14 +68,14 @@ foreach ($chats as $chat) {
$printsection = '';
if ($chat->section !== $currentsection) {
if ($chat->section) {
- $printsection = $chat->section;
+ $printsection = get_section_name($course, $sections[$chat->section]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
$currentsection = $chat->section;
}
- if ($course->format == 'weeks' or $course->format == 'topics') {
+ if ($usesection) {
$table->data[] = array ($printsection, $link);
} else {
$table->data[] = array ($link);
diff --git a/mod/choice/index.php b/mod/choice/index.php
index e3917594ce2..b0a3dd65ae8 100644
--- a/mod/choice/index.php
+++ b/mod/choice/index.php
@@ -18,6 +18,7 @@
$strchoice = get_string("modulename", "choice");
$strchoices = get_string("modulenameplural", "choice");
+ $strsectionname = get_string('sectionname', 'format_'.$course->format);
$PAGE->set_title($strchoices);
$PAGE->navbar->add($strchoices);
echo $OUTPUT->header();
@@ -26,6 +27,11 @@
notice(get_string('thereareno', 'moodle', $strchoices), "../../course/view.php?id=$course->id");
}
+ $usesections = course_format_uses_sections($course->format);
+ if ($usesections) {
+ $sections = get_all_sections($course->id);
+ }
+
$sql = "SELECT cha.*
FROM {choice} ch, {choice_answers} cha
WHERE cha.choiceid = ch.id AND
@@ -44,11 +50,8 @@
$table = new html_table();
- if ($course->format == "weeks") {
- $table->head = array (get_string("week"), get_string("question"), get_string("answer"));
- $table->align = array ("center", "left", "left");
- } else if ($course->format == "topics") {
- $table->head = array (get_string("topic"), get_string("question"), get_string("answer"));
+ if ($usesections) {
+ $table->head = array ($strsectionname, get_string("question"), get_string("answer"));
$table->align = array ("center", "left", "left");
} else {
$table->head = array (get_string("question"), get_string("answer"));
@@ -68,15 +71,17 @@
} else {
$aa = "";
}
- $printsection = "";
- if ($choice->section !== $currentsection) {
- if ($choice->section) {
- $printsection = $choice->section;
+ if ($usesections) {
+ $printsection = "";
+ if ($choice->section !== $currentsection) {
+ if ($choice->section) {
+ $printsection = get_section_name($course, $sections[$choice->section]);
+ }
+ if ($currentsection !== "") {
+ $table->data[] = 'hr';
+ }
+ $currentsection = $choice->section;
}
- if ($currentsection !== "") {
- $table->data[] = 'hr';
- }
- $currentsection = $choice->section;
}
//Calculate the href
@@ -87,7 +92,7 @@
//Show normal if the mod is visible
$tt_href = "
coursemodule\">".format_string($choice->name,true)."";
}
- if ($course->format == "weeks" || $course->format == "topics") {
+ if ($usesections) {
$table->data[] = array ($printsection, $tt_href, $aa);
} else {
$table->data[] = array ($tt_href, $aa);
diff --git a/mod/data/index.php b/mod/data/index.php
index 00178570847..a6914970bf3 100755
--- a/mod/data/index.php
+++ b/mod/data/index.php
@@ -41,8 +41,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id);
add_to_log($course->id, "data", "view all", "index.php?id=$course->id", "");
-$strweek = get_string('week');
-$strtopic = get_string('topic');
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string('name');
$strdata = get_string('modulename','data');
$strdataplural = get_string('modulenameplural','data');
@@ -56,21 +55,21 @@ if (! $datas = get_all_instances_in_course("data", $course)) {
notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id");
}
+$usesections = course_format_uses_sections($course->format);
+if ($usesections) {
+ $sections = get_all_sections($course->id);
+}
+
$timenow = time();
$strname = get_string('name');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
$strdescription = get_string("description");
$strentries = get_string('entries', 'data');
$strnumnotapproved = get_string('numnotapproved', 'data');
$table = new html_table();
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname, $strdescription, $strentries, $strnumnotapproved);
- $table->align = array ('center', 'center', 'center', 'center', 'center');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname, $strdescription, $strentries, $strnumnotapproved);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strdescription, $strentries, $strnumnotapproved);
$table->align = array ('center', 'center', 'center', 'center', 'center');
} else {
$table->head = array ($strname, $strdescription, $strentries, $strnumnotapproved);
@@ -118,10 +117,10 @@ foreach ($datas as $data) {
$rsslink = rss_get_link($context->id, $USER->id, 'data', $data->id, 'RSS');
}
- if ($course->format == 'weeks' or $course->format == 'topics') {
+ if ($usesections) {
if ($data->section !== $currentsection) {
if ($data->section) {
- $printsection = $data->section;
+ $printsection = get_section_name($course, $sections[$data->section]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
diff --git a/mod/feedback/index.php b/mod/feedback/index.php
index 1e9ab624bab..6794825df47 100644
--- a/mod/feedback/index.php
+++ b/mod/feedback/index.php
@@ -47,30 +47,26 @@ if (! $feedbacks = get_all_instances_in_course("feedback", $course)) {
die;
}
+$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)
$timenow = time();
$strname = get_string("name");
-$strweek = get_string("week");
-$strtopic = get_string("topic");
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strresponses = get_string('responses', 'feedback');
$table = new html_table();
-if ($course->format == "weeks") {
+if ($usesections) {
if(has_capability('mod/feedback:viewreports', $context)) {
- $table->head = array ($strweek, $strname, $strresponses);
+ $table->head = array ($strsectionname, $strname, $strresponses);
$table->align = array ("center", "left", 'center');
}else{
- $table->head = array ($strweek, $strname);
- $table->align = array ("center", "left");
- }
-} else if ($course->format == "topics") {
- if(has_capability('mod/feedback:viewreports', $context)) {
- $table->head = array ($strtopic, $strname, $strresponses);
- $table->align = array ("center", "left", "center");
- }else{
- $table->head = array ($strtopic, $strname);
+ $table->head = array ($strsectionname, $strname);
$table->align = array ("center", "left");
}
} else {
@@ -95,8 +91,8 @@ foreach ($feedbacks as $feedback) {
$dimmedclass = $feedback->visible ? '' : 'class="dimmed"';
$link = '
'.$feedback->name.'';
- if ($course->format == "weeks" or $course->format == "topics") {
- $tabledata = array ($feedback->section, $link);
+ if ($usesections) {
+ $tabledata = array (get_section_name($course, $sections[$feedback->section]), $link);
} else {
$tabledata = array ($link);
}
diff --git a/mod/folder/index.php b/mod/folder/index.php
index 6e5a418e39f..9a54a501eb8 100644
--- a/mod/folder/index.php
+++ b/mod/folder/index.php
@@ -36,8 +36,7 @@ add_to_log($course->id, 'folder', 'view all', "index.php?id=$course->id", '');
$strfolder = get_string('modulename', 'folder');
$strfolders = get_string('modulenameplural', 'folder');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
@@ -53,14 +52,16 @@ if (!$folders = get_all_instances_in_course('folder', $course)) {
exit;
}
+$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';
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname, $strintro);
- $table->align = array ('center', 'left', 'left');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname, $strintro);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
$table->head = array ($strlastmodified, $strname, $strintro);
@@ -71,11 +72,11 @@ $modinfo = get_fast_modinfo($course);
$currentsection = '';
foreach ($folders as $folder) {
$cm = $modinfo->cms[$folder->coursemodule];
- if ($course->format == 'weeks' or $course->format == 'topics') {
+ if ($usesections) {
$printsection = '';
if ($folder->section !== $currentsection) {
if ($folder->section) {
- $printsection = $folder->section;
+ $printsection = get_section_name($course, $sections[$folder->section]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php
index e6dd2ea5fcb..e38b6057227 100644
--- a/mod/forum/discuss.php
+++ b/mod/forum/discuss.php
@@ -231,12 +231,8 @@
// single discussion forum can't be moved.
$modinfo = get_fast_modinfo($course);
if (isset($modinfo->instances['forum'])) {
- if ($course->format == 'weeks') {
- $strsection = get_string("week");
- } else {
- $strsection = get_string("topic");
- }
$forummenu = array();
+ $sections = get_all_sections($course->id);
foreach ($modinfo->instances['forum'] as $forumcm) {
if (!$forumcm->uservisible || !has_capability('mod/forum:startdiscussion',
get_context_instance(CONTEXT_MODULE,$forumcm->id))) {
@@ -244,12 +240,13 @@
}
$section = $forumcm->sectionnum;
+ $sectionname = get_section_name($course, $sections[$section]);
if (empty($forummenu[$section])) {
- $forummenu[$section] = array("$strsection $section" => array());
+ $forummenu[$section] = array($sectionname => array());
}
if ($forumcm->instance != $forum->id) {
$url = "/mod/forum/discuss.php?d=$discussion->id&move=$forumcm->instance&sesskey=".sesskey();
- $forummenu[$section]["$strsection $section"][$url] = format_string($forumcm->name);
+ $forummenu[$section][$sectionname][$url] = format_string($forumcm->name);
}
}
if (!empty($forummenu)) {
diff --git a/mod/forum/index.php b/mod/forum/index.php
index a09e7804577..07d442fb5ae 100644
--- a/mod/forum/index.php
+++ b/mod/forum/index.php
@@ -67,8 +67,7 @@ $strunsubscribe = get_string('unsubscribe', 'forum');
$stryes = get_string('yes');
$strno = get_string('no');
$strrss = get_string('rss');
-$strweek = get_string('week');
-$strsection = get_string('section');
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$searchform = forum_search_form($course);
@@ -103,6 +102,10 @@ if ($show_rss = (($can_subscribe || $course->id == SITEID) &&
$generaltable->align[] = 'center';
}
+$usesections = course_format_uses_sections($course->format);
+$sections = get_all_sections($course->id);
+
+$table = new html_table();
// Parse and organise all the forums. Most forums are course modules but
// some special ones are not. These get placed in the general forums
@@ -295,11 +298,7 @@ if ($show_rss = (($can_subscribe || $course->id == SITEID) &&
if ($course->id != SITEID) { // Only real courses have learning forums
// Add extra field for section number, at the front
- if ($course->format == 'weeks' or $course->format == 'weekscss') {
- array_unshift($learningtable->head, $strweek);
- } else {
- array_unshift($learningtable->head, $strsection);
- }
+ array_unshift($learningtable->head, $strsectionname);
array_unshift($learningtable->align, 'center');
@@ -344,7 +343,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 = $cm->sectionnum;
+ $printsection = get_section_name($course, $sections[$cm->sectionnum]);
if ($currentsection) {
$learningtable->data[] = 'hr';
}
diff --git a/mod/glossary/index.php b/mod/glossary/index.php
index ce511268d8f..7c5dfe1dccc 100644
--- a/mod/glossary/index.php
+++ b/mod/glossary/index.php
@@ -43,24 +43,25 @@ if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
die;
}
+$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)
$timenow = time();
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
-$strweek = get_string("week");
-$strtopic = get_string("topic");
$strentries = get_string("entries", "glossary");
$table = new html_table();
-if ($course->format == "weeks") {
- $table->head = array ($strweek, $strname, $strentries);
- $table->align = array ("CENTER", "LEFT", "CENTER");
-} else if ($course->format == "topics") {
- $table->head = array ($strtopic, $strname, $strentries);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ("CENTER", "LEFT", "CENTER");
} else {
- $table->head = array ($strname, $strentries);
+ $table->head = array ($strname, $strintro);
$table->align = array ("LEFT", "CENTER");
}
@@ -84,14 +85,16 @@ foreach ($glossarys as $glossary) {
continue;
}
$printsection = "";
- if ($glossary->section !== $currentsection) {
- if ($glossary->section) {
- $printsection = $glossary->section;
+ if ($usesections) {
+ if ($glossary->section !== $currentsection) {
+ if ($glossary->section) {
+ $printsection = get_section_name($course, $sections[$glossary->section]);
+ }
+ if ($currentsection !== "") {
+ $table->data[] = 'hr';
+ }
+ $currentsection = $glossary->section;
}
- if ($currentsection !== "") {
- $table->data[] = 'hr';
- }
- $currentsection = $glossary->section;
}
// TODO: count only approved if not allowed to see them
@@ -114,7 +117,7 @@ foreach ($glossarys as $glossary) {
}
}
- if ($course->format == "weeks" or $course->format == "topics") {
+ if ($usesections) {
$linedata = array ($printsection, $link, $count);
} else {
$linedata = array ($link, $count);
diff --git a/mod/hotpot/index.php b/mod/hotpot/index.php
index a44c5fd9e73..ed471d0aa6f 100644
--- a/mod/hotpot/index.php
+++ b/mod/hotpot/index.php
@@ -27,6 +27,7 @@
// get message strings for titles
$strmodulenameplural = get_string("modulenameplural", "hotpot");
$strmodulename = get_string("modulename", "hotpot");
+ $strsectionname = get_string('sectionname', 'format_'.$course->format);
// string translation array for single and double quotes
$quotes = array("'"=>"\'", '"'=>'"');
@@ -73,6 +74,11 @@
}
$hotpotids = implode(',', array_keys($hotpots));
+ $usesections = course_format_uses_sections($course->format);
+ if ($usesections) {
+ $sections = get_all_sections($course->id);
+ }
+
if (has_capability('mod/hotpot:grade', $sitecontext)) {
// array of hotpots to be regraded
@@ -264,17 +270,7 @@
print '
'.sprintf("%0.3f", microtime_diff($start, microtime())).' secs'."
\n";
}
- switch ($course->format) {
- case 'weeks' :
- $title = get_string("week");
- break;
- case 'topics' :
- $title = get_string("topic");
- break;
- default :
- $title = '';
- break;
- }
+ $title = $strsectionname;
if ($title) {
array_push($table->head, $title);
array_push($table->align, "center");
@@ -303,8 +299,8 @@
$printsection = "";
if ($hotpot->section != $currentsection) {
if ($hotpot->section) {
- $printsection = $hotpot->section;
- if ($course->format=='weeks' || $course->format=='topics') {
+ if ($usesections) {
+ $printsection = get_section_name($course, $sections[$hotpot->section]);
// Show the zoom boxes
if ($displaysection==$hotpot->section) {
$strshowall = get_string('showall'.$course->format);
@@ -358,7 +354,7 @@
$data = array ();
- if ($course->format=="weeks" || $course->format=="topics") {
+ if ($usesections) {
array_push($data, $printsection);
}
diff --git a/mod/imscp/index.php b/mod/imscp/index.php
index c6e59dd3788..de43f382f45 100644
--- a/mod/imscp/index.php
+++ b/mod/imscp/index.php
@@ -36,8 +36,7 @@ add_to_log($course->id, 'imscp', 'view all', "index.php?id=$course->id", '');
$strimscp = get_string('modulename', 'imscp');
$strimscps = get_string('modulenameplural', 'imscp');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
@@ -53,14 +52,16 @@ if (!$imscps = get_all_instances_in_course('imscp', $course)) {
exit;
}
+$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';
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname, $strintro);
- $table->align = array ('center', 'left', 'left');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname, $strintro);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
$table->head = array ($strlastmodified, $strname, $strintro);
@@ -71,11 +72,11 @@ $modinfo = get_fast_modinfo($course);
$currentsection = '';
foreach ($imscps as $imscp) {
$cm = $modinfo->cms[$imscp->coursemodule];
- if ($course->format == 'weeks' or $course->format == 'topics') {
+ if ($usesections) {
$printsection = '';
if ($imscp->section !== $currentsection) {
if ($imscp->section) {
- $printsection = $imscp->section;
+ $printsection = get_section_name($course, $sections[$imscp->section]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
diff --git a/mod/lesson/index.php b/mod/lesson/index.php
index 6f87d2bde02..21faf9f6366 100644
--- a/mod/lesson/index.php
+++ b/mod/lesson/index.php
@@ -60,22 +60,23 @@ if (! $lessons = get_all_instances_in_course("lesson", $course)) {
die;
}
+$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)
$timenow = time();
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
$strgrade = get_string("grade");
$strdeadline = get_string("deadline", "lesson");
-$strweek = get_string("week");
-$strtopic = get_string("topic");
$strnodeadline = get_string("nodeadline", "lesson");
$table = new html_table();
-if ($course->format == "weeks") {
- $table->head = array ($strweek, $strname, $strgrade, $strdeadline);
- $table->align = array ("center", "left", "center", "center");
-} else if ($course->format == "topics") {
- $table->head = array ($strtopic, $strname, $strgrade, $strdeadline);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strgrade, $strdeadline);
$table->align = array ("center", "left", "center", "center");
} else {
$table->head = array ($strname, $strgrade, $strdeadline);
@@ -101,7 +102,7 @@ foreach ($lessons as $lesson) {
$due = "
".userdate($lesson->deadline)."";
}
- if ($course->format == "weeks" or $course->format == "topics") {
+ if ($usesections) {
if (has_capability('mod/lesson:manage', $context)) {
$grade_value = $lesson->grade;
} else {
@@ -111,7 +112,7 @@ foreach ($lessons as $lesson) {
$grade_value = $return[$USER->id]->rawgrade;
}
}
- $table->data[] = array ($lesson->section, $link, $grade_value, $due);
+ $table->data[] = array (get_section_name($course, $sections[$lesson->section]), $link, $grade_value, $due);
} else {
$table->data[] = array ($link, $lesson->grade, $due);
}
diff --git a/mod/page/index.php b/mod/page/index.php
index 391e63b69b0..df24f84aa5a 100644
--- a/mod/page/index.php
+++ b/mod/page/index.php
@@ -36,8 +36,7 @@ add_to_log($course->id, 'page', 'view all', "index.php?id=$course->id", '');
$strpage = get_string('modulename', 'page');
$strpages = get_string('modulenameplural', 'page');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
@@ -53,14 +52,16 @@ if (!$pages = get_all_instances_in_course('page', $course)) {
exit;
}
+$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';
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname, $strintro);
- $table->align = array ('center', 'left', 'left');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname, $strintro);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
$table->head = array ($strlastmodified, $strname, $strintro);
@@ -71,11 +72,11 @@ $modinfo = get_fast_modinfo($course);
$currentsection = '';
foreach ($pages as $page) {
$cm = $modinfo->cms[$page->coursemodule];
- if ($course->format == 'weeks' or $course->format == 'topics') {
+ if ($usesections) {
$printsection = '';
if ($page->section !== $currentsection) {
if ($page->section) {
- $printsection = $page->section;
+ $printsection = get_section_name($course, $sections[$page->section]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
diff --git a/mod/quiz/index.php b/mod/quiz/index.php
index cf5dbbd43c4..125eac406d9 100644
--- a/mod/quiz/index.php
+++ b/mod/quiz/index.php
@@ -44,6 +44,7 @@
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;
@@ -69,11 +70,7 @@
array_push($align, 'left');
}
- if ($course->format == 'weeks' or $course->format == 'weekscss') {
- array_unshift($headings, get_string('week'));
- } else {
- array_unshift($headings, get_string('section'));
- }
+ array_unshift($headings, get_string('sectionname', 'format_'.$course->format));
array_unshift($align, 'center');
$showing = ''; // default
@@ -115,6 +112,7 @@
if ($quiz->section != $currentsection) {
if ($quiz->section) {
$strsection = $quiz->section;
+ $strsection = get_section_name($course, $sections[$quiz->section]);
}
if ($currentsection) {
$learningtable->data[] = 'hr';
diff --git a/mod/resource/index.php b/mod/resource/index.php
index fe937b90a00..a8963ebccd3 100644
--- a/mod/resource/index.php
+++ b/mod/resource/index.php
@@ -36,8 +36,7 @@ add_to_log($course->id, 'resource', 'view all', "index.php?id=$course->id", '');
$strresource = get_string('modulename', 'resource');
$strresources = get_string('modulenameplural', 'resource');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
@@ -53,14 +52,16 @@ if (!$resources = get_all_instances_in_course('resource', $course)) {
exit;
}
+$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';
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname, $strintro);
- $table->align = array ('center', 'left', 'left');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname, $strintro);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
$table->head = array ($strlastmodified, $strname, $strintro);
@@ -71,11 +72,11 @@ $modinfo = get_fast_modinfo($course);
$currentsection = '';
foreach ($resources as $resource) {
$cm = $modinfo->cms[$resource->coursemodule];
- if ($course->format == 'weeks' or $course->format == 'topics') {
+ if ($usesections) {
$printsection = '';
if ($resource->section !== $currentsection) {
if ($resource->section) {
- $printsection = $resource->section;
+ $printsection = get_section_name($course, $sections[$resource->section]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
diff --git a/mod/scorm/index.php b/mod/scorm/index.php
index ab97cc04039..3d16f2a06ab 100755
--- a/mod/scorm/index.php
+++ b/mod/scorm/index.php
@@ -22,8 +22,7 @@
$strscorm = get_string("modulename", "scorm");
$strscorms = get_string("modulenameplural", "scorm");
- $strweek = get_string("week");
- $strtopic = get_string("topic");
+ $strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
$strsummary = get_string("summary");
$strreport = get_string("report",'scorm');
@@ -34,7 +33,12 @@
$PAGE->navbar->add($strscorms);
echo $OUTPUT->header();
- if ($course->format == "weeks" or $course->format == "topics") {
+ $usesections = course_format_uses_sections($course->format);
+ if ($usesections) {
+ $sections = get_all_sections($course->id);
+ }
+
+ if ($usesections) {
$sortorder = "cw.section ASC";
} else {
$sortorder = "m.timemodified DESC";
@@ -47,11 +51,8 @@
$table = new html_table();
- if ($course->format == "weeks") {
- $table->head = array ($strweek, $strname, $strsummary, $strreport);
- $table->align = array ("center", "left", "left", "left");
- } else if ($course->format == "topics") {
- $table->head = array ($strtopic, $strname, $strsummary, $strreport);
+ if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else {
$table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
@@ -62,9 +63,9 @@
$context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);
$tt = "";
- if ($course->format == "weeks" or $course->format == "topics") {
+ if ($usesections) {
if ($scorm->section) {
- $tt = "$scorm->section";
+ $tt = get_section_name($course, $sections[$scorm->section]);
}
} else {
$tt = userdate($scorm->timemodified);
diff --git a/mod/survey/index.php b/mod/survey/index.php
index 55cbbe108f0..5e017ef6594 100644
--- a/mod/survey/index.php
+++ b/mod/survey/index.php
@@ -17,8 +17,7 @@
add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", "");
$strsurveys = get_string("modulenameplural", "survey");
- $strweek = get_string("week");
- $strtopic = get_string("topic");
+ $strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
$strstatus = get_string("status");
$strdone = get_string("done", "survey");
@@ -33,17 +32,19 @@
notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id");
}
+ $usesections = course_format_uses_sections($course->format);
+ if ($usesections) {
+ $sections = get_all_sections($course->id);
+ }
+
$table = new html_table();
- if ($course->format == "weeks") {
- $table->head = array ($strweek, $strname, $strstatus);
- $table->align = array ("CENTER", "LEFT", "LEFT");
- } else if ($course->format == "topics") {
- $table->head = array ($strtopic, $strname, $strstatus);
- $table->align = array ("CENTER", "LEFT", "LEFT");
+ if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strintro);
+ $table->align = array ('CENTER', 'LEFT', 'LEFT');
} else {
- $table->head = array ($strname, $strstatus);
- $table->align = array ("LEFT", "LEFT");
+ $table->head = array ($strname, $strintro);
+ $table->align = array ('LEFT', 'LEFT');
}
$currentsection = '';
@@ -55,14 +56,16 @@
$ss = $strnotdone;
}
$printsection = "";
- if ($survey->section !== $currentsection) {
- if ($survey->section) {
- $printsection = $survey->section;
+ if ($usesections) {
+ if ($survey->section !== $currentsection) {
+ if ($survey->section) {
+ $printsection = get_section_name($course, $sections[$survey->section]);
+ }
+ if ($currentsection !== "") {
+ $table->data[] = 'hr';
+ }
+ $currentsection = $survey->section;
}
- if ($currentsection !== "") {
- $table->data[] = 'hr';
- }
- $currentsection = $survey->section;
}
//Calculate the href
if (!$survey->visible) {
@@ -73,7 +76,7 @@
$tt_href = "
coursemodule\">".format_string($survey->name,true)."";
}
- if ($course->format == "weeks" or $course->format == "topics") {
+ if ($usesections) {
$table->data[] = array ($printsection, $tt_href, "
coursemodule\">$ss");
} else {
$table->data[] = array ($tt_href, "
coursemodule\">$ss");
diff --git a/mod/url/index.php b/mod/url/index.php
index ed1774e459f..9db9c346016 100644
--- a/mod/url/index.php
+++ b/mod/url/index.php
@@ -36,8 +36,6 @@ add_to_log($course->id, 'url', 'view all', "index.php?id=$course->id", '');
$strurl = get_string('modulename', 'url');
$strurls = get_string('modulenameplural', 'url');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
@@ -53,14 +51,16 @@ if (!$urls = get_all_instances_in_course('url', $course)) {
exit;
}
+$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';
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname, $strintro);
- $table->align = array ('center', 'left', 'left');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname, $strintro);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
$table->head = array ($strlastmodified, $strname, $strintro);
@@ -71,11 +71,11 @@ $modinfo = get_fast_modinfo($course);
$currentsection = '';
foreach ($urls as $url) {
$cm = $modinfo->cms[$url->coursemodule];
- if ($course->format == 'weeks' or $course->format == 'topics') {
+ if ($usesections) {
$printsection = '';
if ($url->section !== $currentsection) {
if ($url->section) {
- $printsection = $url->section;
+ $printsection = get_section_name($course, $sections[$url->section]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
diff --git a/mod/wiki/index.php b/mod/wiki/index.php
index a8653baf2b4..3ef412810d7 100644
--- a/mod/wiki/index.php
+++ b/mod/wiki/index.php
@@ -64,22 +64,23 @@ if (!$wikis = get_all_instances_in_course("wiki", $course)) {
die;
}
+$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)
$timenow = time();
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
-$strweek = get_string("week");
-$strtopic = get_string("topic");
-if ($course->format == "weeks") {
- $table->head = array($strweek, $strname);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname);
$table->align = array("center", "left");
-} else if ($course->format == "topics") {
- $table->head = array($strtopic, $strname);
- $table->align = array("center", "left", "left", "left");
} else {
- $table->head = array($strname);
- $table->align = array("left", "left", "left");
+ $table->head = array ($strname);
+ $table->align = array("left");
}
foreach ($wikis as $wiki) {
@@ -91,8 +92,8 @@ foreach ($wikis as $wiki) {
$link = "
coursemodule\">$wiki->name";
}
- if ($course->format == "weeks" or $course->format == "topics") {
- $table->data[] = array($wiki->section, $link);
+ if ($usesections) {
+ $table->data[] = array(get_section_name($course, $sections[$wiki->section]), $link);
} else {
$table->data[] = array($link);
}
diff --git a/mod/workshop/index.php b/mod/workshop/index.php
index c2bd9079c5d..172bd0e3098 100644
--- a/mod/workshop/index.php
+++ b/mod/workshop/index.php
@@ -59,22 +59,23 @@ if (! $workshops = get_all_instances_in_course('workshop', $course)) {
die();
}
+$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)
$timenow = time();
+$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string('name');
-$strweek = get_string('week');
-$strtopic = get_string('topic');
-if ($course->format == 'weeks') {
- $table->head = array ($strweek, $strname);
+if ($usesections) {
+ $table->head = array ($strsectionname, $strname);
$table->align = array ('center', 'left');
-} else if ($course->format == 'topics') {
- $table->head = array ($strtopic, $strname);
- $table->align = array ('center', 'left', 'left', 'left');
} else {
$table->head = array ($strname);
- $table->align = array ('left', 'left', 'left');
+ $table->align = array ('left');
}
foreach ($workshops as $workshop) {
@@ -86,8 +87,8 @@ foreach ($workshops as $workshop) {
$link = "
coursemodule\">$workshop->name";
}
- if ($course->format == 'weeks' or $course->format == 'topics') {
- $table->data[] = array ($workshop->section, $link);
+ if ($usesections) {
+ $table->data[] = array (get_section_name($course, $sections[$workshop->section]), $link);
} else {
$table->data[] = array ($link);
}