Merge branch 'MDL-32824-master-2' of git://git.luns.net.uk/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 29 May 2012 07:21:55 +0000 (15:21 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 29 May 2012 07:21:55 +0000 (15:21 +0800)
Conflicts:
course/format/weeks/format.js
course/format/weeks/lib.php

1  2 
course/format/renderer.php
course/format/weeks/format.js
course/format/weeks/lib.php
course/yui/dragdrop/dragdrop.js

@@@ -121,10 -135,9 +135,9 @@@ abstract class format_section_renderer_
              // 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,
@@@ -36,9 -36,7 +36,7 @@@ M.course.format.get_config = function(
  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));
@@@ -98,22 -103,23 +98,43 @@@ function callback_weeks_ajax_support() 
      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');
+ }
Simple merge