course formats MDL-22647 Course format names are now properly supported and used. Big thanks to Brandon Turner for the patch.

This commit is contained in:
Sam Hemelryk
2010-06-08 06:21:25 +00:00
parent 669a9e56a8
commit 7487c85699
34 changed files with 374 additions and 307 deletions
+3 -10
View File
@@ -66,16 +66,9 @@ if ($mform->is_cancelled()){
redirect("view.php?id=$course->id");
}
/// Inelegant hack for bug 3408
if ($course->format == 'site') {
$sectionname = get_string('site');
$stredit = get_string('edita', '', " $sectionname");
$strsummaryof = get_string('summaryof', '', " $sectionname");
} else {
$sectionname = get_section_name($course->format);
$stredit = get_string('edita', '', " $sectionname $section->section");
$strsummaryof = get_string('summaryof', '', " $sectionname $section->section");
}
$sectionname = get_section_name($course, $section);
$stredit = get_string('edita', '', " $sectionname");
$strsummaryof = get_string('summaryof', '', " $sectionname");
$PAGE->set_title($stredit);
$PAGE->set_heading($course->fullname);
@@ -23,6 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['sectionname'] = 'topic';
$string['sectionname'] = 'Topic';
$string['pluginname'] = 'Topics format';
$string['section0name'] = 'General';
+10
View File
@@ -23,6 +23,16 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Indicates this format uses sections.
*
* @return bool Returns true
*/
function callback_topics_uses_sections() {
return true;
}
/**
* Used to display the course structure for a course where format=topic
*
+1 -1
View File
@@ -23,6 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['sectionname'] = 'week';
$string['sectionname'] = 'Week';
$string['pluginname'] = 'Weekly format';
$string['section0name'] = 'General';
+19 -1
View File
@@ -23,6 +23,16 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Indicates this format uses sections.
*
* @return bool Returns true
*/
function callback_weeks_uses_sections() {
return true;
}
/**
* Used to display the course structure for a course where format=weeks
*
@@ -57,7 +67,14 @@ function callback_weeks_request_key() {
return 'week';
}
function callback_weeks_get_section_name($course, $section, $sections) {
/**
* Gets the name for the provided section.
*
* @param stdClass $course
* @param stdClass $section
* @return string
*/
function callback_weeks_get_section_name($course, $section) {
// We can't add a node without text
if (!empty($section->name)) {
// Return the name the user set
@@ -67,6 +84,7 @@ function callback_weeks_get_section_name($course, $section, $sections) {
return get_string('section0name', 'format_weeks');
} else {
// Got to work out the date of the week so that we can show it
$sections = get_all_sections($course->id);
$weekdate = $course->startdate+7200;
foreach ($sections as $sec) {
if ($sec->id == $section->id) {
+78 -7
View File
@@ -1174,11 +1174,25 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname
}
}
/**
* Returns an array of sections for the requested course id
*
* This function stores the sections against the course id within a staticvar encase
* of subsequent requests. This is used all over + in some standard libs and course
* format callbacks so subsequent requests are a reality.
*
* @staticvar array $coursesections
* @param int $courseid
* @return array Array of sections
*/
function get_all_sections($courseid) {
global $DB;
return $DB->get_records("course_sections", array("course"=>"$courseid"), "section",
"section, id, course, name, summary, summaryformat, sequence, visible");
static $coursesections = array();
if (!array_key_exists($courseid, $coursesections)) {
$coursesections[$courseid] = $DB->get_records("course_sections", array("course"=>"$courseid"), "section",
"section, id, course, name, summary, summaryformat, sequence, visible");
}
return $coursesections[$courseid];
}
function course_set_display($courseid, $display=0) {
@@ -3243,11 +3257,68 @@ function move_category($category, $newparentcat) {
}
/**
* @param string $format Course format ID e.g. 'weeks'
* @return Name that the course format prefers for sections
* Returns the display name of the given section that the course prefers.
*
* This function utilizes a callback that can be implemented within the course
* formats lib.php file to customize the display name that is used to reference
* the section.
*
* By default (if callback is not defined) the method
* {@see get_numeric_section_name} is called instead.
*
* @param stdClass $course The course to get the section name for
* @param stdClass $section Section object from database
* @return Display name that the course format prefers, e.g. "Week 2"
*
* @see get_generic_section_name
*/
function get_section_name($format) {
return get_string('sectionname', "format_$format");
function get_section_name(stdClass $course, stdClass $section) {
global $CFG;
/// Inelegant hack for bug 3408
if ($course->format == 'site') {
return get_string('site');
}
// Use course formatter callback if it exists
$namingfile = $CFG->dirroot.'/course/format/'.$course->format.'/lib.php';
$namingfunction = 'callback_'.$course->format.'_get_section_name';
if (!function_exists($namingfunction) && file_exists($namingfile)) {
require_once $namingfile;
}
if (function_exists($namingfunction)) {
return $namingfunction($course, $section);
}
// else, default behavior:
return get_generic_section_name($course->format, $section);
}
/**
* Gets the generic section name for a courses section.
*
* @param string $format Course format ID e.g. 'weeks' $course->format
* @param stdClass $section Section object from database
* @return Display name that the course format prefers, e.g. "Week 2"
*/
function get_generic_section_name($format, stdClass $section) {
return get_string('sectionname', "format_$format") . ' ' . $section->section;
}
function course_format_uses_sections($format) {
global $CFG;
$featurefile = $CFG->dirroot.'/course/format/'.$format.'/lib.php';
$featurefunction = 'callback_'.$format.'_uses_sections';
if (!function_exists($featurefunction) && file_exists($featurefile)) {
require_once $featurefile;
}
if (function_exists($featurefunction)) {
return $featurefunction();
}
return false;
}
/**
+4 -4
View File
@@ -87,13 +87,13 @@ if (!empty($add)) {
$data->type = $type;
}
$sectionname = get_section_name($course->format);
$sectionname = get_section_name($course, $cw);
$fullmodulename = get_string('modulename', $module->name);
if ($data->section && $course->format != 'site') {
$heading = new object();
$heading->what = $fullmodulename;
$heading->to = "$sectionname $data->section";
$heading->to = $sectionname;
$pageheading = get_string('addinganewto', 'moodle', $heading);
} else {
$pageheading = get_string('addinganew', 'moodle', $fullmodulename);
@@ -172,13 +172,13 @@ if (!empty($add)) {
}
}
$sectionname = get_section_name($course->format);
$sectionname = get_section_name($course, $cw);
$fullmodulename = get_string('modulename', $module->name);
if ($data->section && $course->format != 'site') {
$heading = new object();
$heading->what = $fullmodulename;
$heading->in = "$sectionname $cw->section";
$heading->in = $sectionname;
$pageheading = get_string('updatingain', 'moodle', $heading);
} else {
$pageheading = get_string('updatinga', 'moodle', $fullmodulename);
+5 -12
View File
@@ -91,12 +91,10 @@ if (has_capability('moodle/course:viewhiddensections', $context)) {
$hiddenfilter = "AND cs.visible = 1";
}
$sections = array();
if ($ss = $DB->get_records_sql("SELECT cs.id, cs.section, cs.sequence, cs.summary, cs.visible
FROM {course_sections} cs
WHERE cs.course = ? AND cs.section <= ?
$hiddenfilter
ORDER BY section", array($course->id, $course->numsections))) {
foreach ($ss as $section) {
$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;
}
}
@@ -122,11 +120,6 @@ if ($param->modid === 'all') {
$sections = array($section->sequence=>$section);
}
switch ($course->format) {
case 'weeks': $sectiontitle = get_string('week'); break;
case 'topics': $sectiontitle = get_string('topic'); break;
default: $sectiontitle = get_string('section'); break;
}
if (is_null($modinfo->groups)) {
$modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo
@@ -140,7 +133,7 @@ foreach ($sections as $section) {
$activity = new object();
$activity->type = 'section';
if ($section->section > 0) {
$activity->name = $sectiontitle.' '.$section->section;
$activity->name = get_section_name($course, $section);
} else {
$activity->name = '';
}
+3 -6
View File
@@ -36,6 +36,7 @@ class recent_form extends moodleform {
$mform =& $this->_form;
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
$modinfo = get_fast_modinfo($COURSE);
$sections = get_all_sections($COURSE->id);
$mform->addElement('header', 'filters', get_string('managefilters')); //TODO: add better string
@@ -70,11 +71,7 @@ class recent_form extends moodleform {
$mform->setAdvanced('user');
}
switch ($COURSE->format) {
case 'weeks': $sectiontitle = get_string('week'); break;
case 'topics': $sectiontitle = get_string('topic'); break;
default: $sectiontitle = get_string('section'); break;
}
$sectiontitle = get_string('sectionname', 'format_'.$COURSE->format);
$options = array(''=>get_string('allactivities'));
$modsused = array();
@@ -102,7 +99,7 @@ class recent_form extends moodleform {
}
foreach ($modinfo->sections as $section=>$cmids) {
$options["section/$section"] = "-- $sectiontitle $section --";
$options["section/$section"] = "-- ".get_section_name($COURSE, $sections[$section])." --";
foreach ($cmids as $cmid) {
$cm = $modinfo->cms[$cmid];
if (empty($modsused[$cm->modname]) or !$cm->uservisible) {
+3 -7
View File
@@ -60,6 +60,7 @@
}
$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
@@ -85,14 +86,9 @@
$sectioncell = new html_table_cell();
$sectioncell->colspan = count($outlinetable->head);
$sectiontitle = '';
switch ($course->format) {
case 'weeks': $sectiontitle = get_string('week'); break;
case 'topics': $sectiontitle = get_string('topic'); break;
default: $sectiontitle = get_string('section'); break;
}
$sectiontitle = get_section_name($course, $sections[$sectionnum]);
$sectioncell->text = $OUTPUT->heading($sectiontitle . ' ' . $sectionnum, 3);
$sectioncell->text = $OUTPUT->heading($sectiontitle, 3);
$sectionrow->cells[] = $sectioncell;
$outlinetable->data[] = $sectionrow;
+10 -10
View File
@@ -29,7 +29,7 @@ require_once("$CFG->libdir/resourcelib.php");
$id = required_param('id', PARAM_INT); // course id
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
$PAGE->set_pagelayout('course');
require_course_login($course, true);
// get list of all resource-like modules
@@ -52,8 +52,7 @@ foreach ($allmodules as $key=>$module) {
}
$strresources = get_string('resources');
$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');
@@ -65,6 +64,10 @@ $PAGE->navbar->add($strresources);
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) {
@@ -91,11 +94,8 @@ if (!$cms) {
$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);
@@ -108,11 +108,11 @@ foreach ($cms as $cm) {
continue;
}
$resource = $resources[$cm->modname][$cm->instance];
if ($course->format == 'weeks' or $course->format == 'topics') {
if ($usesections) {
$printsection = '';
if ($cm->sectionnum !== $currentsection) {
if ($cm->sectionnum) {
$printsection = $cm->sectionnum;
$printsection = get_section_name($course, $sections[$cm->sectionnum]);
}
if ($currentsection !== '') {
$table->data[] = 'hr';
+2 -6
View File
@@ -280,12 +280,8 @@ switch ($mode) {
if ($section->sequence) {
echo '<div class="section">';
echo '<h2>';
switch ($course->format) {
case "weeks": print_string("week"); break;
case "topics": print_string("topic"); break;
default: print_string("section"); break;
}
echo " $i</h2>";
echo get_section_name($course, $section);
echo "</h2>";
echo '<div class="content">';
+7 -7
View File
@@ -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'));
+18 -15
View File
@@ -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 = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
$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);
+2 -17
View File
@@ -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;
+11 -10
View File
@@ -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);
+19 -14
View File
@@ -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 = "<a href=\"view.php?id=$choice->coursemodule\">".format_string($choice->name,true)."</a>";
}
if ($course->format == "weeks" || $course->format == "topics") {
if ($usesections) {
$table->data[] = array ($printsection, $tt_href, $aa);
} else {
$table->data[] = array ($tt_href, $aa);
+10 -11
View File
@@ -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';
+11 -15
View File
@@ -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 = '<a '.$dimmedclass.' href="'.$viewurl->out().'">'.$feedback->name.'</a>';
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);
}
+10 -9
View File
@@ -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';
+4 -7
View File
@@ -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)) {
+7 -8
View File
@@ -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';
}
+19 -16
View File
@@ -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);
+10 -14
View File
@@ -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("'"=>"\'", '"'=>'&quot;');
@@ -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 '<H3>'.sprintf("%0.3f", microtime_diff($start, microtime())).' secs'."</H3>\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);
}
+10 -9
View File
@@ -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';
+10 -9
View File
@@ -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 = "<font color=\"red\">".userdate($lesson->deadline)."</font>";
}
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);
}
+10 -9
View File
@@ -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';
+3 -5
View File
@@ -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';
+10 -9
View File
@@ -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';
+11 -10
View File
@@ -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);
+21 -18
View File
@@ -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 = "<a href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</a>";
}
if ($course->format == "weeks" or $course->format == "topics") {
if ($usesections) {
$table->data[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
} else {
$table->data[] = array ($tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
+9 -9
View File
@@ -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';
+12 -11
View File
@@ -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 = "<a href=\"view.php?id=$wiki->coursemodule\">$wiki->name</a>";
}
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);
}
+11 -10
View File
@@ -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 = "<a href=\"view.php?id=$workshop->coursemodule\">$workshop->name</a>";
}
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);
}