// Only in the non-general sections.
if (!$section->visible) {
$sectionstyle = ' hidden';
- } else if ($course->marker == $section->section) {
+ } else if ($this->is_section_current($section, $course)) {
$sectionstyle = ' current';
}
- $linktitle = ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE);
}
$o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
M.course.format.swap_sections = function(Y, node1, node2) {
var CSS = {
COURSECONTENT : 'course-content',
- LEFT : 'left',
- SECTIONADDMENUS : 'section_add_menus'
+ SECTIONADDMENUS : 'section_add_menus',
- WEEKDATES: 'sectionname'
};
var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y));
return $ajaxsupport;
}
+/**
+ * Return the start and end date of the passed section
+ *
+ * @param stdClass $section The course_section entry from the DB
+ * @param stdClass $course The course entry from DB
+ * @return stdClass property start for startdate, property end for enddate
+ */
+function format_weeks_get_section_dates($section, $course) {
+ $oneweekseconds = 604800;
+ // Hack alert. We add 2 hours to avoid possible DST problems. (e.g. we go into daylight
+ // savings and the date changes.
+ $startdate = $course->startdate + 7200;
+
+ $dates = new stdClass();
+ $dates->start = $startdate + ($oneweekseconds * ($section->section - 1));
+ $dates->end = $dates->start + $oneweekseconds;
+
+ return $dates;
+}
++
+ /**
+ * Callback function to do some action after section move
+ *
+ * @param stdClass $course The course entry from DB
+ * @return array This will be passed in ajax respose.
+ */
+ function callback_weeks_ajax_section_move($course) {
+ global $COURSE, $PAGE;
+
+ $titles = array();
+ rebuild_course_cache($course->id);
+ $modinfo = get_fast_modinfo($COURSE);
+ $renderer = $PAGE->get_renderer('format_weeks');
+ if ($renderer && ($sections = $modinfo->get_section_info_all())) {
+ foreach ($sections as $number => $section) {
+ $titles[$number] = $renderer->section_title($section, $course);
+ }
+ }
+ return array('sectiontitles' => $titles, 'action' => 'move');
+ }