diff --git a/locallib.php b/locallib.php index 9300dc6..788653b 100755 --- a/locallib.php +++ b/locallib.php @@ -160,9 +160,17 @@ function game_question_shortanswer_quiz( $game, $allowspaces, $use_repetitions) print_error( get_string( 'must_select_quiz', 'game')); } - $select = "qtype='shortanswer' AND quiz='$game->quizid' ". + if( game_get_moodle_version() < '02.07') + { + $select = "qtype='shortanswer' AND quiz='$game->quizid' ". " AND qqi.question=q.id"; - $table = "{question} q,{quiz_question_instances} qqi"; + $table = "{question} q,{quiz_question_instances} qqi"; + }else + { + $select = "qtype='shortanswer' AND qs.quizid='$game->quizid' ". + " AND qs.questionid=q.id"; + $table = "{question} q,{quiz_slots} qs"; + } $fields = "q.id"; if( ($id = game_question_selectrandom( $game, $table, $select, $fields, $use_repetitions)) == false) @@ -337,12 +345,23 @@ function game_questions_selectrandom( $game, $count=1) if( $game->quizid == 0){ print_error( get_string( 'must_select_quiz', 'game')); } - - $table = '{question} q, {quiz_question_instances} qqi'; - $select = " qqi.quiz=$game->quizid". - " AND qqi.question=q.id ". - " AND q.qtype in ('shortanswer', 'truefalse', 'multichoice')". - " AND q.hidden=0"; + + if( game_get_moodle_version() < '02.07') + { + $table = '{question} q, {quiz_question_instances} qqi'; + $select = " qqi.quiz=$game->quizid". + " AND qqi.question=q.id ". + " AND q.qtype in ('shortanswer', 'truefalse', 'multichoice')". + " AND q.hidden=0"; + }else + { + + $table = '{question} q, {quiz_slots} qs'; + $select = " qs.quizid=$game->quizid". + " AND qs.questionid=q.id ". + " AND q.qtype in ('shortanswer', 'truefalse', 'multichoice')". + " AND q.hidden=0"; + } //todo 'match' $field = "q.id as id"; @@ -561,14 +580,27 @@ function game_questions_shortanswer_quiz( $game) print_error( get_string( 'must_select_quiz', 'game')); } - $select = "qtype='shortanswer' AND quiz='$game->quizid' ". + if( game_get_moodle_version() < '02.07') + { + $select = "qtype='shortanswer' AND quiz='$game->quizid' ". " AND qqi.question=q.id". " AND qa.question=q.id". " AND q.hidden=0"; - $table = "{question} q,{quiz_question_instances} qqi,{question_answers} qa"; - $fields = "qa.id as qaid, q.id, q.questiontext as questiontext, ". + $table = "{question} q,{quiz_question_instances} qqi,{question_answers} qa"; + $fields = "qa.id as qaid, q.id, q.questiontext as questiontext, ". + "qa.answer as answertext, q.id as questionid,". + " 0 as glossaryentryid,'' as attachment"; + }else + { + $select = "qtype='shortanswer' AND qs.quizid='$game->quizid' ". + " AND qs.questionid=q.id". + " AND qa.question=q.id". + " AND q.hidden=0"; + $table = "{question} q,{quiz_slots} qs,{question_answers} qa"; + $fields = "qa.id as qaid, q.id, q.questiontext as questiontext, ". "qa.answer as answertext, q.id as questionid,". " 0 as glossaryentryid,'' as attachment"; + } return game_questions_shortanswer_question_fraction( $table, $fields, $select); } diff --git a/millionaire/play.php b/millionaire/play.php index d0029d1..659e660 100755 --- a/millionaire/play.php +++ b/millionaire/play.php @@ -298,10 +298,18 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona if( $game->sourcemodule == 'quiz'){ if( $game->quizid == 0){ print_error( get_string( 'must_select_quiz', 'game')); - } - $select = "qtype='multichoice' AND quiz='$game->quizid' ". + } + if( game_get_moodle_version() < '02.07') + { + $select = "qtype='multichoice' AND quiz='$game->quizid' ". " AND qqi.question=q.id"; - $table = "{question} q,{quiz_question_instances} qqi"; + $table = "{question} q,{quiz_question_instances} qqi"; + }else + { + $select = "qtype='multichoice' AND qs.quizid='$game->quizid' ". + " AND qs.questionid=q.id"; + $table = "{question} q,{quiz_slots} qs"; + } }else { if( $game->questioncategoryid == 0){ diff --git a/version.php b/version.php index 88c30b1..e96940c 100755 --- a/version.php +++ b/version.php @@ -11,7 +11,7 @@ defined('MOODLE_INTERNAL') || die(); $module->component = 'mod_game'; // Full name of the plugin (used for diagnostics) -$module->version = 2014061003; // The current module version (Date: YYYYMMDDXX) +$module->version = 2014061101; // The current module version (Date: YYYYMMDDXX) $module->requires = 2010112400; // Requires Moodle 2.0 $module->cron = 0; // Period for cron to check this module (secs) -$module->release = '3.18.10.3'; +$module->release = '3.18.11';