From: martin
Date: Fri, 2 Aug 2002 17:38:18 +0000 (+0000)
Subject: Lots of changes related to module info used in course listings and
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9084509828676570ce20ee201a16710a65ba7963;p=moodle.git
Lots of changes related to module info used in course listings and
activity reports. Module names are now from lang files, not from
the modules table. Cleanups.
---
diff --git a/course/lib.php b/course/lib.php
index b3d3e3a401..3cb84d29f1 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -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 "
+
+
+
+
";
+}
+
+function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
+
+ echo "\n";
+ echo "$heading |
\n";
+ if ($list) {
+ foreach($list as $key => $string) {
+ echo "";
+ if ($icons[$key]) {
+ echo $icons[$key];
+ } else {
+ echo "";
+ }
+ echo " | \n";
+ echo " $string ";
+ echo " |
\n";
+ }
+ }
+ if ($footer) {
+ echo " | $footer |
\n";
+ }
+ echo "
\n\n";
+}
?>
diff --git a/course/mod.php b/course/mod.php
index 929e987bc3..193e450150 100644
--- a/course/mod.php
+++ b/course/mod.php
@@ -119,13 +119,14 @@
"$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");
@@ -165,7 +166,8 @@
$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)) {
@@ -195,10 +197,12 @@
$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 {
@@ -212,14 +216,14 @@
}
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",
"wwwroot/course/view.php?id=$course->id\">$course->shortname ->
- 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";
diff --git a/course/topics.php b/course/topics.php
index b22e5fd06b..731a1e2904 100644
--- a/course/topics.php
+++ b/course/topics.php
@@ -61,9 +61,9 @@
$moddata = array();
$modicon = array();
- if ($modtype) {
- foreach ($modtype as $modname => $modfullname) {
- $moddata[] = "id\">".$modfullname."s";
+ if ($modnamesused) {
+ foreach ($modnamesused as $modname => $modfullname) {
+ $moddata[] = "id\">".$modnamesplural[$modname]."";
$modicon[] = "
";
}
}
@@ -173,7 +173,7 @@
if (isediting($course->id)) {
echo "";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&add=",
- $modtypes, "section$section", "", "Add...");
+ $modnames, "section$section", "", "Add...");
echo "
";
}
diff --git a/course/user.php b/course/user.php
index 508738cd6e..f6d7a0a2ad 100644
--- a/course/user.php
+++ b/course/user.php
@@ -56,7 +56,7 @@
echo "";
- get_all_mods($course->id, $mods, $modtype);
+ get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
switch ($mode) {
case "today" :
diff --git a/course/view.php b/course/view.php
index cfc202196c..e74a8997a7 100644
--- a/course/view.php
+++ b/course/view.php
@@ -48,11 +48,7 @@
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":
@@ -70,47 +66,4 @@
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 "
-
-
-
-
";
-}
-
-function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
-
- echo "\n";
- echo "$heading |
\n";
- if ($list) {
- foreach($list as $key => $string) {
- echo "";
- if ($icons[$key]) {
- echo $icons[$key];
- } else {
- echo "";
- }
- echo " | \n";
- echo " $string ";
- echo " |
\n";
- }
- }
- if ($footer) {
- echo " | $footer |
\n";
- }
- echo "
\n\n";
-}
-
?>
diff --git a/course/weeks.php b/course/weeks.php
index 8315eb8494..fbdd73ffe6 100644
--- a/course/weeks.php
+++ b/course/weeks.php
@@ -43,9 +43,9 @@
$moddata = array();
$modicon = array();
- if ($modtype) {
- foreach ($modtype as $modname => $modfullname) {
- $moddata[] = "id\">".$modfullname."s";
+ if ($modnamesused) {
+ foreach ($modnamesused as $modname => $modfullname) {
+ $moddata[] = "id\">".$modnamesplural[$modname]."";
$modicon[] = "
";
}
}
@@ -136,7 +136,7 @@
}
if (isediting($course->id)) {
- $thisweek->summary .= " id>
";
+ $thisweek->summary .= " id\">
";
}
echo text_to_html($thisweek->summary);
@@ -163,7 +163,7 @@
if (isediting($course->id)) {
echo "";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
- $modtypes, "section$week", "", "Add...");
+ $modnames, "section$week", "", "Add...");
echo "
";
}