Browse Source

Fix MariaDB compatibility

MOODLE_20_STABLE
Vasilis Daloukas 8 years ago
parent
commit
e0d4367d99
  1. 18
      cryptex/cryptexdb_class.php
  2. 2
      cryptex/play.php
  3. 8
      db/importsnakes.php
  4. 4
      export/exporthtml_snakes.php
  5. 2
      locallib.php
  6. 2
      version.php

18
cryptex/cryptexdb_class.php

@ -75,9 +75,9 @@ class CryptexDB extends CrossDB {
*/ */
public function computeletters( $crossm, $crossd) { public function computeletters( $crossm, $crossd) {
$letters = ''; $letters = '';
$cols = $crossm->cols + 1; $cols = $crossm->usedcols + 1;
$letters = str_repeat('.', $crossm->cols).'#'; $letters = str_repeat('.', $crossm->usedcols).'#';
$letters = str_repeat($letters, $crossm->rows); $letters = str_repeat($letters, $crossm->usedrows);
$freqs1 = array(); $freqs1 = array();
$count1 = $count2 = 0; $count1 = $count2 = 0;
@ -115,16 +115,16 @@ class CryptexDB extends CrossDB {
if ($step == 1) { if ($step == 1) {
$step = 2; $step = 2;
$i = array_rand( $freqs1); $i = array_rand( $freqs1);
$this->insertchar( $letters, $crossm->cols, $crossm->rows, $freqs1[ $i], $spaces); $this->insertchar( $letters, $crossm->usedcols, $crossm->usedrows, $freqs1[ $i], $spaces);
} else { } else {
$step = 1; $step = 1;
$i = array_rand( $freqs2); $i = array_rand( $freqs2);
$this->insertchars( $letters, $crossm->cols, $crossm->rows, $freqs2[ $i], $spaces); $this->insertchars( $letters, $crossm->usedcols, $crossm->usedrows, $freqs2[ $i], $spaces);
} }
} }
$retletters = ""; $retletters = "";
for ($row = 0; $row < $crossm->rows; $row++) { for ($row = 0; $row < $crossm->usedrows; $row++) {
$retletters .= game_substr( $letters, $cols * $row, ($cols - 1)); $retletters .= game_substr( $letters, $cols * $row, ($cols - 1));
} }
@ -246,7 +246,7 @@ class CryptexDB extends CrossDB {
$questions = array(); $questions = array();
$corrects = array(); $corrects = array();
$mask = str_repeat( '0', $crossm->cols * $crossm->rows); $mask = str_repeat( '0', $crossm->usedcols * $crossm->usedrows);
if ($recs = $DB->get_records( 'game_queries', array( 'attemptid' => $crossm->id))) { if ($recs = $DB->get_records( 'game_queries', array( 'attemptid' => $crossm->id))) {
foreach ($recs as $rec) { foreach ($recs as $rec) {
@ -257,7 +257,7 @@ class CryptexDB extends CrossDB {
$questions[ $key] = $rec; $questions[ $key] = $rec;
$word = $rec->answertext; $word = $rec->answertext;
$pos = $crossm->cols * ($rec->row - 1) + ($rec->col - 1); $pos = $crossm->usedcols * ($rec->row - 1) + ($rec->col - 1);
$len = game_strlen( $word); $len = game_strlen( $word);
$found = ($rec->answertext == $rec->studentanswer); $found = ($rec->answertext == $rec->studentanswer);
@ -268,7 +268,7 @@ class CryptexDB extends CrossDB {
game_setchar( $mask, $pos, $c); game_setchar( $mask, $pos, $c);
} }
$pos += ($rec->horizontal ? 1 : $crossm->cols); $pos += ($rec->horizontal ? 1 : $crossm->usedcols);
} }
if ($found) { if ($found) {

2
cryptex/play.php

@ -277,7 +277,7 @@ width: 240pt;
echo '<table border=0>'; echo '<table border=0>';
echo '<tr><td>'; echo '<tr><td>';
$cryptex->displaycryptex( $crossm->cols, $crossm->rows, $cryptexrec->letters, $mask, $showsolution, $textdir); $cryptex->displaycryptex( $crossm->usedcols, $crossm->usedrows, $cryptexrec->letters, $mask, $showsolution, $textdir);
?> ?>
</td> </td>

8
db/importsnakes.php

@ -39,8 +39,8 @@ function game_importsnakes() {
$newrec = new stdClass(); $newrec = new stdClass();
$newrec->name = '8x8 - 4 Snakes - 4 Ladders'; $newrec->name = '8x8 - 4 Snakes - 4 Ladders';
$newrec->cols = 8; $newrec->usedcols = 8;
$newrec->rows = 8; $newrec->usedrows = 8;
$newrec->fileboard = 'fidaki.jpg'; $newrec->fileboard = 'fidaki.jpg';
$newrec->direction = 1; $newrec->direction = 1;
$newrec->headerx = 4; $newrec->headerx = 4;
@ -54,8 +54,8 @@ function game_importsnakes() {
$newrec = new stdClass(); $newrec = new stdClass();
$newrec->name = '6x6 - 3 Snakes - 3 Ladders'; $newrec->name = '6x6 - 3 Snakes - 3 Ladders';
$newrec->cols = 6; $newrec->usedcols = 6;
$newrec->rows = 6; $newrec->usedrows = 6;
$newrec->fileboard = 'fidaki2.jpg'; $newrec->fileboard = 'fidaki2.jpg';
$newrec->direction = 1; $newrec->direction = 1;
$newrec->headerx = 8; $newrec->headerx = 8;

4
export/exporthtml_snakes.php

@ -100,8 +100,8 @@ var quest_total = 25; // Count of questions
board_images[ 0] = '<?php echo $board->fileboard; ?>'; board_images[ 0] = '<?php echo $board->fileboard; ?>';
board_names[ 0] = "<?php echo $game->name; ?>"; board_names[ 0] = "<?php echo $game->name; ?>";
board_cols [0] = <?php echo $board->cols; ?>; board_cols [0] = <?php echo $board->usedcols; ?>;
board_rows [0] = <?php echo $board->rows; ?>; board_rows [0] = <?php echo $board->usedrows; ?>;
board_contents [0] = '<?php echo $board->data; ?>'; board_contents [0] = '<?php echo $board->data; ?>';
board_headerx [0] = <?php echo $board->headerx; ?>; board_headerx [0] = <?php echo $board->headerx; ?>;
board_headery [0] = <?php echo $board->headery; ?>; board_headery [0] = <?php echo $board->headery; ?>;

2
locallib.php

@ -2078,7 +2078,7 @@ function game_snakes_create_user_defined_board( &$game) {
if ($f === false) { if ($f === false) {
print_error( 'No image specified'); print_error( 'No image specified');
} }
$im = game_createsnakesboard($f->get_content(), $board->cols, $board->rows, $board->headery, $board->headery, $im = game_createsnakesboard($f->get_content(), $board->usedcols, $board->usedrows, $board->headery, $board->headery,
$board->footerx, $board->headerx, $board->data, $board->width, $board->height); $board->footerx, $board->headerx, $board->data, $board->width, $board->height);
ob_start(); ob_start();
imagepng($im); imagepng($im);

2
version.php

@ -35,7 +35,7 @@ if (!isset( $plugin)) {
} }
$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 = 2017062701; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2017062702; // 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 = '2017-06-20'; $plugin->release = '2017-06-20';

Loading…
Cancel
Save