]> git.mjollnir.org Git - moodle.git/commitdiff
Hide/show individual activities in any section
authormoodler <moodler>
Mon, 14 Apr 2003 15:11:09 +0000 (15:11 +0000)
committermoodler <moodler>
Mon, 14 Apr 2003 15:11:09 +0000 (15:11 +0000)
Code submitted by Eloy Lafuente (thanks!) for 1.0.8 ... I hand-merged it
into 1.0.9.

16 files changed:
course/lib.php
course/mod.php
lib/datalib.php
lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
pix/t/hide.gif [new file with mode: 0644]
pix/t/show.gif [new file with mode: 0644]
theme/standard/styles.php
theme/standardblue/styles.php
theme/standardgreen/styles.php
theme/standardlogo/styles.php
theme/standardred/styles.php
theme/standardwhite/styles.php
version.php

index 16688184761cc6cdefd46f137b82a6ce49c1db09..90bcf10c0bd9a8c6178806ec95fcdbf0d4557b7a 100644 (file)
@@ -467,7 +467,9 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname
         foreach($rawmods as $mod) {    // Index the mods
             $mods[$mod->id] = $mod;
             $mods[$mod->id]->modfullname = $modnames[$mod->modname];
-            $modnamesused[$mod->modname] = $modnames[$mod->modname];
+            if ($mod->visible or isteacher($courseid)) {
+                $modnamesused[$mod->modname] = $modnames[$mod->modname];
+            }
         }
         asort($modnamesused);
     }
@@ -498,11 +500,18 @@ function print_section_block($heading, $course, $section, $mods, $modnames, $mod
         foreach ($sectionmods as $modnumber) {
             $mod = $mods[$modnumber];
             if ($isediting) {
-                $editbuttons = make_editing_buttons($mod->id, $absolute);
+                $editbuttons = make_editing_buttons($mod->id, $absolute, $mod->visible);
+            }
+            if ($mod->visible or isteacher($course->id)) {
+                $instancename = urldecode($modinfo[$modnumber]->name);
+                if ($mod->visible) {
+                    $link_css = "";
+                } else {
+                    $link_css = " class=\"dimmed\" ";
+                }
+                $modicon[] = "<img src=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" height=\"16\" width=\"16\" alt=\"$mod->modfullname\">";
+                $moddata[] = "<a title=\"$mod->modfullname\" $link_css href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a><BR>$editbuttons";
             }
-            $instancename = urldecode($modinfo[$modnumber]->name);
-            $modicon[] = "<img src=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" height=\"16\" width=\"16\" alt=\"$mod->modfullname\">";
-            $moddata[] = "<a title=\"$mod->modfullname\" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a><BR>$editbuttons";
         }
     }
     if ($isediting) {
@@ -532,15 +541,24 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
                 continue;
             }
             $mod = $mods[$modnumber];
-            $instancename = urldecode($modinfo[$modnumber]->name);
-            echo "<IMG SRC=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
-            echo " <FONT SIZE=2><A TITLE=\"$mod->modfullname\"";
-            echo "   HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</A></FONT>";
+            if ($mod->visible or isteacher($course->id)) {
+                $instancename = urldecode($modinfo[$modnumber]->name);
+                if ($mod->visible) {
+                    $link_css = "";
+                } else {
+                    $link_css = " class=\"dimmed\" ";
+                }
+                echo "<IMG SRC=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
+                echo " <FONT SIZE=2><A TITLE=\"$mod->modfullname\" $link_css";
+                echo "   HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</A></FONT>";
+            }
             if (isediting($course->id)) {
                 echo "&nbsp;&nbsp;";
-                echo make_editing_buttons($mod->id, $absolute);
+                echo make_editing_buttons($mod->id, $absolute, $mod->visible);
+            }
+            if ($mod->visible or isteacher($course->id)) {
+                echo "<BR>\n";
             }
