Permalink
Browse files

Updates that make it possible to override the options queries

This makes it easier to use this question type as the virtual question type for dataset dependent question types
  • Loading branch information...
1 parent b0a02eb commit f7dea937e6a7437d70046dca0d15d9e5d937037d kaipe committed Aug 4, 2004
Showing with 19 additions and 4 deletions.
  1. +19 −4 mod/quiz/questiontypes/multianswer/questiontype.php
@@ -16,6 +16,10 @@
class quiz_embedded_cloze_qtype extends quiz_default_questiontype {
function get_answers($question) {
+ // This function is not used by any other function within this class.
+ // It is possible that it is used by some report that uses the
+ // function quiz_get_answers in lib.php
+
/// The returned answers includes subanswers...
// As this question type embedds some other question types,
// it is necessary to have access to those:
@@ -39,6 +43,18 @@ function get_answers($question) {
return $answers;
}
+ function get_position_multianswer($questionid, $positionkey) {
+ // As a separate function in order to make it overridable
+
+ return get_record('quiz_multianswers', 'question', $questionid,
+ 'positionkey', $positionkey);
+ }
+
+ function get_multianswers($questionid) {
+ // As a separate function in order to make it overridable
+ return get_records('quiz_multianswers', 'question', $questionid);
+ }
+
function name() {
return 'multianswer';
}
@@ -203,8 +219,8 @@ function print_question_formulation_and_controls($question,
echo $qtextsplits[0];
$qtextremaining = $qtextsplits[1];
- $multianswer = get_record('quiz_multianswers', 'question',
- $question->id, 'positionkey', $regs[1]);
+ $multianswer = $this->get_position_multianswer($question->id, $regs[1]);
+
$inputname = $nameprefix.$multianswer->id;
$response = isset($question->response[$inputname])
? $question->response[$inputname] : '';
@@ -277,8 +293,7 @@ function grade_response($question, $nameprefix) {
$result->answers = array();
$result->correctanswers = array();
- $multianswers = get_records('quiz_multianswers',
- 'question', $question->id);
+ $multianswers = $this->get_multianswers($question->id);
// Default settings:
$subquestion->id = $question->id;
$normsum = 0;

0 comments on commit f7dea93

Please sign in to comment.