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
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));
}
$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;
$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\" ";
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>";
}
}
-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 = '';
$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");
" 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";
}
- 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");
}
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;
}
`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`)
table_column("course", "", "showrecent", "integer", "10", "unsigned", "1", "", "numsections");
}
+ if ($oldversion < 2003091400) {
+ table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score");
+ }
+
+
return $result;
}
?>
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'
);
// 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