]> git.mjollnir.org Git - moodle.git/commitdiff
Lots of changes related to module info used in course listings and
authormartin <martin>
Fri, 2 Aug 2002 17:38:18 +0000 (17:38 +0000)
committermartin <martin>
Fri, 2 Aug 2002 17:38:18 +0000 (17:38 +0000)
activity reports.  Module names are now from lang files, not from
the modules table.  Cleanups.

course/lib.php
course/mod.php
course/topics.php
course/user.php
course/view.php
course/weeks.php

index b3d3e3a4013a01657b315fa93901f3f83c2c35c2..3cb84d29f12942e0a0c5b9c4436941eb06010d90 100644 (file)
@@ -393,23 +393,35 @@ function enrol_student_in_course($user, $course) {
        }
 }
 
-function get_all_mods($courseid, &$mods, &$modtype) {
+function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) {
+// Returns a number of useful structures for course displays
 
-    $mods = NULL;
-    $modtype = NULL;
+    $mods          = NULL;    // course modules indexed by id
+    $modnames      = NULL;    // all course module names
+    $modnamesused  = NULL;    // course module names used
 
-    if ( $rawmods = get_records_sql("SELECT cm.*, m.name as modname, m.fullname as modfullname
-                                   FROM modules m, course_modules cm
-                                   WHERE cm.course = '$courseid' 
-                                     AND cm.deleted = '0'
-                                     AND cm.module = m.id") ) {
+    if ($allmods = get_records_sql("SELECT * FROM modules") ) {
+        foreach ($allmods as $mod) {
+            $modnames[$mod->name] = get_string("modulename", "$mod->name");
+            $modnamesplural[$mod->name] = get_string("modulenameplural", "$mod->name");
+        }
+        asort($modnames);
+    } else {
+        error("No modules are installed!");
+    }
+
+    if ($rawmods = get_records_sql("SELECT cm.*, m.name as modname
+                                     FROM modules m, course_modules cm
+                                     WHERE cm.course = '$courseid' 
+                                       AND cm.deleted = '0'
+                                       AND cm.module = m.id") ) {
         foreach($rawmods as $mod) {    // Index the mods
             $mods[$mod->id] = $mod;
-            $modtype[$mod->modname] = $mod->modfullname;
+            $mods[$mod->id]->modfullname = $modnames[$mod->modname];
+            $modnamesused[$mod->modname] = $modnames[$mod->modname];
         }
-        ksort($modtype);
+        asort($modnamesused);
     }
-
 }
 
 function get_all_sections($courseid) {
@@ -642,5 +654,43 @@ function move_module($id, $move) {
     }
 }
 
+function make_editing_buttons($moduleid) {
+    $delete   = get_string("delete");
+    $moveup   = get_string("moveup");
+    $movedown = get_string("movedown");
+    $update   = get_string("update");
+    return "&nbsp; &nbsp; 
+          <A HREF=mod.php?delete=$moduleid><IMG 
+             SRC=../pix/t/delete.gif BORDER=0 ALT=\"$delete\"></A>
+          <A HREF=mod.php?id=$moduleid&move=-1><IMG 
+             SRC=../pix/t/up.gif BORDER=0 ALT=\"$moveup\"></A>
+          <A HREF=mod.php?id=$moduleid&move=1><IMG 
+             SRC=../pix/t/down.gif BORDER=0 ALT=\"$movedown\"></A>
+          <A HREF=mod.php?update=$moduleid><IMG 
+             SRC=../pix/t/edit.gif BORDER=0 ALT=\"$update\"></A>";
+}
+
+function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
+    
+    echo "<TABLE WIDTH=100%>\n";
+    echo "<TR><TD COLSPAN=2><P><B><FONT SIZE=2>$heading</TD></TR>\n";
+    if ($list) {
+        foreach($list as $key => $string) {
+            echo "<TR><TD VALIGN=top WIDTH=12>";
+            if ($icons[$key]) {
+                echo $icons[$key];
+            } else {
+                echo "";
+            }
+            echo "</TD>\n<TD WIDTH=100% VALIGN=top>";
+            echo "<P><FONT SIZE=2>$string</FONT></P>";
+            echo "</TD></TR>\n";
+        }
+    }
+    if ($footer) {
+        echo "<TR><TD></TD><TD ALIGN=left><P><FONT SIZE=2>$footer</TD></TR>\n";
+    }
+    echo "</TABLE><BR>\n\n";
+}
 
 ?>
index 929e987bc383589720d6c8a47955680236acb93b..193e4501503a622e6b4f9b251e2e73cf35b8d813 100644 (file)
                   "$CFG->wwwroot/course/view.php?id=$course->id");
         }
 
+        $fullmodulename = strtolower(get_string("modulename", $module->name));
 
         $form->coursemodule = $cm->id;
         $form->section      = $cm->section;
         $form->course       = $cm->course;
         $form->instance     = $cm->instance;
         $form->modulename   = $module->name;
-        $form->fullmodulename  = strtolower($module->fullname);
+        $form->fullmodulename  = $fullmodulename;
         $form->instancename = $instance->name;
 
         include("mod_delete.html");
         $form->instance     = $cm->instance;
         $form->mode         = "update";
 
