From e0d4367d994c42df89530ff8f3cb56515b336acc Mon Sep 17 00:00:00 2001 From: Vasilis Daloukas Date: Tue, 27 Jun 2017 10:37:37 +0300 Subject: [PATCH] Fix MariaDB compatibility --- cryptex/cryptexdb_class.php | 18 +++++++++--------- cryptex/play.php | 2 +- db/importsnakes.php | 8 ++++---- export/exporthtml_snakes.php | 4 ++-- locallib.php | 2 +- version.php | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cryptex/cryptexdb_class.php b/cryptex/cryptexdb_class.php index 3779a0e..41e9b77 100644 --- a/cryptex/cryptexdb_class.php +++ b/cryptex/cryptexdb_class.php @@ -75,9 +75,9 @@ class CryptexDB extends CrossDB { */ public function computeletters( $crossm, $crossd) { $letters = ''; - $cols = $crossm->cols + 1; - $letters = str_repeat('.', $crossm->cols).'#'; - $letters = str_repeat($letters, $crossm->rows); + $cols = $crossm->usedcols + 1; + $letters = str_repeat('.', $crossm->usedcols).'#'; + $letters = str_repeat($letters, $crossm->usedrows); $freqs1 = array(); $count1 = $count2 = 0; @@ -115,16 +115,16 @@ class CryptexDB extends CrossDB { if ($step == 1) { $step = 2; $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 { $step = 1; $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 = ""; - for ($row = 0; $row < $crossm->rows; $row++) { + for ($row = 0; $row < $crossm->usedrows; $row++) { $retletters .= game_substr( $letters, $cols * $row, ($cols - 1)); } @@ -246,7 +246,7 @@ class CryptexDB extends CrossDB { $questions = 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))) { foreach ($recs as $rec) { @@ -257,7 +257,7 @@ class CryptexDB extends CrossDB { $questions[ $key] = $rec; $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); $found = ($rec->answertext == $rec->studentanswer); @@ -268,7 +268,7 @@ class CryptexDB extends CrossDB { game_setchar( $mask, $pos, $c); } - $pos += ($rec->horizontal ? 1 : $crossm->cols); + $pos += ($rec->horizontal ? 1 : $crossm->usedcols); } if ($found) { diff --git a/cryptex/play.php b/cryptex/play.php index 789c95c..87c2152 100644 --- a/cryptex/play.php +++ b/cryptex/play.php @@ -277,7 +277,7 @@ width: 240pt; echo ''; echo ' diff --git a/db/importsnakes.php b/db/importsnakes.php index e64e827..2b10878 100644 --- a/db/importsnakes.php +++ b/db/importsnakes.php @@ -39,8 +39,8 @@ function game_importsnakes() { $newrec = new stdClass(); $newrec->name = '8x8 - 4 Snakes - 4 Ladders'; - $newrec->cols = 8; - $newrec->rows = 8; + $newrec->usedcols = 8; + $newrec->usedrows = 8; $newrec->fileboard = 'fidaki.jpg'; $newrec->direction = 1; $newrec->headerx = 4; @@ -54,8 +54,8 @@ function game_importsnakes() { $newrec = new stdClass(); $newrec->name = '6x6 - 3 Snakes - 3 Ladders'; - $newrec->cols = 6; - $newrec->rows = 6; + $newrec->usedcols = 6; + $newrec->usedrows = 6; $newrec->fileboard = 'fidaki2.jpg'; $newrec->direction = 1; $newrec->headerx = 8; diff --git a/export/exporthtml_snakes.php b/export/exporthtml_snakes.php index f911351..a14be66 100644 --- a/export/exporthtml_snakes.php +++ b/export/exporthtml_snakes.php @@ -100,8 +100,8 @@ var quest_total = 25; // Count of questions board_images[ 0] = 'fileboard; ?>'; board_names[ 0] = "name; ?>"; -board_cols [0] = cols; ?>; -board_rows [0] = rows; ?>; +board_cols [0] = usedcols; ?>; +board_rows [0] = usedrows; ?>; board_contents [0] = 'data; ?>'; board_headerx [0] = headerx; ?>; board_headery [0] = headery; ?>; diff --git a/locallib.php b/locallib.php index 0c0ca52..9581374 100644 --- a/locallib.php +++ b/locallib.php @@ -2078,7 +2078,7 @@ function game_snakes_create_user_defined_board( &$game) { if ($f === false) { 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); ob_start(); imagepng($im); diff --git a/version.php b/version.php index 409aea6..b882031 100644 --- a/version.php +++ b/version.php @@ -35,7 +35,7 @@ if (!isset( $plugin)) { } $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->cron = 0; // Period for cron to check this module (secs). $plugin->release = '2017-06-20';
'; - $cryptex->displaycryptex( $crossm->cols, $crossm->rows, $cryptexrec->letters, $mask, $showsolution, $textdir); + $cryptex->displaycryptex( $crossm->usedcols, $crossm->usedrows, $cryptexrec->letters, $mask, $showsolution, $textdir); ?>