qtypes help: MDL-5106 Create questiontype help file dynamically

This commit is contained in:
tjhunt
2009-02-26 07:07:40 +00:00
parent 944efb3e8b
commit 8bc590f5df
3 changed files with 30 additions and 1 deletions
+25
View File
@@ -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;
+4
View File
@@ -0,0 +1,4 @@
<h1>Creating a new question</h1>
<p>You can create questions of various different types:</p>
+1 -1
View 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">';