]> git.mjollnir.org Git - moodle.git/commitdiff
New field on course_modules called "indent" ... this is an integer
authormoodler <moodler>
Sun, 14 Sep 2003 16:31:33 +0000 (16:31 +0000)
committermoodler <moodler>
Sun, 14 Sep 2003 16:31:33 +0000 (16:31 +0000)
that tells us how far to indent the activity when it is displayed.

This gives us some more flexibility on the course outline to
arrange things as we might like them, into subtopics etc

Backup/restore is updated as well.

There is also a bit more robustness in course/mod.php

backup/backuplib.php
backup/restorelib.php
course/lib.php
course/mod.php
lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
version.php

index ba6ce1bbf8a16f035e8cbd470a16d6abf508be06..aa80ff6f483edbcfa368eabd9fe3699c9cc35288 100644 (file)
                fwrite ($bf,full_tag("ADDED",6,false,$course_module[$tok]->added));
                fwrite ($bf,full_tag("DELETED",6,false,$course_module[$tok]->deleted));
                fwrite ($bf,full_tag("SCORE",6,false,$course_module[$tok]->score));
+               fwrite ($bf,full_tag("INDENT",6,false,$course_module[$tok]->indent));
                fwrite ($bf,full_tag("VISIBLE",6,false,$course_module[$tok]->visible));
                fwrite ($bf,end_tag("MOD",5,true));
             }
index 1d20d2b481f5b620aac99a8f000dc36dd10048ae..bcd6c973ac8a4d9b85f328b3fa224e686d3f6bff 100644 (file)
                                     $course_module->added = $mod->added;
                                     $course_module->deleted = $mod->deleted;
                                     $course_module->score = $mod->score;
+                                    $course_module->indent = $mod->indent;
                                     $course_module->visible = $mod->visible;
                                     $course_module->instance = null;
                                     //NOTE: The instance (new) is calculated and updated in db in the
                                 $this->info->tempmod->deleted;
                             $this->info->tempsection->mods[$this->info->tempmod->id]->score = 
                                 $this->info->tempmod->score;
+                            $this->info->tempsection->mods[$this->info->tempmod->id]->indent = 
+                                $this->info->tempmod->indent;
                             $this->info->tempsection->mods[$this->info->tempmod->id]->visible = 
                                 $this->info->tempmod->visible;
                             unset($this->info->tempmod);
                         case "SCORE":
                             $this->info->tempmod->score = $this->getContents();
                             break;
+                        case "INDENT":
+                            $this->info->tempmod->indent = $this->getContents();
+                            break;
                         case "VISIBLE":
                             $this->info->tempmod->visible = $this->getContents();
                             break;
index d476ace0614ef10ab6acf3c41f2e833c7b28cfa0..3af0aa7bdf6409922aef52f85250b30f075e1679 100644 (file)
@@ -637,8 +637,18 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
                     $extra = "";
                 }
 
+                if ($mod->indent) {
+                    print_spacer(12, 20 * $mod->indent, false);
+                }
+
                 if ($mod->modname == "label") {
+                    if (!$mod->visible) {
+                        echo "<span class=\"dimmed_text\">";
+                    }
                     echo format_text($extra, FORMAT_HTML);
+                    if (!$mod->visible) {
+                        echo "</span>";
+                    }
 
                 } else { // Normal activity
                     $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
@@ -650,7 +660,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
                 echo "</td>";
                 if ($isediting) {
                     echo "<td align=\"right\" valign=\"top\" nowrap=\"nowrap\" class=\"activityeditbuttons\">";
-                    echo make_editing_buttons($mod->id, $absolute, $mod->visible);
+                    echo make_editing_buttons($mod->id, $absolute, $mod->visible, true, $mod->indent);
                     echo " </td>";
                 }
                 echo "</tr>";
@@ -1508,7 +1518,7 @@ function move_module($cm, $move) {
     }
 }
 
