diff --git a/course/lib.php b/course/lib.php
index 16688184761..90bcf10c0bd 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -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[] = "
wwwroot/mod/$mod->modname/icon.gif\" height=\"16\" width=\"16\" alt=\"$mod->modfullname\">";
+ $moddata[] = "modfullname\" $link_css href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename
$editbuttons";
}
- $instancename = urldecode($modinfo[$modnumber]->name);
- $modicon[] = "
wwwroot/mod/$mod->modname/icon.gif\" height=\"16\" width=\"16\" alt=\"$mod->modfullname\">";
- $moddata[] = "modfullname\" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename
$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 "
wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
- echo " modfullname\"";
- echo " HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename";
+ if ($mod->visible or isteacher($course->id)) {
+ $instancename = urldecode($modinfo[$modnumber]->name);
+ if ($mod->visible) {
+ $link_css = "";
+ } else {
+ $link_css = " class=\"dimmed\" ";
+ }
+ echo "
wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
+ echo " modfullname\" $link_css";
+ echo " HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename";
+ }
if (isediting($course->id)) {
echo " ";
- echo make_editing_buttons($mod->id, $absolute);
+ echo make_editing_buttons($mod->id, $absolute, $mod->visible);
+ }
+ if ($mod->visible or isteacher($course->id)) {
+ echo "
\n";
}
- echo "
\n";
}
}
echo "
\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 "
hide\" HREF=\"".$path."mod.php?hide=$moduleid\">
";
+ } else {
+ $hideshow = " show\" HREF=\"".$path."mod.php?show=$moduleid\">
";
+ }
+
+ return "delete\" HREF=\"".$path."mod.php?delete=$moduleid\">
-
moveup\" HREF=\"".$path."mod.php?id=$moduleid&move=-1\">
-
movedown\" HREF=\"".$path."mod.php?id=$moduleid&move=1\">
-
";
+ update\" HREF=\"".$path."mod.php?update=$moduleid\">
$hideshow";
}
?>
diff --git a/course/mod.php b/course/mod.php
index 53535e5964e..a482bf56178 100644
--- a/course/mod.php
+++ b/course/mod.php
@@ -118,6 +118,38 @@
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)) {
diff --git a/lib/datalib.php b/lib/datalib.php
index 73a544e7d5e..6a28bb79480 100644
--- a/lib/datalib.php
+++ b/lib/datalib.php
@@ -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");
}
diff --git a/lib/db/mysql.php b/lib/db/mysql.php
index bb95cae201d..6bf079213aa 100644
--- a/lib/db/mysql.php
+++ b/lib/db/mysql.php
@@ -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;
}
diff --git a/lib/db/mysql.sql b/lib/db/mysql.sql
index e725943eb7c..eb4094ac83c 100644
--- a/lib/db/mysql.sql
+++ b/lib/db/mysql.sql
@@ -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;
diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php
index e9a184f350b..b1d74d63c96 100644
--- a/lib/db/postgres7.php
+++ b/lib/db/postgres7.php
@@ -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;
}
diff --git a/lib/db/postgres7.sql b/lib/db/postgres7.sql
index 8dc0153f933..d8407635262 100644
--- a/lib/db/postgres7.sql
+++ b/lib/db/postgres7.sql
@@ -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
index 00000000000..f938a798f88
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
index 00000000000..f506c7c0a48
Binary files /dev/null and b/pix/t/show.gif differ
diff --git a/theme/standard/styles.php b/theme/standard/styles.php
index d6ade57eaf8..c8121d3164e 100644
--- a/theme/standard/styles.php
+++ b/theme/standard/styles.php
@@ -190,3 +190,18 @@ form {
.feedbacktext {
color: cellheading2?>;
}
+
+a.dimmed:link {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:visited {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:hover {
+ text-decoration: underline;
+ color: red;
+}
diff --git a/theme/standardblue/styles.php b/theme/standardblue/styles.php
index d6ade57eaf8..c8121d3164e 100644
--- a/theme/standardblue/styles.php
+++ b/theme/standardblue/styles.php
@@ -190,3 +190,18 @@ form {
.feedbacktext {
color: cellheading2?>;
}
+
+a.dimmed:link {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:visited {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:hover {
+ text-decoration: underline;
+ color: red;
+}
diff --git a/theme/standardgreen/styles.php b/theme/standardgreen/styles.php
index d6ade57eaf8..c8121d3164e 100644
--- a/theme/standardgreen/styles.php
+++ b/theme/standardgreen/styles.php
@@ -190,3 +190,18 @@ form {
.feedbacktext {
color: cellheading2?>;
}
+
+a.dimmed:link {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:visited {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:hover {
+ text-decoration: underline;
+ color: red;
+}
diff --git a/theme/standardlogo/styles.php b/theme/standardlogo/styles.php
index d6ade57eaf8..c8121d3164e 100644
--- a/theme/standardlogo/styles.php
+++ b/theme/standardlogo/styles.php
@@ -190,3 +190,18 @@ form {
.feedbacktext {
color: cellheading2?>;
}
+
+a.dimmed:link {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:visited {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:hover {
+ text-decoration: underline;
+ color: red;
+}
diff --git a/theme/standardred/styles.php b/theme/standardred/styles.php
index d6ade57eaf8..c8121d3164e 100644
--- a/theme/standardred/styles.php
+++ b/theme/standardred/styles.php
@@ -190,3 +190,18 @@ form {
.feedbacktext {
color: cellheading2?>;
}
+
+a.dimmed:link {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:visited {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:hover {
+ text-decoration: underline;
+ color: red;
+}
diff --git a/theme/standardwhite/styles.php b/theme/standardwhite/styles.php
index d6ade57eaf8..c8121d3164e 100644
--- a/theme/standardwhite/styles.php
+++ b/theme/standardwhite/styles.php
@@ -190,3 +190,18 @@ form {
.feedbacktext {
color: cellheading2?>;
}
+
+a.dimmed:link {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:visited {
+ text-decoration: none;
+ color: #AAAAAA;
+}
+
+a.dimmed:hover {
+ text-decoration: underline;
+ color: red;
+}
diff --git a/version.php b/version.php
index 5a8a937a35c..ccd8d568180 100644
--- a/version.php
+++ b/version.php
@@ -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