Commit 5c03acf5 authored by David Monllaó's avatar David Monllaó
Browse files

Merge branch 'MDL-51048_28' of git://github.com/timhunt/moodle into MOODLE_28_STABLE

parents 8d5092cd f558ddcc
......@@ -27,8 +27,18 @@ class cc_assesment_question_truefalse extends cc_assesment_question_proc_base {
public function __construct($quiz, $questions, $manifest, $section, $question_node, $rootpath, $contextid, $outdir) {
parent::__construct($quiz, $questions, $manifest, $section, $question_node, $rootpath, $contextid, $outdir);
$this->qtype = cc_qti_profiletype::true_false;
$this->correct_answer_node_id = $this->questions->nodeValue(
'plugin_qtype_truefalse_question/truefalse/trueanswer', $this->question_node);
// Determine the correct answer by finding out which answer has the non zero fraction...
// This is because a true / false question type can have 'false' as the correct answer.
$answers = $this->questions->nodeList('plugin_qtype_truefalse_question/answers/answer', $this->question_node);
foreach ($answers as $answer) {
$fraction = $this->questions->nodeValue('fraction', $answer);
if ($fraction != 0) {
$this->correct_answer_node_id = (int)$this->questions->nodeValue('@id', $answer);
}
}
$maximum_quiz_grade = (int)$this->quiz->nodeValue('/activity/quiz/grade');
$this->total_grade_value = ($maximum_quiz_grade + 1).'.0000000';
}
......
......@@ -886,26 +886,30 @@ class cc_quiz extends entities {
$sheet_question_categories_question = cc2moodle::loadsheet(SHEET_COURSE_QUESTION_CATEGORIES_QUESTION_CATEGORY_QUESTION_TRUE_FALSE);
$max_score = 0;
$true_answer_id = 0;
$false_answer_id = 0;
$trueanswer = null;
$falseanswer = null;
if (!empty($question['answers'])) {
// Identify the true and false answers.
foreach ($question['answers'] as $answer) {
if ($answer['score'] > $max_score) {
$max_score = $answer['score'];
$true_answer_id = $answer['id'];
if ($answer['identifier'] == 'true') {
$trueanswer = $answer;
} else if ($answer['identifier'] == 'false') {
$falseanswer = $answer;
} else {
// Should not happen, but just in case.
throw new coding_exception("Unknown answer identifier detected" .
" in true/false quiz question with id {$question['id']}.");
}
$node_course_question_categories_question_answer .= $this->create_node_course_question_categories_question_category_question_answer($answer);
}
foreach ($question['answers'] as $answer) {
if ($answer['id'] != $true_answer_id) {
$max_score = $answer['score'];
$false_answer_id = $answer['id'];
}
// Make sure the true and false answer was found.
if (is_null($trueanswer) || is_null($falseanswer)) {
throw new coding_exception("Unable to correctly identify the " .
"true and false answers in the question with id {$question['id']}.");
}
}
......@@ -914,8 +918,8 @@ class cc_quiz extends entities {
'[#false_answer_id#]');
$replace_values = array($node_course_question_categories_question_answer,
$true_answer_id,
$false_answer_id);
$trueanswer['id'],
$falseanswer['id']);
$node_question_categories_question = str_replace($find_tags, $replace_values, $sheet_question_categories_question);
......
......@@ -909,26 +909,30 @@ class cc11_quiz extends entities11 {
$sheet_question_categories_question = cc112moodle::loadsheet(SHEET_COURSE_QUESTION_CATEGORIES_QUESTION_CATEGORY_QUESTION_TRUE_FALSE);
$max_score = 0;
$true_answer_id = 0;
$false_answer_id = 0;
$trueanswer = null;
$falseanswer = null;
if (!empty($question['answers'])) {
// Identify the true and false answers.
foreach ($question['answers'] as $answer) {
if ($answer['score'] > $max_score) {
$max_score = $answer['score'];
$true_answer_id = $answer['id'];
if ($answer['identifier'] == 'true') {
$trueanswer = $answer;
} else if ($answer['identifier'] == 'false') {
$falseanswer = $answer;
} else {
// Should not happen, but just in case.
throw new coding_exception("Unknown answer identifier detected " .
"in true/false quiz question with id {$question['id']}.");
}
$node_course_question_categories_question_answer .= $this->create_node_course_question_categories_question_category_question_answer($answer);
}
foreach ($question['answers'] as $answer) {
if ($answer['id'] != $true_answer_id) {
$max_score = $answer['score'];
$false_answer_id = $answer['id'];
}
// Make sure the true and false answer was found.
if (is_null($trueanswer) || is_null($falseanswer)) {
throw new coding_exception("Unable to correctly identify the " .
"true and false answers in the question with id {$question['id']}.");
}
}
......@@ -937,8 +941,8 @@ class cc11_quiz extends entities11 {
'[#false_answer_id#]');
$replace_values = array($node_course_question_categories_question_answer,
$true_answer_id,
$false_answer_id);
$trueanswer['id'],
$falseanswer['id']);
$node_question_categories_question = str_replace($find_tags, $replace_values, $sheet_question_categories_question);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment