diff --git a/millionaire/play.php b/millionaire/play.php index b8f88fd..13ef6df 100755 --- a/millionaire/play.php +++ b/millionaire/play.php @@ -304,11 +304,13 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona $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"; + $order = ''; }else { $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"; + $order = 'qs.page,qs.slot'; } }else { @@ -332,7 +334,7 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona if( $game->shuffle or $game->quizid == 0) $questionid = game_question_selectrandom( $game, $table, $select, 'q.id as id', true); else - $questionid = game_millionaire_select_serial_question( $game, $table, $select, 'q.id as id', $millionaire->level); + $questionid = game_millionaire_select_serial_question( $game, $table, $select, 'q.id as id', $millionaire->level, $order); if( $questionid == 0){ print_error( get_string( 'no_questions', 'game')); @@ -397,28 +399,19 @@ function game_millionaire_SelectQuestion( &$aAnswer, $game, $attempt, &$milliona game_update_queries( $game, $attempt, $query, $score, ''); } -function game_millionaire_select_serial_question( $game, $table, $select, $id_fields="id", $level) +function game_millionaire_select_serial_question( $game, $table, $select, $id_fields="id", $level, $order) { global $DB, $USER; - if( $game->sourcemodule == 'quiz') - { - $rec = $DB->get_record( 'quiz', array( 'id' => $game->quizid)); - if( $rec === false) - return false; - - $questions = $rec->questions; - $questions = explode( ',', $rec->questions); - array_pop( $questions); - }else - { - $sql = "SELECT $id_fields,$id_fields FROM ".$table." WHERE $select ORDER BY q.name"; - if( ($recs = $DB->get_records_sql( $sql)) == false) - return false; - $questions = array(); - foreach( $recs as $rec) - $questions[] = $rec->id; - } + $sql = "SELECT $id_fields,$id_fields FROM ".$table." WHERE $select "; + if( $order != '') + $sql .= " ORDER BY $order"; + + if( ($recs = $DB->get_records_sql( $sql)) == false) + return false; + $questions = array(); + foreach( $recs as $rec) + $questions[] = $rec->id; $count = count( $questions); if( $count == 0) diff --git a/version.php b/version.php index 022ae53..d7c41b7 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 = 2015071503; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2015071504; // 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.3'; +$plugin->release = '3.30.15.4'; if( $useplugin != 2) $module = $plugin;