From c432fd3213be5d3d98e70caa0a5cb555a4a6532d Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 22 Aug 2003 12:15:35 +0000 Subject: [PATCH] Put in buttons so that course creators can create courses! :-I Also, category fix_sorting is done better now when a course is added. --- course/category.php | 14 +++++++------- course/edit.php | 4 ++-- course/index.php | 12 ++++++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/course/category.php b/course/category.php index 65e0701736..db2fe1525e 100644 --- a/course/category.php +++ b/course/category.php @@ -353,31 +353,31 @@ } - if (isadmin()) { - echo "
"; - - /// Print button to re-sort courses by name + echo "
"; + if (isadmin()) { /// Print button to re-sort courses by name unset($options); $options["id"] = $category->id; $options["resort"] = "name"; print_single_button("category.php", $options, get_string("resortcoursesbyname"), "get"); + } - /// Print button to create a new course + if (iscreator()) { /// Print button to create a new course unset($options); $options["category"] = $category->id; print_single_button("edit.php", $options, get_string("addnewcourse"), "get"); echo "
"; + } - /// Print form to rename the category + if (isadmin()) { /// Print form to rename the category $strrename= get_string("rename"); echo "
"; echo "id\">"; echo "name\">"; echo ""; echo "
"; - echo "
"; echo "
"; } + echo "
"; print_footer(); diff --git a/course/edit.php b/course/edit.php index e751f3d8f6..6b2da9b826 100644 --- a/course/edit.php +++ b/course/edit.php @@ -45,11 +45,10 @@ $form->timemodified = time(); - fix_course_sortorder($form->category); - if (!empty($course)) { if (update_record("course", $form)) { add_to_log($course->id, "course", "update", "edit.php?id=$id", ""); + fix_course_sortorder($form->category); redirect("view.php?id=$course->id", get_string("changessaved")); } else { error("Serious Error! Could not update the course record! (id = $form->id)"); @@ -63,6 +62,7 @@ $section->section = 0; $section->id = insert_record("course_sections", $section); + fix_course_sortorder($form->category); add_to_log($newcourseid, "course", "new", "view.php?id=$newcourseid", ""); if (isadmin()) { // Redirect admin to add teachers diff --git a/course/index.php b/course/index.php index 995d4d0ecb..06c831771c 100644 --- a/course/index.php +++ b/course/index.php @@ -41,7 +41,15 @@ print_header("$site->shortname: $strfulllistofcourses", $strfulllistofcourses, $strfulllistofcourses); print_courses(0, "80%"); } - + + if (iscreator()) { // Print link to create a new course + echo "

"; + unset($options); + $option["category"] = $category->id; + print_single_button("edit.php", $options, get_string("addnewcourse"), "get"); + echo "

"; + } + print_footer(); exit; } @@ -255,8 +263,8 @@ echo ""; echo "
"; - echo "
"; /// Print link to create a new course + echo "
"; unset($options); $option["category"] = $category->id; print_single_button("edit.php", $options, get_string("addnewcourse"), "get"); -- 2.39.5