New field on course_modules called "indent" ... this is an integer

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
This commit is contained in:
moodler 2003-09-14 16:31:33 +00:00
parent 2b9f062552
commit aac94fd0cc
9 changed files with 91 additions and 25 deletions

View file

@ -530,6 +530,7 @@
fwrite ($bf,full_tag("ADDED",6,false,$course_module[$tok]->added)); 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("DELETED",6,false,$course_module[$tok]->deleted));
fwrite ($bf,full_tag("SCORE",6,false,$course_module[$tok]->score)); 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,full_tag("VISIBLE",6,false,$course_module[$tok]->visible));
fwrite ($bf,end_tag("MOD",5,true)); fwrite ($bf,end_tag("MOD",5,true));
} }

View file

@ -394,6 +394,7 @@
$course_module->added = $mod->added; $course_module->added = $mod->added;
$course_module->deleted = $mod->deleted; $course_module->deleted = $mod->deleted;
$course_module->score = $mod->score; $course_module->score = $mod->score;
$course_module->indent = $mod->indent;
$course_module->visible = $mod->visible; $course_module->visible = $mod->visible;
$course_module->instance = null; $course_module->instance = null;
//NOTE: The instance (new) is calculated and updated in db in the //NOTE: The instance (new) is calculated and updated in db in the
@ -1320,6 +1321,8 @@
$this->info->tempmod->deleted; $this->info->tempmod->deleted;
$this->info->tempsection->mods[$this->info->tempmod->id]->score = $this->info->tempsection->mods[$this->info->tempmod->id]->score =
$this->info->tempmod->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->tempsection->mods[$this->info->tempmod->id]->visible =
$this->info->tempmod->visible; $this->info->tempmod->visible;
unset($this->info->tempmod); unset($this->info->tempmod);
@ -1345,6 +1348,9 @@
case "SCORE": case "SCORE":
$this->info->tempmod->score = $this->getContents(); $this->info->tempmod->score = $this->getContents();
break; break;
case "INDENT":
$this->info->tempmod->indent = $this->getContents();
break;
case "VISIBLE": case "VISIBLE":
$this->info->tempmod->visible = $this->getContents(); $this->info->tempmod->visible = $this->getContents();
break; break;

View file

