Hide/show individual activities in any section
Code submitted by Eloy Lafuente (thanks!) for 1.0.8 ... I hand-merged it into 1.0.9.
This commit is contained in:
+60
-21
@@ -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 " ";
|
||||
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";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
+8
-1
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 74 B |
Binary file not shown.
|
After Width: | Height: | Size: 66 B |
@@ -190,3 +190,18 @@ form {
|
||||
.feedbacktext {
|
||||
color: <?PHP echo $THEME->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;
|
||||
}
|
||||
|
||||
@@ -190,3 +190,18 @@ form {
|
||||
.feedbacktext {
|
||||
color: <?PHP echo $THEME->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;
|
||||
}
|
||||
|
||||
@@ -190,3 +190,18 @@ form {
|
||||
.feedbacktext {
|
||||
color: <?PHP echo $THEME->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;
|
||||
}
|
||||
|
||||
@@ -190,3 +190,18 @@ form {
|
||||
.feedbacktext {
|
||||
color: <?PHP echo $THEME->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;
|
||||
}
|
||||
|
||||
@@ -190,3 +190,18 @@ form {
|
||||
.feedbacktext {
|
||||
color: <?PHP echo $THEME->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;
|
||||
}
|
||||
|
||||
@@ -190,3 +190,18 @@ form {
|
||||
.feedbacktext {
|
||||
color: <?PHP echo $THEME->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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user