From 593362a22e278d80a6b0488491a2fe0253cd2462 Mon Sep 17 00:00:00 2001 From: Vasilis Daloukas Date: Mon, 28 Dec 2015 00:05:28 +0200 Subject: [PATCH] Fix:Coding style --- cross/cross_class.php | 8 ++++---- cross/crossdb_class.php | 4 ++-- cross/play.php | 4 ++-- cryptex/play.php | 2 +- db/importsudoku.php | 15 +++++++-------- hiddenpicture/picture.php | 2 +- hiddenpicture/play.php | 1 + locallib.php | 8 +++++++- millionaire/play.php | 4 ++-- snakes/play.php | 2 +- sudoku/class.Sudoku.php | 32 ++++++++++++++++---------------- sudoku/play.php | 7 +++++-- 12 files changed, 49 insertions(+), 40 deletions(-) diff --git a/cross/cross_class.php b/cross/cross_class.php index e556ef7..457623c 100755 --- a/cross/cross_class.php +++ b/cross/cross_class.php @@ -96,8 +96,8 @@ class Cross $this->mn20min = $this->mn20max; } - $this->m_words = array(); - foreach ($this->m_input_answers as $word => $answer) { + $this->mwords = array(); + foreach ($this->minputanswers as $word => $answer) { $len = game_strlen( $word); if ($len <= $this->mn20max) { @@ -218,7 +218,7 @@ class Cross if ($score > $this->mbestscore) { $this->mbestcrosspos = $crosspos; - $this->m_best_cross_dir = $crossdir; + $this->mbestcrossdir = $crossdir; $this->mbestcrossword = $crossword; $this->mbestpuzzle = $puzzle; @@ -622,7 +622,7 @@ class Cross $ssolutions = ''; $shtmlsolutions = ''; $swordx = ""; - $ssordy = ""; + $swordy = ""; $sclue = ""; $lasthorizontalword = -1; $i = -1; diff --git a/cross/crossdb_class.php b/cross/crossdb_class.php index 4b6660a..286ac6e 100755 --- a/cross/crossdb_class.php +++ b/cross/crossdb_class.php @@ -85,12 +85,12 @@ class CrossDB extends Cross { $this->mmaxrow = $crossrec->rows; if ($g == "") { - $g = str_repeat( ' ', $this->m_maxcol * $this->m_maxrow); + $g = str_repeat( ' ', $this->mmaxcol * $this->mmaxrow); } $load = false; - $puzzle = str_repeat('.', $this->m_maxrow * $this->m_maxcol); + $puzzle = str_repeat('.', $this->mmaxrow * $this->mmaxcol); if ($recs = $DB->get_records( 'game_queries', array( 'attemptid' => $crossrec->id))) { $a = array(); foreach ($recs as $rec) { diff --git a/cross/play.php b/cross/play.php index 43bd043..326ac18 100755 --- a/cross/play.php +++ b/cross/play.php @@ -1146,7 +1146,7 @@ function game_cross_show_welcome1() { function game_cross_show_legends( $cross) { echo ''; - ShowLegend( $cross->m_LegendH, get_string( 'cross_across', 'game')); - ShowLegend( $cross->m_LegendV, get_string( 'cross_down', 'game')); + ShowLegend( $cross->mlegendh, get_string( 'cross_across', 'game')); + ShowLegend( $cross->mlegendv, get_string( 'cross_down', 'game')); echo ''; } diff --git a/cryptex/play.php b/cryptex/play.php index 8375d2a..d9b88a5 100755 --- a/cryptex/play.php +++ b/cryptex/play.php @@ -32,7 +32,7 @@ function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $ $endofgame = false; } - if $attempt != false and $cryptexrec != false) { + if( $attempt != false and $cryptexrec != false) { $crossm = $DB->get_record( 'game_cross', array( 'id' => $attempt->id)); return game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm, false, false, false, $context); } diff --git a/db/importsudoku.php b/db/importsudoku.php index c3b1f62..cdc93f5 100755 --- a/db/importsudoku.php +++ b/db/importsudoku.php @@ -213,7 +213,7 @@ $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES ( "'IEB14368GG34H56A298F17IB354375819DB69FB47E38114HF2C9752317FH59D5IG2D361H486E19BCG')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 24,". "'938FBG541AD6895732257143HI6472385A6IFHC971524519FBD378BE37I681D469218C5G7HA43E962')"); -$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 26," +$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 26,". "'36I8EA27D451B7CI8FHB79461537B81954C6534F2G1986IA43827E982F13E473A57DB8F9G6D5H9312')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 28,". "'DAB73865978645I12C395A26G84IB4E67C8AE37H12I6461H4CI57BB4E89C17F3916G52D88F72D19E3')"); @@ -289,7 +289,7 @@ $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES ( $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,". "'12E784I3FD89C62G51F3G951B84B6GD9351851482F97C8I31G54F23D2HE96716I51D7B3871H32654I')"); -$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27," +$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27,". "'163I48EG29ED2671H3278CEA4I6HE46C921773A528DIFIF27A483532A496785H75312FDI649E8G123')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 31,". "'67C1B5IDH248GF93A5IEA3DH276DIB816E376715BC894583794FA2BFA78I354D57A32I8F83946E12G')"); @@ -303,7 +303,7 @@ $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES ( "'I17528D634C8IGF21E5624A37H92E13968G4347H5A692F98274C5114B73E68I5F9AHDG2383G92F14E')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,". "'463I81B5G97H42E61CE21G3F894726HCD519389561G42DA59723F86751D839BAI42C78E62HC65I147')"); -$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27," +$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27,". "'2A47E638939F148B5G57823I16D46589C12G723FA5D8IHI1G42653F72I41E388CD5F29G19153H7DBF')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 28,". "'DHA625937756349A8B92CG1HD65A537DBH96IGD86C21528F591C4G274CF9518631528DIGHEI174632')"); @@ -417,7 +417,7 @@ $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES ( "'53H27A49FG6B49381E419F58B3GFBE9871D3378F4A5299D15237H6864G59C1223G1H4IE6A9E36B874')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 24,". "'FA4E93B783576H2ID1B98D17F3592E36G48113F8245GI7H41593F2756AC2H49D1879526392C84F57A')"); -$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27," +$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27,". "'965HA34BG72364I58AH1DE27639GEBA94638418CF59729F3782DEAB8F54I3711972C6HE43451G82I6')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27,". "'6I7841CB5DHEC9271623AE7FH49962GA45H38745639BAC1E92846747915HB3FFC82D71591526I37HD')"); @@ -444,7 +444,7 @@ $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES ( "'BE63A47H9I48FBG35A73A5982DFADE972863876513BI4329HF415743HEIG621AFE482739I72613DH5')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 30,". "'HGD19C52F3E9HB67D1F217548CIIEH362417614975BHC372DA8596281FCE749D3G198562I652D7AHC')"); -$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,".. +$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,". "'B8E1639749362GD851147589FBC752HC64I1AI8547F2343F91BH7E649E1GC2H7AB389465358264GI1')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,". "'6C72598A452H431GI69D1HFG3524HB37A59695G862ADC613D9E728I28163G45675BHD3191C457928F')"); @@ -705,7 +705,7 @@ $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES ( "'783I62DE1DA23857I6F59AG4C28519FCG2486GH12D95C2439857AF1BF89537D5492CG861837461EIB')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,". "'39158F27D6H72D91CEB4E3G1869A69742H5357C8619BD482IEC6179B86C54AGG564A239813479H52F')"); -$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25," +$DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,". "'8G1C4B569C59716DH2B6D9857ACD56I8C2178GA624593392571HDF6947BH135238165IDGAE7439628')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 27,". @@ -2387,8 +2387,7 @@ $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES ( " 'IB5C47F184H72A6953C1695H7BD5837IB46AG69148E3B2415FC8798E91C62G4F7D82E39AA32D9GF85')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 26,". " '16H92C75DB59D76A83743H1E62I3I58476AB6D2591GCH178CF2954536D81BG99273FE814DHA297536')"); -". - " + $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 25,". " 'BGD568391569A4C872381927FDE452713I8F398FEDB17GA6892534F49HC71B5731425I8FB5H16I473')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 26,". diff --git a/hiddenpicture/picture.php b/hiddenpicture/picture.php index 5e8acee..aa17a1c 100755 --- a/hiddenpicture/picture.php +++ b/hiddenpicture/picture.php @@ -109,7 +109,7 @@ function shownumber( $imghandle, $imgnumbers, $number, $x1 , $y1, $width, $heigh $srch = $sizenumbers[ 1]; $dstw = $width / 10; $dsth = $dstw * $srch / $srcw; - imagecopyresized( $imghandle, $imgnumbers, $dstx, $dsty, $srcx, 0, $dstw, $dsth, $srcw, $srchh); + imagecopyresized( $imghandle, $imgnumbers, $dstx, $dsty, $srcx, 0, $dstw, $dsth, $srcw, $srch); } else { $number1 = floor( $number / 10); $number2 = $number % 10; diff --git a/hiddenpicture/play.php b/hiddenpicture/play.php index 88ad4a3..f269574 100755 --- a/hiddenpicture/play.php +++ b/hiddenpicture/play.php @@ -140,6 +140,7 @@ function game_hiddenpicture_selectglossaryentry( $game, $attempt) { } } if (count( $ids) == 0) { + $a = new stdClass(); $a->name = "'".$DB->get_field( 'glossary', 'name', array( 'id' => $game->glossaryid2))."'"; print_error( get_string( 'hiddenpicture_nomainquestion', 'game', $a)); return false; diff --git a/locallib.php b/locallib.php index 74ca377..5a26b41 100755 --- a/locallib.php +++ b/locallib.php @@ -1517,12 +1517,18 @@ function game_select_from_repetitions( $game, $recs, $need) { return $ret; } -function game_grade_responses( $question, $responses, $maxgrade, &$answertext) { +function game_grade_responses( $question, $responses, $maxgrade, &$answertext, &$answered) { + $answered = true; + if ($question->qtype == 'multichoice') { if ($question->options->single == 0) { return game_grade_responses_multianswer( $question, $responses, $maxgrade, $answertext); } $name = "resp{$question->id}_"; + if( !isset( $responses->$name)) { + $answered = false; + return 0; + } $value = $responses->$name; $answer = $question->options->answers[ $value]; $answertext = $answer->answer; diff --git a/millionaire/play.php b/millionaire/play.php index 394af3f..401c61d 100755 --- a/millionaire/play.php +++ b/millionaire/play.php @@ -172,14 +172,14 @@ function game_millionaire_showgrid( $game, $millionaire, $id, $query, $aanswer, $styletext = "style='$stylequestion'"; } - $aval = array( 100, 200, 300, 400, 500, 1000, 1500, 2000, 4000, 5000, 10000, 20000, 40000, 80000, 150000); + $aval = array( 100, 200, 300, 400, 500, 1000, 1500, 2000, 4000, 5000, 10000, 20000, 40000, 80000, 150000); for ($i = 15; $i >= 1; $i--) { $btr = false; switch ($i) { case 15: echo "      \r\n"; + " $background>      \r\n"; $btr = true; break; case 14: diff --git a/snakes/play.php b/snakes/play.php index e1f9879..79e6c79 100755 --- a/snakes/play.php +++ b/snakes/play.php @@ -312,7 +312,7 @@ function game_snakes_check_questions( $id, $game, $attempt, $snakes, $context) { $query = new stdClass(); $query->id = $snakes->queryid; - $grade = game_grade_responses( $question, $responses, 100, $answertext); + $grade = game_grade_responses( $question, $responses, 100, $answertext, $answered); if ($grade < 99) { // Wrong answer. game_update_queries( $game, $attempt, $query, 0, $answertext); diff --git a/sudoku/class.Sudoku.php b/sudoku/class.Sudoku.php index f6da5ca..3bf96be 100755 --- a/sudoku/class.Sudoku.php +++ b/sudoku/class.Sudoku.php @@ -56,7 +56,7 @@ @require_once("SDD/class.SDD.php"); -/** +/* * @author Dick Munroe * @copyright copyright @ 2005 by Dick Munroe, Cottage Software Works, Inc. * @license http://www.csworks.com/publications/ModifiedNetBSD.html @@ -64,7 +64,7 @@ * @package Sudoku */ -/** +/* * Basic functionality needed for ObjectSs in the Sudoku solver. * * Technically speaking these aren't restricted to the Sudoku classes @@ -73,7 +73,7 @@ * @package Sudoku */ -class ObjectS { +class objects { /** * @desc Are two array's equal (have the same contents). * @param array @@ -95,11 +95,11 @@ class ObjectS { return (count($xxx) == 0); } - /** + /* * Deep copy anything. - * + * * @access public - * @param array $theArray [optional] Something to be deep copied. [Default is the current + * @param array $theArray [optional] Something to be deep copied. Default is the current * ObjectS. * @return mixed The deep copy of the input. All references embedded within * the array have been resolved into copies allowing things like the @@ -126,7 +126,7 @@ class ObjectS { } } -/** +/* * The individual cell on the Sudoku board. * * These cells aren't restricted to 9x9 Sudoku (although pretty much everything else @@ -135,7 +135,7 @@ class ObjectS { * * @package Sudoku */ -class Cell extends ObjectS { +class cell extends objects { protected $r; protected $c; @@ -226,7 +226,7 @@ class Cell extends ObjectS { } } - /** + /* * Used to make sure that solved positions show up at print time. * The value is used as a candidate for "slicing and dicing" by elimination in * Sudoku::_newSolvedPosition. @@ -240,7 +240,7 @@ class Cell extends ObjectS { $this->state = array($value => $value); } - /** + /* * @desc return the state of a cell. * @access protected * @return mixed Either solved state or array of state pending solution. @@ -250,7 +250,7 @@ class Cell extends ObjectS { return $this->state; } - /** + /* * @desc Has the state of this cell been applied to the board. * @access public * @return boolean True if it has, false otherwise. Implies that IsSolved is true as well. @@ -260,7 +260,7 @@ class Cell extends ObjectS { return $this->applied; } - /** + /* * @desc Has this cell been solved? * @access public * @return boolean True if this cell has hit a single state. @@ -270,7 +270,7 @@ class Cell extends ObjectS { return !is_array($this->state); } - /** + /* * This is used primarily by the pretty printer, but has other applications * in the code. * @@ -293,7 +293,7 @@ class Cell extends ObjectS { } } - /** + /* * This is the negative inference of Sudoku. By eliminating values the * cells approach solutions. Once a cell has been completely eliminated, * the value causing the complete elimination must be the solution and the @@ -1360,7 +1360,7 @@ class sudoku extends ObjectS { * Pick a spot on the board and get the clues set up. */ - $thechoice = mt_rand(0, count($thecouplings[$themaximumcoupling]) - 1; + $thechoice = mt_rand(0, count($thecouplings[$themaximumcoupling]) - 1); $thecluespositions[] = $thecouplings[$themaximumcoupling][$thechoice]; $therow = $thecouplings[$themaximumcoupling][$thechoice][0]; $thecolumn = $thecouplings[$themaximumcoupling][$thechoice][1]; @@ -1911,7 +1911,7 @@ class sudoku extends ObjectS { class SudokuTemplates extends Sudoku { - public function sudokutemplates($theDebug = false) { + public function sudokutemplates($thedebug = false) { $this->sudoku($thedebug); } diff --git a/sudoku/play.php b/sudoku/play.php index a2f1f66..89eeda7 100755 --- a/sudoku/play.php +++ b/sudoku/play.php @@ -527,7 +527,10 @@ function game_sudoku_check_questions( $id, $game, $attempt, $sudoku, $finishatte continue; } - $grade = game_grade_responses( $question, $responses, 100, $answertext); + $grade = game_grade_responses( $question, $responses, 100, $answertext, $answered); + if( $answered == false) { + continue; + } if ($grade < 99) { // Wrong answer. game_update_queries( $game, $attempt, $query, $grade / 100, $answertext); @@ -555,7 +558,7 @@ function game_sudoku_check_glossaryentries( $id, $game, $attempt, $sudoku, $fini if (!($entries = $DB->get_records_select( 'glossary_entries', "id IN ($entrieslist)"))) { print_error( get_string('noglossaryentriesfound', 'game')); } - foreach (entries as $entry) { + foreach ($entries as $entry) { $answerundefined = optional_param('resp'.$entry->id, 'undefined', PARAM_TEXT); if ($answerundefined == 'undefined') { continue;