Sections can now be moved up and down

This commit is contained in:
moodler
2003-06-10 15:27:09 +00:00
parent 0aefd39fd4
commit 12905134ab
4 changed files with 62 additions and 3 deletions
+35 -3
View 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;
+10
View File
@@ -223,6 +223,16 @@
"<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>";
+6
View File
@@ -42,6 +42,12 @@
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";
+11
View File
@@ -215,6 +215,17 @@
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>";