-function make_editing_buttons($moduleid, $absolute=false, $visible=true, $moveselect=true) {
+function make_editing_buttons($moduleid, $absolute=false, $visible=true, $moveselect=true, $indent=-1) {
     global $CFG, $THEME;
 
     static $str = '';
@@ -1517,6 +1527,8 @@ function make_editing_buttons($moduleid, $absolute=false, $visible=true, $movese
         $str->move     = get_string("move");
         $str->moveup   = get_string("moveup");
         $str->movedown = get_string("movedown");
+        $str->moveright   = get_string("moveright");
+        $str->moveleft = get_string("moveleft");
         $str->update   = get_string("update");
         $str->hide     = get_string("hide");
         $str->show     = get_string("show");
@@ -1552,7 +1564,17 @@ function make_editing_buttons($moduleid, $absolute=false, $visible=true, $movese
                     " src=\"$pixpath/t/down.gif\" height=11 width=11 border=0></a> ";
     }
 
-    return "<a title=\"$str->delete\" href=\"$path/mod.php?delete=$moduleid\"><img".
+    $leftright = "";
+    if ($indent > 0) {
+        $leftright .= "<a title=\"$str->moveleft\" href=\"$path/mod.php?id=$moduleid&indent=-1\"><img".
+                      " src=\"$pixpath/t/left.gif\" height=11 width=11 border=0></a> ";
+    }
+    if ($indent >= 0) {
+        $leftright .= "<a title=\"$str->moveright\" href=\"$path/mod.php?id=$moduleid&indent=1\"><img".
+                      " src=\"$pixpath/t/right.gif\" height=11 width=11 border=0></a> ";
+    }
+
+    return "$leftright<a title=\"$str->delete\" href=\"$path/mod.php?delete=$moduleid\"><img".
            " src=\"$pixpath/t/delete.gif\" height=11 width=11 border=0></a> $move".
            "<a title=\"$str->update\" href=\"$path/mod.php?update=$moduleid\"><img".
            " src=\"$pixpath/t/edit.gif\" height=11 width=11 border=0></a> $hideshow";
index 73d4a331d559bae0fbd168fb31bd6259586b51c6..86a0da95288f004e7f78b88870c524024cf898b8 100644 (file)
     }
 
 
-    if (isset($move)) {  
+    if (isset($_GET['move'])) {  
 
         require_variable($id);   
 
             error("You can't modify this course!");
         }
     
-        move_module($cm, $move);
+        move_module($cm, $_GET['move']);
 
         rebuild_course_cache($cm->course);
 
         }
         exit;
 
-    } else if (isset($movetosection) or isset($moveto)) {  
+    } else if (isset($_GET['movetosection']) or isset($_GET['moveto'])) {  
         
         if (! $cm = get_record("course_modules", "id", $USER->activitycopy)) {
             error("The copied course module doesn't exist!");
         }
 
-        if (isset($movetosection)) {
-            if (! $section = get_record("course_sections", "id", $movetosection)) {
+        if (isset($_GET['movetosection'])) {
+            if (! $section = get_record("course_sections", "id", $_GET['movetosection'])) {
                 error("This section doesn't exist");
             }
             $beforecm = NULL;
 
         } else {                      // normal moveto
-            if (! $beforecm = get_record("course_modules", "id", $moveto)) {
+            if (! $beforecm = get_record("course_modules", "id", $_GET['moveto'])) {
                 error("The destination course module doesn't exist");
             }
             if (! $section = get_record("course_sections", "id", $beforecm->section)) {
             redirect("view.php?id=$section->course");
         }
 
-    } else if (isset($hide)) {
+    } else if (isset($_GET['indent'])) {  
 
-        if (! $cm = get_record("course_modules", "id", $hide)) {
+        require_variable($id);   
+
+        if (! $cm = get_record("course_modules", "id", $id)) {
+            error("This course module doesn't exist");
+        }
+
+        $cm->indent += $_GET['indent'];
+
+        if ($cm->indent < 0) {
+            $cm->indent = 0;
+        }
+
+        if (!set_field("course_modules", "indent", $cm->indent, "id", $cm->id)) {
+            error("Could not update the indent level on that course module");
+        }
+
+        $site = get_site();
+        if ($site->id == $cm->course) {
+            redirect($CFG->wwwroot);
+        } else {
+            redirect("view.php?id=$cm->course");
+        }
+        exit;
+
+    } else if (isset($_GET['hide'])) {
+
+        if (! $cm = get_record("course_modules", "id", $_GET['hide'])) {
             error("This course module doesn't exist");
         }
 
         }
         exit;
 
-    } else if (isset($show)) {
+    } else if (isset($_GET['show'])) {
 
-        if (! $cm = get_record("course_modules", "id", $show)) {
+        if (! $cm = get_record("course_modules", "id", $_GET['show'])) {
             error("This course module doesn't exist");
         }
 
         }
         exit;
 
-    } else if (isset($copy)) { // value = course module
+    } else if (isset($_GET['copy'])) { // value = course module
 
-        if (! $cm = get_record("course_modules", "id", $copy)) {
+        if (! $cm = get_record("course_modules", "id", $_GET['copy'])) {
             error("This course module doesn't exist");
         }
 
 
         redirect("view.php?id=$cm->course");
 
-    } else if (isset($cancelcopy)) { // value = course module
+    } else if (isset($_GET['cancelcopy'])) { // value = course module
 
         $courseid = $USER->activitycopycourse;
 
 
         redirect("view.php?id=$courseid");
 
-    } else if (isset($delete)) {   // value = course module
+    } else if (isset($_GET['delete'])) {   // value = course module
 
-        if (! $cm = get_record("course_modules", "id", $delete)) {
+        if (! $cm = get_record("course_modules", "id", $_GET['delete'])) {
             error("This course module doesn't exist");
         }
 
                   "$CFG->wwwroot/course/view.php?id=$course->id");
         }
 
-        $fullmodulename = strtolower(get_string("modulename", $module->name));
+        $fullmodulename = get_string("modulename", $module->name);
 
         $form->coursemodule = $cm->id;
         $form->section      = $cm->section;
         exit;
 
 
-    } else if (isset($update)) {   // value = course module
+    } else if (isset($_GET['update'])) {   // value = course module
 
-        if (! $cm = get_record("course_modules", "id", $update)) {
+        if (! $cm = get_record("course_modules", "id", $_GET['update'])) {
             error("This course module doesn't exist");
         }
 
         }
 
         
-    } else if (isset($add)) {
+    } else if (isset($_GET['add'])) {
 
-        if (!$add) {
+        if (empty($_GET['add'])) {
             redirect($_SERVER["HTTP_REFERER"]);
             die;
         }
             error("This course doesn't exist");
         }
 
-        if (! $module = get_record("modules", "name", $add)) {
+        if (! $module = get_record("modules", "name", $_GET['add'])) {
             error("This module type doesn't exist");
         }
 
index 71a209820c0353c18d1e837933f3c48b33ac3d10..d5b6ef09180914b2e14403793ab76921f43a3381 100644 (file)
@@ -501,6 +501,10 @@ function main_upgrade($oldversion=0) {
         execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'user report', 'user', 'CONCAT(firstname,\" \",lastname)') ");
     }
 
+    if ($oldversion < 2003091400) {
+        table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score");
+    }
+
     return $result;
 
 }
index dd3e025eb70e586007a2664feb4d3b4ed4c00e60..9b8b2a9b3b419db8c6f69c97e819c0a40caabe9e 100644 (file)
@@ -104,6 +104,7 @@ CREATE TABLE `prefix_course_modules` (
   `added` int(10) unsigned NOT NULL default '0',
   `deleted` tinyint(1) unsigned NOT NULL default '0',
   `score` tinyint(4) NOT NULL default '0',
+  `indent` int(5) unsigned NOT NULL default '0',
   `visible` tinyint(1) NOT NULL default '1',
   PRIMARY KEY  (`id`),
   UNIQUE KEY `id` (`id`)
index e4ce8369257b7472044d780ba7b9e816342e7301..89e6a89a030bcc234cef958ce4490042c82d467e 100644 (file)
@@ -250,6 +250,11 @@ function main_upgrade($oldversion=0) {
         table_column("course", "", "showrecent", "integer", "10", "unsigned", "1", "", "numsections");
     }
 
+    if ($oldversion < 2003091400) {
+        table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score");
+    }
+
+
     return $result;
 }
 ?>    
index dee9e0793ad0c58b42c46967ba2c6a3a51646ecc..5e4fe2d3217745c1543bc74e4f046816bf849288 100644 (file)
@@ -62,6 +62,7 @@ CREATE TABLE prefix_course_modules (
    added integer NOT NULL default '0',
    deleted integer NOT NULL default '0',
    score integer NOT NULL default '0',
+   indent integer NOT NULL default '0',
    visible integer NOT NULL default '1'
 );
 
index d5c1f71c14253c297096d761871afddf195c43e4..3049095b820608931f18ac54e31a33cbd509ef70 100644 (file)
@@ -5,7 +5,7 @@
 // database to determine whether upgrades should
 // be performed (see lib/db/*.php)
 
-$version = 2003091111;   // The current version is a date (YYYYMMDDXX)
+$version = 2003091400;   // The current version is a date (YYYYMMDDXX)
 
 $release = "1.2 development";   // User-friendly version number