-            echo "<BR>\n";
         }
     }
     echo "</TD></TR></TABLE><BR>\n\n";
@@ -828,6 +846,14 @@ function add_mod_to_section($mod) {
     }
 }
 
+function hide_course_module($mod) {
+    return set_field("course_modules", "visible", 0, "id", $mod);
+}
+
+function show_course_module($mod) {
+    return set_field("course_modules", "visible", 1, "id", $mod);
+}
+
 function delete_course_module($mod) {
     return set_field("course_modules", "deleted", 1, "id", $mod);
 }
@@ -975,27 +1001,40 @@ function move_module($cm, $move) {
     }
 }
 
-function make_editing_buttons($moduleid, $absolute=false) {
+function make_editing_buttons($moduleid, $absolute=false, $visible=true, $str=NULL) {
     global $CFG;
 
-    $delete   = get_string("delete");
-    $moveup   = get_string("moveup");
-    $movedown = get_string("movedown");
-    $update   = get_string("update");
+    if (empty($str)) {
+        $str->delete   = get_string("delete");
+        $str->moveup   = get_string("moveup");
+        $str->movedown = get_string("movedown");
+        $str->update   = get_string("update");
+        $str->hide     = get_string("hide");
+        $str->show     = get_string("show");
+    }
 
     if ($absolute) {
         $path = "$CFG->wwwroot/course/";
     } else {
         $path = "";
     }
-    return "<A TITLE=\"$delete\" HREF=\"".$path."mod.php?delete=$moduleid\"><IMG 
+
+    if ($visible) {
+        $hideshow = " <A TITLE=\"$str->hide\" HREF=\"".$path."mod.php?hide=$moduleid\"><IMG 
+                        SRC=".$path."../pix/t/hide.gif BORDER=0></A>";
+    } else {
+        $hideshow = " <A TITLE=\"$str->show\" HREF=\"".$path."mod.php?show=$moduleid\"><IMG 
+                        SRC=".$path."../pix/t/show.gif BORDER=0></A>";
+    }
+
+    return "<A TITLE=\"$str->delete\" HREF=\"".$path."mod.php?delete=$moduleid\"><IMG 
              SRC=".$path."../pix/t/delete.gif BORDER=0></A>
-          <A TITLE=\"$moveup\" HREF=\"".$path."mod.php?id=$moduleid&move=-1\"><IMG 
+          <A TITLE=\"$str->moveup\" HREF=\"".$path."mod.php?id=$moduleid&move=-1\"><IMG 
              SRC=".$path."../pix/t/up.gif BORDER=0></A>
-          <A TITLE=\"$movedown\" HREF=\"".$path."mod.php?id=$moduleid&move=1\"><IMG 
+          <A TITLE=\"$str->movedown\" HREF=\"".$path."mod.php?id=$moduleid&move=1\"><IMG 
              SRC=".$path."../pix/t/down.gif BORDER=0></A>
-          <A TITLE=\"$update\" HREF=\"".$path."mod.php?update=$moduleid\"><IMG 
-             SRC=".$path."../pix/t/edit.gif BORDER=0></A>";
+          <A TITLE=\"$str->update\" HREF=\"".$path."mod.php?update=$moduleid\"><IMG 
+             SRC=".$path."../pix/t/edit.gif BORDER=0></A> $hideshow";
 }
 
 ?>
index 53535e5964ef21b73c723981d1bde59b9095a727..a482bf56178d23f7f9cbe0fff0adf1d565f17933 100644 (file)
         redirect($_SERVER["HTTP_REFERER"]);
         exit;
 
+    } else if (isset($hide)) {
+
+        if (! $cm = get_record("course_modules", "id", $hide)) {
+            error("This course module doesn't exist");
+        }
+   
+        hide_course_module($hide);
+
+        $modinfo = serialize(get_array_of_activities($cm->course));
+        if (!set_field("course", "modinfo", $modinfo, "id", $cm->course)) {
+            error("Could not cache module information!");
+        }
+
+        redirect($_SERVER["HTTP_REFERER"]);
+        exit;
+
+    } else if (isset($show)) {
+
+        if (! $cm = get_record("course_modules", "id", $show)) {
+            error("This course module doesn't exist");
+        }
+   
+        show_course_module($show);
+
+        $modinfo = serialize(get_array_of_activities($cm->course));
+        if (!set_field("course", "modinfo", $modinfo, "id", $cm->course)) {
+            error("Could not cache module information!");
+        }
+
+        redirect($_SERVER["HTTP_REFERER"]);
+        exit;
+
     } else if (isset($delete)) {   // value = course module
 
         if (! $cm = get_record("course_modules", "id", $delete)) {
index 73a544e7d5e5a2765320c723a9e5396e5c4a63d8..6a28bb7948052559e871f6d6b1150f46af9bfa03 100644 (file)
@@ -998,6 +998,13 @@ function get_all_instances_in_course($modulename, $courseid, $sort="cw.section")
 
     global $CFG;
 
+    // Hide non-visible instances from students
+    if (isteacher($courseid)) {
+        $showvisible = "";
+    } else {
+        $showvisible = "AND cm.visible = '1'";
+    }
+
     return get_records_sql("SELECT m.*,cw.section,cm.id as coursemodule 
                             FROM {$CFG->prefix}course_modules cm, {$CFG->prefix}course_sections cw, 
                                  {$CFG->prefix}modules md, {$CFG->prefix}$modulename m 
@@ -1006,7 +1013,7 @@ function get_all_instances_in_course($modulename, $courseid, $sort="cw.section")
                                   cm.deleted = '0' AND
                                   cm.section = cw.id AND 
                                   md.name = '$modulename' AND 
-                                  md.id = cm.module
+                                  md.id = cm.module $showvisible
                             ORDER BY $sort");
 
 }
index bb95cae201dc123abb716b92f09cdb9820b83d4f..6bf079213aa202212a09894745df4960a83475bc 100644 (file)
@@ -270,6 +270,10 @@ function main_upgrade($oldversion=0) {
         execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(course) ");
         execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(userid) ");
     }
+    
+       if ($oldversion < 2003041400) {
+        table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
+    }
 
     return true;
 }
index e725943eb7cf95ac4190dd0f9d823f32f9df57ee..eb4094ac83cbc3eeff166d447aed62998e2ad7bd 100644 (file)
@@ -77,6 +77,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',
+  `visible` tinyint(1) NOT NULL default '1',
   PRIMARY KEY  (`id`),
   UNIQUE KEY `id` (`id`)
 ) TYPE=MyISAM;
