Merged from MOODLE_14_STABLE - Provide an explicit sortorder for new courses in empty categories, and run fix_course_sortorder() after adding the course to make sure its in the appropriate range for the category. This mege adds fix specific to HEAD: it reverts an earlier bad fix.

This commit is contained in:
martinlanghoff 2005-02-24 21:22:06 +00:00
parent 97cfb9352c
commit b935c832ec

View File

@ -86,7 +86,10 @@
// place at beginning of category
fix_course_sortorder();
$form->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category=$form->category") || 1000;
$form->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category=$form->category");
if (empty($form->sortorder)) {
$form->sortorder = 100;
}
if ($newcourseid = insert_record('course', $form)) { // Set up new course
@ -120,6 +123,8 @@
$USER->teacher[$newcourseid] = true;
$USER->teacheredit[$newcourseid] = true;
fix_course_sortorder();
redirect("view.php?id=$newcourseid", get_string("changessaved"));
}