Skip to content

Commit

Permalink
qtypes help: MDL-5106 Create questiontype help file dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhunt committed Feb 26, 2009
1 parent 944efb3 commit 8bc590f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
25 changes: 25 additions & 0 deletions help.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
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
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions lang/en_utf8/help/question/types.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>Creating a new question</h1>

<p>You can create questions of various different types:</p>

2 changes: 1 addition & 1 deletion question/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">';
Expand Down

0 comments on commit 8bc590f

Please sign in to comment.