]> git.mjollnir.org Git - moodle.git/commitdiff
qtypes help: MDL-5106 Create questiontype help file dynamically
authortjhunt <tjhunt>
Thu, 26 Feb 2009 07:07:40 +0000 (07:07 +0000)
committertjhunt <tjhunt>
Thu, 26 Feb 2009 07:07:40 +0000 (07:07 +0000)
help.php
lang/en_utf8/help/question/types.html [new file with mode: 0644]
question/editlib.php

index 7a89337ae0a1dd1ff0b08e7ae540b7e4fa510e9d..88fcfd8fefbcd91765f96344c5e87fb242992f34 100644 (file)
--- a/help.php
+++ b/help.php
@@ -99,6 +99,9 @@ if (!empty($file)) {
                 if ($module == 'moodle' and ($file == 'index.html' or $file == 'mods.html')) {
                     include_help_for_each_module($file, $langs, $helpdir);
                 }
+                if ($module == 'question' and ($file == 'types.html')) {
+                    include_help_for_each_qtype();
+                }
 
                 // The remaining horrible hardcoded special cases should be delegated to modules somehow.
                 if ($module == 'moodle' and ($file == 'resource/types.html')) {  // RESOURCES
@@ -208,6 +211,28 @@ function include_help_for_each_module($file, $langs, $helpdir) {
     }
 }
 
+function include_help_for_each_qtype() {
+    global $CFG;
+    require_once($CFG->libdir . '/questionlib.php');
+    global $QTYPES;
+    $types = question_type_menu();
+    $fakeqtypes = array();
+    foreach ($types as $qtype => $localizedname) {
+        if ($QTYPES[$qtype]->is_real_question_type()) {
+            include_help_for_qtype($qtype, $localizedname);
+        } else {
+            $fakeqtypes[$qtype] = $localizedname;
+        }
+    }
+    foreach ($fakeqtypes as $qtype => $localizedname) {
+        include_help_for_qtype($qtype, $localizedname);
+    }
+}
+function include_help_for_qtype($qtype, $localizedname) {
+    echo '<h2>' . $localizedname . "</h2>\n\n";
+    echo '<p>' . get_string($qtype . 'summary', 'qtype_' . $qtype) . "</p>\n\n";
+}
+
 function include_help_for_each_resource($file, $langs, $helpdir) {
     global $CFG;
 
diff --git a/lang/en_utf8/help/question/types.html b/lang/en_utf8/help/question/types.html
new file mode 100644 (file)
index 0000000..56c58ea
--- /dev/null
@@ -0,0 +1,4 @@
+<h1>Creating a new question</h1>
+
+<p>You can create questions of various different types:</p>
+
index fdbbab6b28768ff38ffa99c2359b8e55bb14f568..dbcc783f4e379dc5869f4242ad6ecfd1c797a35d 100644 (file)
@@ -1901,7 +1901,7 @@ function create_new_question_button($categoryid, $params, $caption, $tooltip = '
     $params['category'] = $categoryid;
     print_single_button($CFG->wwwroot . '/question/addquestion.php', $params,
             $caption,'get', '', false, $tooltip, $disabled);
-    helpbutton('questiontypes', get_string('createnewquestion', 'question'), 'question');
+    helpbutton('types', get_string('createnewquestion', 'question'), 'question');
     require_js(array('yui_yahoo','yui_dom','yui_event', 'yui_dragdrop', 'yui_container'));
     if (!$choiceformprinted) {
         echo '<div id="qtypechoicecontainer">';