Browse Source

Fix: Multianswer questions

MOODLE_20_STABLE
Vasilis Daloukas 10 years ago
parent
commit
43a520bd2f
  1. 7
      locallib.php
  2. 16
      millionaire/play.php
  3. 4
      version.php

7
locallib.php

@ -1231,9 +1231,10 @@ function game_get_question_states(&$questions, $cmoptions, $attempt, $lastattemp
function game_sudoku_getquestions( $questionlist) function game_sudoku_getquestions( $questionlist)
{ {
global $DB; global $CFG, $DB;
// Load the questions // 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)")) { if (!$questions = $DB->get_records_select( 'question', "id IN ($questionlist)")) {
print_error( get_string( 'no_questions', 'game')); 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->qtype == 'multichoice')
{ {
if( $question->category == 8) if( $question->options->single == 0)
return game_grade_responses_multianswer( $question, $responses, $maxgrade, $answertext); return game_grade_responses_multianswer( $question, $responses, $maxgrade, $answertext);
$name = "resp{$question->id}_"; $name = "resp{$question->id}_";
$value = $responses->$name; $value = $responses->$name;
@ -1598,7 +1599,7 @@ function game_print_question( $game, $question, $context)
{ {
if( $question->qtype == 'multichoice') if( $question->qtype == 'multichoice')
{ {
if( $question->category == 8) if( $question->options->single == 0)
game_print_question_multianswer( $game, $question, $context); game_print_question_multianswer( $game, $question, $context);
else else
game_print_question_multichoice( $game, $question, $context); game_print_question_multichoice( $game, $question, $context);

16
millionaire/play.php

@ -301,14 +301,14 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona
} }
if( game_get_moodle_version() < '02.07') if( game_get_moodle_version() < '02.07')
{ {
$select = "qtype='multichoice' AND quiz='$game->quizid' ". $select = "qtype='multichoice' AND quiz='$game->quizid' AND qmo.questionid=q.id".
" AND qqi.question=q.id AND q.category=1"; " AND qqi.question=q.id";
$table = "{question} q,{quiz_question_instances} qqi"; $table = "{quiz_question_instances} qqi,{question} q, {qtype_multichoice_options} qmo";
}else }else
{ {
$select = "qtype='multichoice' AND qs.quizid='$game->quizid' ". $select = "qtype='multichoice' AND qs.quizid='$game->quizid' AND qmo.questionid=q.id".
" AND qs.questionid=q.id AND q.category=1"; " AND qs.questionid=q.id";
$table = "{question} q,{quiz_slots} qs"; $table = "{quiz_slots} qs,{question} q, {qtype_multichoice_options} qmo";
} }
}else }else
{ {
@ -324,9 +324,9 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona
$select = 'q.category in ('.implode(',', $cats).')'; $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'; $select .= ' AND hidden=0';
if( $game->shuffle or $game->quizid == 0) if( $game->shuffle or $game->quizid == 0)

4
version.php

@ -22,10 +22,10 @@ if( !isset( $plugin))
$useplugin = 2; $useplugin = 2;
$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics) $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->requires = 2010112400; // Requires Moodle 2.0
$plugin->cron = 0; // Period for cron to check this module (secs) $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) if( $useplugin != 2)
$module = $plugin; $module = $plugin;

Loading…
Cancel
Save