/// MODULE FUNCTIONS /////////////////////////////////////////////////////////////////
function add_course_module($mod) {
- GLOBAL $db;
$mod->added = time();
}
function delete_mod_from_section($mod, $section) {
- GLOBAL $db;
if ($section = get_record("course_sections", "id", "$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;
"<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§ion=$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§ion=$section&move=1\" title=\"$strtopicdown\">".
+ "<img src=\"$pixpath/i/down.gif\" vspace=3 height=11 width=11 border=0></a><br />";
+ }
+
}
echo "</td>";
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";
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§ion=$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§ion=$section&move=1\" title=\"$strtopicdown\">".
+ "<img src=\"$pixpath/t/down.gif\" vspace=3 height=11 width=11 border=0></a><br />";
+ }
+
}
echo "</td>";