]> git.mjollnir.org Git - moodle.git/commitdiff
More moodling on the course categories, improving performance for
authormoodler <moodler>
Sat, 9 Aug 2003 16:53:30 +0000 (16:53 +0000)
committermoodler <moodler>
Sat, 9 Aug 2003 16:53:30 +0000 (16:53 +0000)
large categories and making it easier to move large numbers of
courses around.

Also cleaned up some of the navigation bars

admin/index.php
course/category.php
course/delete.php
course/edit.php
course/index.php
course/lib.php
lang/en/moodle.php

index 4eeb9585313e6015bbc33455c1075a20a3593f2f..f5a1f09255e11e20ddf02f114e038b65dbef8167 100644 (file)
             $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>";
index 791d28067331cb4a6aaa3530a40fe00b410c36a7..0554ee1e7f61f9991b56a95426eef0c58902d516 100644 (file)
     $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", 
 
     /// 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);
             }
         }
 
     } 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");
         }
 
     
+        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>";
 
         $numcourses = count($courses);
         $count = 0;
+        $abletomovecourses = false;  // for now
 
         foreach ($courses as $course) {
             $count++;
                     }
     
                     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 />";
     }
 
index 19c3340f50b446c1ac96d1a78a83e0351eb667fd..d0cee3315b5a8d8410b1346ad71cd3959c5f2b1c 100644 (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();
 
     $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);
index 3fee94c5c6d68fc7f9745a47561cb7c64e8a15b5..d2e3be879a5e7219562c8a306f75690ae63bc492 100644 (file)
@@ -5,6 +5,7 @@
        require_once("lib.php");
 
     optional_variable($id, 0);   // course id
+    optional_variable($category, 0);   // category id
 
     require_login();
 
             $form->numsections = 10;
             $form->newsitems = 5;
             $form->showrecent = 1;
-            $form->category = 0;
+            $form->category = $category;
             $form->id = "";
             $form->visible = 1;
         }
     $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);
index 17fe8e45ca69e45cf5b4d0d61c1253ba25bc4870..73cb0c5f036cc6fdb0708177dfe3d7c29ac41197 100644 (file)
     $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);
 
 /// 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 />";
 
     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();
 
index 264911d8860cf85fa006963936cc41a00258b103..f6982eb70317fcb5b31f465341777d88e1cafe5c 100644 (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()) {
index c82c1f5988998303a7111a4e3d14cca06fa0fe0f..dabb3eccf43772af2e7dc4e9ed8a916934ada968 100644 (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";