MDL-43089 quiz: improved interface for building quizzes
This commit is actually the joint work of Mahmoud Kassaei, Colin Chambers and Tim Hunt from The Open University. We could only use one persons name for the commit, and this time Colin gets the credit/blame. The goal of this work was to increase usability, and also clean up the page enough that it will be possible to add new features in future. Display of mod/quiz/edit.php is now entirely generated by mod_quiz\output\edit_renderer. This uses a helper class mod_quiz\structure to provide details of the structure of the quiz, and mod_quiz\repaginate to alter that structure. (Acutally, there are still some modification methods on mod_quiz\structure. Expect that to be cleaned up in future.) The new code uses much more ajax, and there are new scripts mod/quiz/edit_rest.php and mod/quiz/repaginate.php to handle this. (Again, don't be surprised if those two scripts get merged in future.) Also questionbank.ajax.php (which may, in future, be made more generic, and moved into the core question bank code.) Most of the new JavaScript code has intentionally copied the way things are done when editing activities on the course page. As a result of this, mod/quiz/editlib.php is now much shorter than it was. (In future, expect the remaining code in here to move into mod/quiz/classes.)
This commit is contained in:
+13
-6
@@ -374,6 +374,16 @@ function question_edit_setup($edittab, $baseurl, $requirecmid = false, $requirec
|
||||
return array($thispageurl, $contexts, $cmid, $cm, $module, $pagevars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category id from $pagevars.
|
||||
* @param array $pagevars from {@link question_edit_setup()}.
|
||||
* @return int the category id.
|
||||
*/
|
||||
function question_get_category_id_from_pagevars(array $pagevars) {
|
||||
list($questioncategoryid) = explode(',', $pagevars['cat']);
|
||||
return $questioncategoryid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a particular question preference that is also stored as a user preference.
|
||||
* If the the value is given in the GET/POST request, then that value is used,
|
||||
@@ -445,10 +455,7 @@ function print_choose_qtype_to_add_form($hiddenparams, array $allowedqtypes = nu
|
||||
|
||||
if ($enablejs) {
|
||||
// Add the chooser.
|
||||
$PAGE->requires->yui_module('moodle-question-chooser',
|
||||
'M.question.init_chooser',
|
||||
array(array('courseid' => $PAGE->course->id))
|
||||
);
|
||||
$PAGE->requires->yui_module('moodle-question-chooser', 'M.question.init_chooser', array(array()));
|
||||
}
|
||||
|
||||
$realqtypes = array();
|
||||
@@ -465,7 +472,7 @@ function print_choose_qtype_to_add_form($hiddenparams, array $allowedqtypes = nu
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('question', 'bank');
|
||||
echo $renderer->qbank_chooser($realqtypes, $fakeqtypes, $PAGE->course, $hiddenparams);
|
||||
return $renderer->qbank_chooser($realqtypes, $fakeqtypes, $PAGE->course, $hiddenparams);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -489,7 +496,7 @@ function create_new_question_button($categoryid, $params, $caption, $tooltip = '
|
||||
|
||||
if (!$choiceformprinted) {
|
||||
echo '<div id="qtypechoicecontainer">';
|
||||
print_choose_qtype_to_add_form(array());
|
||||
echo print_choose_qtype_to_add_form(array());
|
||||
echo "</div>\n";
|
||||
$choiceformprinted = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user