Skip to content

Commit

Permalink
Updates that make it possible to override the options queries
Browse files Browse the repository at this point in the history
This makes it easier to use this question type as the virtual question type for dataset dependent question types
  • Loading branch information
kaipe committed Aug 4, 2004
1 parent b0a02eb commit f7dea93
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions mod/quiz/questiontypes/multianswer/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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';
}
Expand Down Expand Up @@ -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] : '';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f7dea93

Please sign in to comment.