]> git.mjollnir.org Git - moodle.git/commitdiff
Sections can now be moved up and down
authormoodler <moodler>
Tue, 10 Jun 2003 15:27:09 +0000 (15:27 +0000)
committermoodler <moodler>
Tue, 10 Jun 2003 15:27:09 +0000 (15:27 +0000)
course/lib.php
course/topics.php
course/view.php
course/weeks.php

index 4a2e2d4940cac359a70e7560035cf67f04ff72da..131282982c0b975ca151ceb91ce8111eab1409d5 100644 (file)
@@ -929,7 +929,6 @@ function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
 /// MODULE FUNCTIONS /////////////////////////////////////////////////////////////////
 
 function add_course_module($mod) {
-    GLOBAL $db;
 
     $mod->added = time();
 
@@ -974,7 +973,6 @@ function delete_course_module($mod) {
 }
 
 function delete_mod_from_section($mod, $section) {
-    GLOBAL $db;
 
     if ($section = get_record("course_sections", "id", "$section") ) {
 
@@ -993,9 +991,43 @@ function delete_mod_from_section($mod, $section) {
     }
 }
 
+function move_section($course, $section, $move) {
+/// Moves a whole course section up and down within the course
+
+    if (!$move) {
+        return true;
+    }
+
+    $sectiondest = $section + $move;
+
+    if ($sectiondest > $course->numsections or $sectiondest < 1) {
+        return false;
+    }
+
+    if (!$sectionrecord = get_record("course_sections", "course", $course->id, "section", $section)) {
+        return false;
+    }
+
+    if (!$sectiondestrecord = get_record("course_sections", "course", $course->id, "section", $sectiondest)) {
+        return false;
+    }
+
+    $sectionrecord->section = $sectiondest;
+    $sectiondestrecord->section = $section;
+
+    if (!update_record("course_sections", $sectionrecord)) {
+        return false;
+    }
+    if (!update_record("course_sections", $sectiondestrecord)) {
+        return false;
+    }
+    return true;
+}
+
+
 
 function move_module($cm, $move) {
-    GLOBAL $db;
+/// Moves an activity module up and down within the course
 
     if (!$move) {
         return true;
index fb739a163c7f63456e674e003ad247328c8b5f84..a9c9994cb4538fe7a2affe2ed62cb132c88285d8 100644 (file)
                      "<img src=\"$pixpath/i/show.gif\" vspace=3 height=16 width=16 border=0></a><br />";
             }
 
+            if ($section > 1) {                       // Add a arrow to move section up
+                echo "<a href=\"view.php?id=$course->id&section=$section&move=-1\" title=\"$strtopicup\">".
+                     "<img src=\"$pixpath/i/up.gif\" vspace=3 height=11 width=11 border=0></a><br />";
+            }
+
+            if ($section < $course->numsections) {    // Add a arrow to move section down
+                echo "<a href=\"view.php?id=$course->id&section=$section&move=1\" title=\"$strtopicdown\">".
+                     "<img src=\"$pixpath/i/down.gif\" vspace=3 height=11 width=11 border=0></a><br />";
+            }
+
         }
 
         echo "</td>";
index 35a0c34216006660d9334c85eb523df9cf00a18a..c4b78f6fa9d7fda81b08a3b1670c9bddf0143bdf 100644 (file)
         if (isset($show)) {
             set_section_visible($course->id, $show, "1");
         }
+
+        if (!empty($section)) {
+            if (!empty($move)) {
+                move_section($course, $section, $move);
+            }
+        }
     }
 
     $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
index daabd6c80ff566841cd6ecf2eaeb95980df234d3..ba60deb6e5fe440d9f57d5e638eb597b71cce6bb 100644 (file)
                 echo "<a href=\"view.php?id=$course->id&show=$section\" title=\"$strweekshow\">".
                      "<img src=\"$pixpath/i/show.gif\" vspace=3 height=16 width=16 border=0></a><br />";
             }
+
+            if ($section > 1) {                       // Add a arrow to move section up
+                echo "<a href=\"view.php?id=$course->id&section=$section&move=-1\" title=\"$strtopicup\">".
+                     "<img src=\"$pixpath/t/up.gif\" vspace=3 height=11 width=11 border=0></a><br />";
+            }
+
+            if ($section < $course->numsections) {    // Add a arrow to move section down
+                echo "<a href=\"view.php?id=$course->id&section=$section&move=1\" title=\"$strtopicdown\">".
+                     "<img src=\"$pixpath/t/down.gif\" vspace=3 height=11 width=11 border=0></a><br />";
+            }
+
         }
 
         echo "</td>";