@ -637,8 +637,18 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
$extra = ""; $extra = "";
} }
if ($mod->indent) {
print_spacer(12, 20 * $mod->indent, false);
}
if ($mod->modname == "label") { if ($mod->modname == "label") {
if (!$mod->visible) {
echo "<span class=\"dimmed_text\">";
}
echo format_text($extra, FORMAT_HTML); echo format_text($extra, FORMAT_HTML);
if (!$mod->visible) {
echo "</span>";
}
} else { // Normal activity } else { // Normal activity
$linkcss = $mod->visible ? "" : " class=\"dimmed\" "; $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
@ -650,7 +660,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
echo "</td>"; echo "</td>";
if ($isediting) { if ($isediting) {
echo "<td align=\"right\" valign=\"top\" nowrap=\"nowrap\" class=\"activityeditbuttons\">"; 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 " </td>";
} }
echo "</tr>"; 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; global $CFG, $THEME;
static $str = ''; static $str = '';
@ -1517,6 +1527,8 @@ function make_editing_buttons($moduleid, $absolute=false, $visible=true, $movese
$str->move = get_string("move"); $str->move = get_string("move");
$str->moveup = get_string("moveup"); $str->moveup = get_string("moveup");
$str->movedown = get_string("movedown"); $str->movedown = get_string("movedown");
$str->moveright = get_string("moveright");
$str->moveleft = get_string("moveleft");
$str->update = get_string("update"); $str->update = get_string("update");
$str->hide = get_string("hide"); $str->hide = get_string("hide");
$str->show = get_string("show"); $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> "; " 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". " src=\"$pixpath/t/delete.gif\" height=11 width=11 border=0></a> $move".
"<a title=\"$str->update\" href=\"$path/mod.php?update=$moduleid\"><img". "<a title=\"$str->update\" href=\"$path/mod.php?update=$moduleid\"><img".
" src=\"$pixpath/t/edit.gif\" height=11 width=11 border=0></a> $hideshow"; " src=\"$pixpath/t/edit.gif\" height=11 width=11 border=0></a> $hideshow";

View file

@ -103,7 +103,7 @@
} }
if (isset($move)) { if (isset($_GET['move'])) {
require_variable($id); require_variable($id);
@ -115,7 +115,7 @@
error("You can't modify this course!"); error("You can't modify this course!");
} }
move_module($cm, $move); move_module($cm, $_GET['move']);
rebuild_course_cache($cm->course); rebuild_course_cache($cm->course);
@ -127,20 +127,20 @@
} }
exit; 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)) { if (! $cm = get_record("course_modules", "id", $USER->activitycopy)) {
error("The copied course module doesn't exist!"); error("The copied course module doesn't exist!");
} }
if (isset($movetosection)) { if (isset($_GET['movetosection'])) {
if (! $section = get_record("course_sections", "id", $movetosection)) { if (! $section = get_record("course_sections", "id", $_GET['movetosection'])) {
error("This section doesn't exist"); error("This section doesn't exist");
} }
$beforecm = NULL; $beforecm = NULL;
} else { // normal moveto } 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"); error("The destination course module doesn't exist");
} }
if (! $section = get_record("course_sections", "id", $beforecm->section)) { if (! $section = get_record("course_sections", "id", $beforecm->section)) {
@ -171,9 +171,35 @@
redirect("view.php?id=$section->course"); 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"); error("This course module doesn't exist");
} }
@ -193,9 +219,9 @@
} }
exit; 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"); error("This course module doesn't exist");
} }
@ -225,9 +251,9 @@
} }
exit; 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"); error("This course module doesn't exist");
} }
@ -253,7 +279,7 @@
redirect("view.php?id=$cm->course"); redirect("view.php?id=$cm->course");
} else if (isset($cancelcopy)) { // value = course module } else if (isset($_GET['cancelcopy'])) { // value = course module
$courseid = $USER->activitycopycourse; $courseid = $USER->activitycopycourse;
@ -263,9 +289,9 @@
redirect("view.php?id=$courseid"); 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"); error("This course module doesn't exist");
} }
@ -293,7 +319,7 @@
"$CFG->wwwroot/course/view.php?id=$course->id"); "$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->coursemodule = $cm->id;
$form->section = $cm->section; $form->section = $cm->section;
@ -319,9 +345,9 @@
exit; 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"); error("This course module doesn't exist");
} }
@ -369,9 +395,9 @@
} }
} else if (isset($add)) { } else if (isset($_GET['add'])) {
if (!$add) { if (empty($_GET['add'])) {
redirect($_SERVER["HTTP_REFERER"]); redirect($_SERVER["HTTP_REFERER"]);
die; die;
} }
@ -383,7 +409,7 @@
error("This course doesn't exist"); 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"); error("This module type doesn't exist");
} }

View 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)') "); 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; return $result;
} }

View file

@ -104,6 +104,7 @@ CREATE TABLE `prefix_course_modules` (
`added` int(10) unsigned NOT NULL default '0', `added` int(10) unsigned NOT NULL default '0',
`deleted` tinyint(1) unsigned NOT NULL default '0', `deleted` tinyint(1) unsigned NOT NULL default '0',
`score` tinyint(4) 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', `visible` tinyint(1) NOT NULL default '1',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`) UNIQUE KEY `id` (`id`)

View file

@ -250,6 +250,11 @@ function main_upgrade($oldversion=0) {
table_column("course", "", "showrecent", "integer", "10", "unsigned", "1", "", "numsections"); table_column("course", "", "showrecent", "integer", "10", "unsigned", "1", "", "numsections");
} }
if ($oldversion < 2003091400) {
table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score");
}
return $result; return $result;
} }
?> ?>

View file

@ -62,6 +62,7 @@ CREATE TABLE prefix_course_modules (
added integer NOT NULL default '0', added integer NOT NULL default '0',
deleted integer NOT NULL default '0', deleted integer NOT NULL default '0',
score integer NOT NULL default '0', score integer NOT NULL default '0',
indent integer NOT NULL default '0',
visible integer NOT NULL default '1' visible integer NOT NULL default '1'
); );

View file

@ -5,7 +5,7 @@
// database to determine whether upgrades should // database to determine whether upgrades should
// be performed (see lib/db/*.php) // 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 $release = "1.2 development"; // User-friendly version number