-        $pageheading = "Updating a ".strtolower($module->fullname)." in $sectionname $cw->section";
+        $fullmodulename = strtolower(get_string("modulename", $module->name));
+        $pageheading = "Updating a $fullmodulename in $sectionname $cw->section";
 
         
     } else if (isset($add)) {
         $form->instance   = $cm->instance;
         $form->mode       = "add";
 
+        $fullmodulename = strtolower(get_string("modulename", $module->name));
+
+        $pageheading = "Adding a new $fullmodulename";
+
         if ($form->section) {
-            $pageheading = "Adding a new ".strtolower($module->fullname)." to $sectionname $form->section";
-        } else {
-            $pageheading = "Adding a new ".strtolower($module->fullname);
+            $pageheading .= " to $sectionname $form->section";
         }
 
     } else {
     }
 
     if ($course->category) {
-        print_header("$course->shortname: Editing a $module->fullname", 
-                     "$course->shortname: Editing a $module->fullname",
+        print_header("$course->shortname: Editing a $fullmodulename", 
+                     "$course->shortname: Editing a $fullmodulename",
                      "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> 
-                      Editing a $module->fullname", "form.name", "", false);
+                      Editing a $fullmodulename", "form.name", "", false);
     } else {
-        print_header("$course->shortname: Editing a $module->fullname", 
-                     "$course->shortname: Editing a $module->fullname",
-                     "Editing a $module->fullname", "form.name", "", false);
+        print_header("$course->shortname: Editing a $fullmodulename", 
+                     "$course->shortname: Editing a $fullmodulename",
+                     "Editing a $fullmodulename", "form.name", "", false);
     }
 
     $modform = "../mod/$module->name/mod.html";
index b22e5fd06b9fd4490a01bc8f0c47e53e03bbe8c7..731a1e290441282084668e0ac54f58f8525feb23 100644 (file)
@@ -61,9 +61,9 @@
 
     $moddata = array();
     $modicon = array();
-    if ($modtype) {
-        foreach ($modtype as $modname => $modfullname) {
-            $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modfullname."s</A>";
+    if ($modnamesused) {
+        foreach ($modnamesused as $modname => $modfullname) {
+            $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
             $modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$modfullname\">";
         }
     }
         if (isediting($course->id)) {
             echo "<DIV ALIGN=right>";
             popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=", 
-                        $modtypes, "section$section", "", "Add...");
+                        $modnames, "section$section", "", "Add...");
             echo "</DIV>";
         }
 
index 508738cd6e56888eae0ff4aaf0930d6c157f7e4c..f6d7a0a2ad29a690c47f9f810f13edb3ccf4ea9a 100644 (file)
@@ -56,7 +56,7 @@
     echo "</TR></TABLE>";
 
 
-    get_all_mods($course->id, $mods, $modtype);
+    get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
 
     switch ($mode) {
         case "today" :
index cfc202196c58bc8e5c874307af4127ee204dc0f6..e74a8997a7bfb632a3980038e380151cc57ad863 100644 (file)
     print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
                   update_course_icon($course->id));
 
-    if (! $modtypes = get_records_sql_menu("SELECT name,fullname FROM modules ORDER BY fullname") ) {
-        error("No modules are installed!");
-    }
-
-    get_all_mods($course->id, $mods, $modtype);
+    get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
 
     switch ($course->format) {
         case "weeks":
 
     print_footer($course);
 
-
-/// FUNCTIONS ////////
-
-
-function make_editing_buttons($moduleid) {
-    $delete   = get_string("delete");
-    $moveup   = get_string("moveup");
-    $movedown = get_string("movedown");
-    $update   = get_string("update");
-    return "&nbsp; &nbsp; 
-          <A HREF=mod.php?delete=$moduleid><IMG 
-             SRC=../pix/t/delete.gif BORDER=0 ALT=\"$delete\"></A>
-          <A HREF=mod.php?id=$moduleid&move=-1><IMG 
-             SRC=../pix/t/up.gif BORDER=0 ALT=\"$moveup\"></A>
-          <A HREF=mod.php?id=$moduleid&move=1><IMG 
-             SRC=../pix/t/down.gif BORDER=0 ALT=\"$movedown\"></A>
-          <A HREF=mod.php?update=$moduleid><IMG 
-             SRC=../pix/t/edit.gif BORDER=0 ALT=\"$update\"></A>";
-}
-
-function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
-    
-    echo "<TABLE WIDTH=100%>\n";
-    echo "<TR><TD COLSPAN=2><P><B><FONT SIZE=2>$heading</TD></TR>\n";
-    if ($list) {
-        foreach($list as $key => $string) {
-            echo "<TR><TD VALIGN=top WIDTH=12>";
-            if ($icons[$key]) {
-                echo $icons[$key];
-            } else {
-                echo "";
-            }
-            echo "</TD>\n<TD WIDTH=100% VALIGN=top>";
-            echo "<P><FONT SIZE=2>$string</FONT></P>";
-            echo "</TD></TR>\n";
-        }
-    }
-    if ($footer) {
-        echo "<TR><TD></TD><TD ALIGN=left><P><FONT SIZE=2>$footer</TD></TR>\n";
-    }
-    echo "</TABLE><BR>\n\n";
-}
-
 ?>
index 8315eb8494f379136567c892fe806b6a787458d0..fbdd73ffe662567eec46eb72a47fb0904e873e50 100644 (file)
@@ -43,9 +43,9 @@
 
     $moddata = array();
     $modicon = array();
-    if ($modtype) {
-        foreach ($modtype as $modname => $modfullname) {
-            $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modfullname."s</A>";
+    if ($modnamesused) {
+        foreach ($modnamesused as $modname => $modfullname) {
+            $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
             $modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$modfullname\">";
         }
     }
         }
 
         if (isediting($course->id)) {
-            $thisweek->summary .= "&nbsp;<A HREF=editweek.php?id=$thisweek->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
+            $thisweek->summary .= "&nbsp;<A HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
         }
 
         echo text_to_html($thisweek->summary);
         if (isediting($course->id)) {
             echo "<DIV ALIGN=right>";
             popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$week&add=", 
-                        $modtypes, "section$week", "", "Add...");
+                        $modnames, "section$week", "", "Add...");
             echo "</DIV>";
         }