From 43a520bd2fec1b4dd145979c604a2f0aa546d9a1 Mon Sep 17 00:00:00 2001 From: Vasilis Daloukas Date: Wed, 15 Jul 2015 13:09:17 +0300 Subject: [PATCH] Fix: Multianswer questions --- locallib.php | 7 ++++--- millionaire/play.php | 16 ++++++++-------- version.php | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/locallib.php b/locallib.php index 5621612..f878b75 100755 --- a/locallib.php +++ b/locallib.php @@ -1231,9 +1231,10 @@ function game_get_question_states(&$questions, $cmoptions, $attempt, $lastattemp function game_sudoku_getquestions( $questionlist) { - global $DB; + global $CFG, $DB; // Load the questions + $sql = "SELECT q.*,qmo.single FROM {$CFG->prefix}question LEFT JOIN {$CFG->prefix}qtype_multichoice_options qmo ON q.id=qmo.questionid AND q.qtype='multichoice' WHERE q.id IN ($questionlist)"; if (!$questions = $DB->get_records_select( 'question', "id IN ($questionlist)")) { print_error( get_string( 'no_questions', 'game')); } @@ -1550,7 +1551,7 @@ function game_grade_responses( $question, $responses, $maxgrade, &$answertext) { if( $question->qtype == 'multichoice') { - if( $question->category == 8) + if( $question->options->single == 0) return game_grade_responses_multianswer( $question, $responses, $maxgrade, $answertext); $name = "resp{$question->id}_"; $value = $responses->$name; @@ -1598,7 +1599,7 @@ function game_print_question( $game, $question, $context) { if( $question->qtype == 'multichoice') { - if( $question->category == 8) + if( $question->options->single == 0) game_print_question_multianswer( $game, $question, $context); else game_print_question_multichoice( $game, $question, $context); diff --git a/millionaire/play.php b/millionaire/play.php index 5f3536a..b8f88fd 100755 --- a/millionaire/play.php +++ b/millionaire/play.php @@ -301,14 +301,14 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona } if( game_get_moodle_version() < '02.07') { - $select = "qtype='multichoice' AND quiz='$game->quizid' ". - " AND qqi.question=q.id AND q.category=1"; - $table = "{question} q,{quiz_question_instances} qqi"; + $select = "qtype='multichoice' AND quiz='$game->quizid' AND qmo.questionid=q.id". + " AND qqi.question=q.id"; + $table = "{quiz_question_instances} qqi,{question} q, {qtype_multichoice_options} qmo"; }else { - $select = "qtype='multichoice' AND qs.quizid='$game->quizid' ". - " AND qs.questionid=q.id AND q.category=1"; - $table = "{question} q,{quiz_slots} qs"; + $select = "qtype='multichoice' AND qs.quizid='$game->quizid' AND qmo.questionid=q.id". + " AND qs.questionid=q.id"; + $table = "{quiz_slots} qs,{question} q, {qtype_multichoice_options} qmo"; } }else { @@ -324,9 +324,9 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona $select = 'q.category in ('.implode(',', $cats).')'; } } - $select .= " AND qtype='multichoice' AND category=1"; + $select .= " AND qtype='multichoice' AND qmo.single=1 AND qmo.questionid=q.id"; - $table = '{question} q'; + $table = '{question} q, {qtype_multichoice_options} qmo'; } $select .= ' AND hidden=0'; if( $game->shuffle or $game->quizid == 0) diff --git a/version.php b/version.php index cafd8fd..b6873ad 100755 --- a/version.php +++ b/version.php @@ -22,10 +22,10 @@ if( !isset( $plugin)) $useplugin = 2; $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics) -$plugin->version = 20150715; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2015071502; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2010112400; // Requires Moodle 2.0 $plugin->cron = 0; // Period for cron to check this module (secs) -$plugin->release = '3.30.15'; +$plugin->release = '3.30.15.2'; if( $useplugin != 2) $module = $plugin;