From: moodler Date: Sat, 9 Aug 2003 16:53:30 +0000 (+0000) Subject: More moodling on the course categories, improving performance for X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f2bb0045d30e243fba94c366c2452dbf667bc3f4;p=moodle.git 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 --- diff --git a/admin/index.php b/admin/index.php index 4eeb958531..f5a1f09255 100644 --- a/admin/index.php +++ b/admin/index.php @@ -360,7 +360,6 @@ $table->data[0][0] .= "

dbtype/frame.php\">".get_string("managedatabase")."

"; } $table->data[0][1] = "

".get_string("coursemanagement")."

". - "

".get_string("addnewcourse")."

"; $table->data[0][1] .= "

id\">".get_string("courserestore")."

"; if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual") { $table->data[0][2] = "

".get_string("addnewuser")."

"; diff --git a/course/category.php b/course/category.php index 791d280673..0554ee1e7f 100644 --- a/course/category.php +++ b/course/category.php @@ -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", "admin/index.php\">$stradministration -> ". - "$strcoursemanagement -> $category->name", + "$strcategories -> $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 "
"; echo ""; echo ""; if ($creatorediting) { echo ""; if ($adminediting) { - echo ""; + echo ""; } } echo ""; @@ -218,6 +230,7 @@ $numcourses = count($courses); $count = 0; + $abletomovecourses = false; // for now foreach ($courses as $course) { $count++; @@ -257,34 +270,52 @@ } echo ""; - echo ""; + echo ""; } echo ""; } + + if ($abletomovecourses) { + echo ""; + } echo "
$strcourses$stredit$strmovecourseto$strmove
"; - popup_form ("category.php?id=$category->id&move=$course->id&moveto=", $displaylist, - "moveform$course->id", "$course->category", "", "", "", false); + echo ""; + echo "id\">"; + $abletomovecourses = true; + } else if (isteacher($course->id)) { + echo ""; echo "wwwroot/$CFG->admin/teacher.php?id=$course->id\"> "; } - echo "
"; + echo "
"; + choose_from_menu ($displaylist, "moveto", "", get_string("moveselectedcoursesto"), ""); + echo "id\">"; + echo ""; + echo "
"; + echo "
"; echo "
"; } + if ($adminediting) { - /// First print form to rename the category - $strrename= get_string("rename"); - print_simple_box_start("center"); echo "
"; + + /// Print link to create a new course + unset($options); + $option["category"] = $category->id; + print_single_button("edit.php", $options, get_string("addnewcourse"), "get"); + echo "
"; + + /// Print form to rename the category + $strrename= get_string("rename"); echo "
"; echo "id\">"; echo "name\">"; echo ""; echo "
"; echo "
"; - print_simple_box_end(); echo "
"; } diff --git a/course/delete.php b/course/delete.php index 19c3340f50..d0cee3315b 100644 --- a/course/delete.php +++ b/course/delete.php @@ -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, - "admin/index.php\">$stradministration -> $strdeletecourse"); - - if ($courses = get_courses()) { - print_heading(get_string("choosecourse")); - print_simple_box_start("CENTER"); - foreach ($courses as $course) { - echo "id\">$course->fullname ($course->shortname)
"; - } - 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, "admin/index.php\">$stradministration -> ". - "category\">$strcoursemanagement -> ". + "$strcategories -> ". + "category\">$category->name -> ". "$strdeletecheck"); notice_yesno("$strdeletecoursecheck

$course->fullname ($course->shortname)", @@ -66,7 +52,8 @@ print_header("$site->shortname: $strdeletingcourse", $site->fullname, "admin/index.php\">$stradministration -> ". - "category\">$strcoursemanagement -> ". + "$strcategories -> ". + "category\">$category->name -> ". "$strdeletingcourse"); print_heading($strdeletingcourse); diff --git a/course/edit.php b/course/edit.php index 3fee94c5c6..d2e3be879a 100644 --- a/course/edit.php +++ b/course/edit.php @@ -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", - "wwwroot/course/view.php?id=$course->id\">$course->shortname + "wwwroot/course/view.php?id=$course->id\">$course->shortname -> $streditcoursesettings", $focus); } else { print_header("$site->shortname: $straddnewcourse", "$site->fullname", - "admin/index.php\">$stradministration - -> $straddnewcourse", $focus); + "admin/index.php\">$stradministration -> ". + "$strcategories -> $straddnewcourse", $focus); } print_heading($streditcoursesettings); diff --git a/course/index.php b/course/index.php index 17fe8e45ca..73cb0c5f03 100644 --- a/course/index.php +++ b/course/index.php @@ -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", - "admin/index.php\">$stradministration -> $strcoursemanagement", + "admin/index.php\">$stradministration -> $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 "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; - print_simple_box_end(); echo "
"; @@ -255,7 +252,15 @@ print_category_edit(NULL, $displaylist, $parentlist); echo ""; + echo "
"; + echo "
"; + /// Print link to create a new course + unset($options); + $option["category"] = $category->id; + print_single_button("edit.php", $options, get_string("addnewcourse"), "get"); + echo "
"; + echo "
"; print_footer(); diff --git a/course/lib.php b/course/lib.php index 264911d886..f6982eb703 100644 --- a/course/lib.php +++ b/course/lib.php @@ -715,8 +715,6 @@ function print_admin_links ($siteid, $width=180) { if (iscreator()) { $moddata[]="wwwroot/course/index.php?edit=on\">".get_string("coursemanagement").""; $modicon[]=$icon; - $moddata[]="wwwroot/course/edit.php\">".get_string("addnewcourse").""; - $modicon[]=$icon; $fulladmin = ""; } if (isadmin()) { diff --git a/lang/en/moodle.php b/lang/en/moodle.php index c82c1f5988..dabb3eccf4 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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";