More moodling on the course categories, improving performance for

large categories and making it easier to move large numbers of
courses around.

Also cleaned up some of the navigation bars
This commit is contained in:
moodler 2003-08-09 16:53:30 +00:00
parent 7140a97ae3
commit f2bb0045d3
7 changed files with 84 additions and 59 deletions

View File

@ -360,7 +360,6 @@
$table->data[0][0] .= "<p><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></p>";
}
$table->data[0][1] = "<p><a href=\"../course/index.php?edit=on\">".get_string("coursemanagement")."</a></p>".
"<p><a href=\"../course/edit.php\">".get_string("addnewcourse")."</a></p>";
$table->data[0][1] .= "<p><a href=\"../files/index.php?id=$site->id\">".get_string("courserestore")."</a></p>";
if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual") {
$table->data[0][2] = "<p><a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a></p>";

View File

@ -54,13 +54,12 @@
$strcategories = get_string("categories");
$strcategory = get_string("category");
$strcourses = get_string("courses");
$strcoursemanagement = get_string("coursemanagement");
if ($creatorediting) {
if ($adminediting) {
print_header("$site->shortname: $category->name", "$site->fullname",
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
"<a href=\"index.php\">$strcoursemanagement</a> -> $category->name",
"<a href=\"index.php\">$strcategories</a> -> $category->name",
"", "", true, $updatebutton);
} else {
print_header("$site->shortname: $category->name", "$site->fullname",
@ -90,18 +89,30 @@
/// Move a specified course to a new category
if (isset($move) and isset($moveto)) {
if (! $course = get_record("course", "id", $move)) {
notify("Error finding the course");
} else if (! $destcategory = get_record("course_categories", "id", $moveto)) {
notify("Error finding the category");
} else {
if (!set_field("course", "category", $destcategory->id, "id", $course->id)) {
notify("An error occurred - course not moved!");
if ($data = data_submitted()) { // Some courses are being moved
if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
error("Error finding the category");
}
unset($data->moveto);
unset($data->id);
if ($data) {
foreach ($data as $code => $junk) {
$courseid = substr($code, 1);
if (! $course = get_record("course", "id", $courseid)) {
notify("Error finding course $courseid");
} else {
if (!set_field("course", "category", $destcategory->id, "id", $course->id)) {
notify("An error occurred - course not moved!");
}
fix_course_sortorder($destcategory->id);
fix_course_sortorder($category->id);
$category = get_record("course_categories", "id", $category->id);
}
}
fix_course_sortorder($destcategory->id);
fix_course_sortorder($category->id);
$category = get_record("course_categories", "id", $category->id);
}
}
@ -187,7 +198,7 @@
} else {
$strcourses = get_string("courses");
$strmovecourseto = get_string("movecourseto");
$strmove = get_string("move");
$stredit = get_string("edit");
$strdelete = get_string("delete");
$strbackup = get_string("backup");
@ -205,12 +216,13 @@
}
echo "<form action=category.php method=post>";
echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=4 class=\"generalbox\"><tr>";
echo "<th>$strcourses</th>";
if ($creatorediting) {
echo "<th>$stredit</th>";
if ($adminediting) {
echo "<th>$strmovecourseto</th>";
echo "<th>$strmove</th>";
}
}
echo "</tr>";
@ -218,6 +230,7 @@
$numcourses = count($courses);
$count = 0;
$abletomovecourses = false; // for now
foreach ($courses as $course) {
$count++;
@ -257,34 +270,52 @@
}
echo "</td>";
echo "<td>";
popup_form ("category.php?id=$category->id&move=$course->id&moveto=", $displaylist,
"moveform$course->id", "$course->category", "", "", "", false);
echo "<td align=\"center\">";
echo "<input type=\"checkbox\" name=\"c$course->id\">";
$abletomovecourses = true;
} else if (isteacher($course->id)) {
echo "<td>";
echo "<a title=\"$strassignteachers\" href=\"$CFG->wwwroot/$CFG->admin/teacher.php?id=$course->id\"><img".
" src=\"$pixpath/t/user.gif\" height=11 width=11 border=0></a> ";
}
echo "</td>";
echo "</td>";
}
echo "</tr>";
}
if ($abletomovecourses) {
echo "<tr><td colspan=3 align=right>";
echo "<br />";
choose_from_menu ($displaylist, "moveto", "", get_string("moveselectedcoursesto"), "");
echo "<input type=\"hidden\" name=\"id\" value=\"$category->id\">";
echo "<input type=\"submit\" value=\"".get_string("move")."\">";
echo "</td></tr>";
}
echo "</table>";
echo "</form>";
echo "<br />";
}
if ($adminediting) {
/// First print form to rename the category
$strrename= get_string("rename");
print_simple_box_start("center");
echo "<center>";
/// Print link to create a new course
unset($options);
$option["category"] = $category->id;
print_single_button("edit.php", $options, get_string("addnewcourse"), "get");
echo "<br />";
/// Print form to rename the category
$strrename= get_string("rename");
echo "<form name=\"renameform\" action=\"category.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$category->id\">";
echo "<input type=\"text\" size=30 name=\"rename\" value=\"$category->name\">";
echo "<input type=\"submit\" value=\"$strrename\">";
echo "</form>";
echo "</center>";
print_simple_box_end();
echo "<br />";
}

View File

