Browse Source

CONTRIB-4774 fix:crossword game activity throws database error

MOODLE_20_STABLE
ubuntu 11 years ago
parent
commit
2f46048aea
  1. 2
      cross/play.php
  2. 2
      cryptex/play.php
  3. 2
      hangman/play.php
  4. 6
      locallib.php
  5. 2
      snakes/play.php
  6. 4
      version.php

2
cross/play.php

@ -55,7 +55,7 @@ function game_cross_new( $game, $attemptid, &$crossm)
$infos[ $rec->answertext] = array( $game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment); $infos[ $rec->answertext] = array( $game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment);
$a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid); $a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
if(($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions r')) != false){ if(($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions AS r')) != false){
$reps[ $rec->answertext] = $rec2->r; $reps[ $rec->answertext] = $rec2->r;
} }
} }

2
cryptex/play.php

@ -52,7 +52,7 @@ function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $
$infos[ $rec->answertext] = array( $game->sourcemodule, $rec->questionid, $rec->glossaryentryid); $infos[ $rec->answertext] = array( $game->sourcemodule, $rec->questionid, $rec->glossaryentryid);
$a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid); $a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
if(($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions r')) != false){ if(($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions AS r')) != false){
$reps[ $rec->answertext] = $rec2->r; $reps[ $rec->answertext] = $rec2->r;
} }
} }

2
hangman/play.php

@ -73,7 +73,7 @@ function game_hangman_continue( $id, $game, $attempt, $hangman, $newletter, $act
$copy = false; $copy = false;
$select2 = 'gameid=? AND userid=? AND questionid=? AND glossaryentryid=?'; $select2 = 'gameid=? AND userid=? AND questionid=? AND glossaryentryid=?';
if( ($rec2 = $DB->get_record_select( 'game_repetitions', $select2, array( $game->id, $USER->id, $rec->questionid, $rec->glossaryentryid), 'id,repetitions r')) != false){ if( ($rec2 = $DB->get_record_select( 'game_repetitions', $select2, array( $game->id, $USER->id, $rec->questionid, $rec->glossaryentryid), 'id,repetitions AS r')) != false){
if( ($rec2->r < $min_num) or ($min_num == 0)){ if( ($rec2->r < $min_num) or ($min_num == 0)){
$min_num = $rec2->r; $min_num = $rec2->r;
$copy = true; $copy = true;

6
locallib.php

@ -270,7 +270,7 @@ function game_question_selectrandom( $game, $table, $select, $id_fields='id', $u
$questionid = $id; $questionid = $id;
$a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $questionid, 'glossaryentryid' => $glossaryentryid); $a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $questionid, 'glossaryentryid' => $glossaryentryid);
if( ($rec = $DB->get_record( 'game_repetitions', $a, 'id,repetitions r')) != false){ if( ($rec = $DB->get_record( 'game_repetitions', $a, 'id,repetitions AS r')) != false){
if( ($rec->r < $min_num) or ($min_num == 0)){ if( ($rec->r < $min_num) or ($min_num == 0)){
$min_num = $rec->r; $min_num = $rec->r;
$min_id = $id; $min_id = $id;
@ -295,7 +295,7 @@ function game_update_repetitions( $gameid, $userid, $questionid, $glossaryentryi
global $DB; global $DB;
$a = array( 'gameid' => $gameid, 'userid' => $userid, 'questionid' => $questionid, 'glossaryentryid' => $glossaryentryid); $a = array( 'gameid' => $gameid, 'userid' => $userid, 'questionid' => $questionid, 'glossaryentryid' => $glossaryentryid);
if( ($rec = $DB->get_record( 'game_repetitions', $a, 'id,repetitions r')) != false){ if( ($rec = $DB->get_record( 'game_repetitions', $a, 'id,repetitions AS r')) != false){
$updrec = new stdClass(); $updrec = new stdClass();
$updrec->id = $rec->id; $updrec->id = $rec->id;
$updrec->repetitions = $rec->r + 1; $updrec->repetitions = $rec->r + 1;
@ -1480,7 +1480,7 @@ function game_select_from_repetitions( $game, $recs, $need){
foreach( $recs as $rec){ foreach( $recs as $rec){
$a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid); $a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
$id = $rec->$field; $id = $rec->$field;
if( ($rec = $DB->get_record( 'game_repetitions', $a, 'id,repetitions r')) != false){ if( ($rec = $DB->get_record( 'game_repetitions', $a, 'id,repetitions AS r')) != false){
$reps[ $id] = $rec->r; $reps[ $id] = $rec->r;
}else }else
{ {

2
snakes/play.php

@ -170,7 +170,7 @@ function game_snakes_computenextquestion( $game, &$snakes, &$query)
$query = new stdClass(); $query = new stdClass();
foreach( $recs as $rec){ foreach( $recs as $rec){
$a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid); $a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
if(($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions r')) != false){ if(($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions AS r')) != false){
if( ($rec2->r < $min_num) or ($min_num == 0)){ if( ($rec2->r < $min_num) or ($min_num == 0)){
$min_num = $rec2->r; $min_num = $rec2->r;
$query->glossaryentryid = $rec->glossaryentryid; $query->glossaryentryid = $rec->glossaryentryid;

4
version.php

@ -11,7 +11,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$module->component = 'mod_game'; // Full name of the plugin (used for diagnostics) $module->component = 'mod_game'; // Full name of the plugin (used for diagnostics)
$module->version = 2013122501; // The current module version (Date: YYYYMMDDXX) $module->version = 2013122502; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2010112400; // Requires Moodle 2.0 $module->requires = 2010112400; // Requires Moodle 2.0
$module->cron = 0; // Period for cron to check this module (secs) $module->cron = 0; // Period for cron to check this module (secs)
$module->release = '3.12.25'; $module->release = '3.12.25.2';

Loading…
Cancel
Save