index e9a184f350bcc28711e5a8240195e9eef79397c1..b1d74d63c964ccf3dbff8aea3df2bf9d93b57e5a 100644 (file)
@@ -46,6 +46,10 @@ function main_upgrade($oldversion=0) {
                                   userid int8  NOT NULL default '0'
                                   )");
        }
+
+       if ($oldversion < 2003041400) {
+        table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
+    }
        
     return true;
 }
index 8dc0153f933c3977008c2a36735f00e099dab5eb..d840763526207bdaa364505edfce1b3af673b23b 100644 (file)
@@ -40,7 +40,8 @@ CREATE TABLE prefix_course_modules (
    section integer NOT NULL default '0',
    added integer NOT NULL default '0',
    deleted integer NOT NULL default '0',
-   score integer NOT NULL default '0'
+   score integer NOT NULL default '0',
+   visible integer NOT NULL default '1'
 );
 
 CREATE TABLE prefix_course_sections (
diff --git a/pix/t/hide.gif b/pix/t/hide.gif
new file mode 100644 (file)
index 0000000..f938a79
Binary files /dev/null and b/pix/t/hide.gif differ
diff --git a/pix/t/show.gif b/pix/t/show.gif
new file mode 100644 (file)
index 0000000..f506c7c
Binary files /dev/null and b/pix/t/show.gif differ
index d6ade57eaf8068fa775ee665cb7dbe0c45bcdd21..c8121d3164efedaff67987ef8676a5701a6cc6ac 100644 (file)
@@ -190,3 +190,18 @@ form {
 .feedbacktext {\r
     color: <?PHP echo $THEME->cellheading2?>;\r
 }\r
+\r
+a.dimmed:link {\r
+    text-decoration: none; \r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:visited {\r
+    text-decoration: none;\r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:hover {\r
+    text-decoration: underline;\r
+    color: red;\r
+}\r
index d6ade57eaf8068fa775ee665cb7dbe0c45bcdd21..c8121d3164efedaff67987ef8676a5701a6cc6ac 100644 (file)
@@ -190,3 +190,18 @@ form {
 .feedbacktext {\r
     color: <?PHP echo $THEME->cellheading2?>;\r
 }\r
+\r
+a.dimmed:link {\r
+    text-decoration: none; \r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:visited {\r
+    text-decoration: none;\r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:hover {\r
+    text-decoration: underline;\r
+    color: red;\r
+}\r
index d6ade57eaf8068fa775ee665cb7dbe0c45bcdd21..c8121d3164efedaff67987ef8676a5701a6cc6ac 100644 (file)
@@ -190,3 +190,18 @@ form {
 .feedbacktext {\r
     color: <?PHP echo $THEME->cellheading2?>;\r
 }\r
+\r
+a.dimmed:link {\r
+    text-decoration: none; \r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:visited {\r
+    text-decoration: none;\r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:hover {\r
+    text-decoration: underline;\r
+    color: red;\r
+}\r
index d6ade57eaf8068fa775ee665cb7dbe0c45bcdd21..c8121d3164efedaff67987ef8676a5701a6cc6ac 100644 (file)
@@ -190,3 +190,18 @@ form {
 .feedbacktext {\r
     color: <?PHP echo $THEME->cellheading2?>;\r
 }\r
+\r
+a.dimmed:link {\r
+    text-decoration: none; \r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:visited {\r
+    text-decoration: none;\r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:hover {\r
+    text-decoration: underline;\r
+    color: red;\r
+}\r
index d6ade57eaf8068fa775ee665cb7dbe0c45bcdd21..c8121d3164efedaff67987ef8676a5701a6cc6ac 100644 (file)
@@ -190,3 +190,18 @@ form {
 .feedbacktext {\r
     color: <?PHP echo $THEME->cellheading2?>;\r
 }\r
+\r
+a.dimmed:link {\r
+    text-decoration: none; \r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:visited {\r
+    text-decoration: none;\r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:hover {\r
+    text-decoration: underline;\r
+    color: red;\r
+}\r
index d6ade57eaf8068fa775ee665cb7dbe0c45bcdd21..c8121d3164efedaff67987ef8676a5701a6cc6ac 100644 (file)
@@ -190,3 +190,18 @@ form {
 .feedbacktext {\r
     color: <?PHP echo $THEME->cellheading2?>;\r
 }\r
+\r
+a.dimmed:link {\r
+    text-decoration: none; \r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:visited {\r
+    text-decoration: none;\r
+    color: #AAAAAA;\r
+}\r
+\r
+a.dimmed:hover {\r
+    text-decoration: underline;\r
+    color: red;\r
+}\r
index 5a8a937a35c86ac45cef5131ebc968aee8537d6e..ccd8d56818097a62d152b948b5318a5e53ea12b8 100644 (file)
@@ -5,7 +5,7 @@
 // database to determine whether upgrades should
 // be performed (see lib/db/*.php)
 
-$version = 2003041200;   // The current version is a date (YYYYMMDDXX)
+$version = 2003041400;   // The current version is a date (YYYYMMDDXX)
 
 $release = "1.0.9 development";  // User-friendly version number