@ -3,7 +3,7 @@
require_once("../config.php");
optional_variable($id); // course id
require_variable($id); // course id
optional_variable($delete); // delete confirmation
require_login();
@ -18,37 +18,23 @@
$strdeletecourse = get_string("deletecourse");
$stradministration = get_string("administration");
$strcoursemanagement = get_string("coursemanagement");
if (!$id) {
print_header("$site->shortname: $strdeletecourse", $site->fullname,
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> -> $strdeletecourse");
if ($courses = get_courses()) {
print_heading(get_string("choosecourse"));
print_simple_box_start("CENTER");
foreach ($courses as $course) {
echo "<A HREF=\"delete.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
}
print_simple_box_end();
} else {
print_heading(get_string("nocoursesyet"));
print_continue("../$CFG->admin/index.php");
}
print_footer();
exit;
}
$strcategories = get_string("categories");
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect (can't find it)");
}
$category = get_record("course_categories", "id", $course->category);
if (! $delete) {
$strdeletecheck = get_string("deletecheck", "", $course->shortname);
$strdeletecoursecheck = get_string("deletecoursecheck");
print_header("$site->shortname: $strdeletecheck", $site->fullname,
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
"<a href=\"category.php?id=$course->category\">$strcoursemanagement</a> -> ".
"<a href=\"index.php\">$strcategories</a> -> ".
"<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
"$strdeletecheck");
notice_yesno("$strdeletecoursecheck<BR><BR>$course->fullname ($course->shortname)",
@ -66,7 +52,8 @@
print_header("$site->shortname: $strdeletingcourse", $site->fullname,
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
"<a href=\"category.php?id=$course->category\">$strcoursemanagement</a> -> ".
"<a href=\"index.php\">$strcategories</a> -> ".
"<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
"$strdeletingcourse");
print_heading($strdeletingcourse);

View File

@ -5,6 +5,7 @@
require_once("lib.php");
optional_variable($id, 0); // course id
optional_variable($category, 0); // category id
require_login();
@ -116,7 +117,7 @@
$form->numsections = 10;
$form->newsitems = 5;
$form->showrecent = 1;
$form->category = 0;
$form->category = $category;
$form->id = "";
$form->visible = 1;
}
@ -137,15 +138,16 @@
$streditcoursesettings = get_string("editcoursesettings");
$straddnewcourse = get_string("addnewcourse");
$stradministration = get_string("administration");
$strcategories = get_string("categories");
if (!empty($course)) {
print_header($streditcoursesettings, "$course->fullname",
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
-> $streditcoursesettings", $focus);
} else {
print_header("$site->shortname: $straddnewcourse", "$site->fullname",
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A>
-> $straddnewcourse", $focus);
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
"<a href=\"index.php\">$strcategories</a> -> $straddnewcourse", $focus);
}
print_heading($streditcoursesettings);

View File

@ -59,14 +59,13 @@
$strcategories = get_string("categories");
$strcategory = get_string("category");
$strcourses = get_string("courses");
$strcoursemanagement = get_string("coursemanagement");
$stredit = get_string("edit");
$strdelete = get_string("delete");
$straction = get_string("action");
$straddnewcategory = get_string("addnewcategory");
print_header("$site->shortname: $strcategories", "$site->fullname",
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strcoursemanagement",
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strcategories",
"addform.addcategory", "", true, update_categories_button());
print_heading($strcategories);
@ -221,14 +220,12 @@
/// Print form for creating new categories
print_simple_box_start("center");
echo "<center>";
echo "<form name=\"addform\" action=\"index.php\" method=\"post\">";
echo "<input type=\"text\" size=30 name=\"addcategory\">";
echo "<input type=\"submit\" value=\"$straddnewcategory\">";
echo "</form>";
echo "</center>";
print_simple_box_end();
echo "<br />";
@ -255,7 +252,15 @@
print_category_edit(NULL, $displaylist, $parentlist);
echo "</table>";
echo "<br />";
echo "<center>";
/// Print link to create a new course
unset($options);
$option["category"] = $category->id;
print_single_button("edit.php", $options, get_string("addnewcourse"), "get");
echo "<br />";
echo "</center>";
print_footer();

View File

@ -715,8 +715,6 @@ function print_admin_links ($siteid, $width=180) {
if (iscreator()) {
$moddata[]="<a href=\"$CFG->wwwroot/course/index.php?edit=on\">".get_string("coursemanagement")."</a>";
$modicon[]=$icon;
$moddata[]="<a href=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</a>";
$modicon[]=$icon;
$fulladmin = "";
}
if (isadmin()) {

View File

@ -125,6 +125,8 @@ $string['course'] = "Course";
$string['courseavailable'] = "This course is available to students";
$string['courseavailablenot'] = "This course is not available to students";
$string['coursebackup'] = "Course backup";
$string['coursecategories'] = "Course categories";
$string['coursecategory'] = "Course category";
$string['coursecreators'] = "Course creators";
$string['courseinfo'] = "Course info";
$string['coursefiles'] = "Course files";
@ -461,11 +463,12 @@ $string['move'] = "Move";
$string['movecategoryto'] = "Move category to:";
$string['movecourseto'] = "Move course to:";
$string['movedown'] = "Move down";
$string['movefilestohere'] = "Move files to here";
$string['movefull'] = "Move \$a to this location";
$string['movehere'] = "Move to here";
$string['moveup'] = "Move up";
$string['moveselectedcoursesto'] = "Move selected courses to...";
$string['movetoanotherfolder'] = "Move to another folder";
$string['movefilestohere'] = "Move files to here";
$string['moveup'] = "Move up";
$string['mustconfirm'] = "You need to confirm your login";
$string['mycourses'] = "My courses";
$string['name'] = "Name";