diff --git a/cross/crossdb_class.php b/cross/crossdb_class.php index 88162c9..09f2573 100755 --- a/cross/crossdb_class.php +++ b/cross/crossdb_class.php @@ -65,9 +65,7 @@ class CrossDB extends Cross $html = ''; $done = false; - if( $g == ""){ - $game_questions = false; - } + $loadfromdb = ( $g == ""); $this->m_mincol = $this->m_minrow = 0; $this->m_maxcol = $crossrec->cols; @@ -98,7 +96,7 @@ class CrossDB extends Cross $correctletters = $wrongletters = $restletters = 0; foreach( $a as $rec){ - $this->updatecrossquestions( $rec, $g, $pos, $correctletters, $wrongletters, $restletters, $game, $attempt, $crossrec); + $this->updatecrossquestions( $rec, $g, $pos, $correctletters, $wrongletters, $restletters, $game, $attempt, $crossrec, $loadfromdb); $b[] = $rec; if( ($rec->col != 0) and ($rec->row != 0)){ @@ -138,10 +136,11 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters, if( $correctletters > 1 or $wrongletters > 1) { $ret = get_string( 'cross_found_many', 'game'); - }else + }else if( count( $a)) { $ret = get_string( 'cross_found_one', 'game'); - } + }else + $ret = ''; $i = 0; foreach( $a as $msg) @@ -178,13 +177,18 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters, } //rec is a record of cross_questions - function updatecrossquestions( &$rec, &$g, &$pos, &$correctletters, &$wrongletters, &$restletters, $game, $attempt, $crossrec) + function updatecrossquestions( &$rec, &$g, &$pos, &$correctletters, &$wrongletters, &$restletters, $game, $attempt, $crossrec, $loadfromdb) { global $DB, $USER; $word = $rec->answertext; $len = textlib::strlen( $word); - $guess = textlib::substr( $g, $pos, $len); + + if( $loadfromdb) + $guess = $rec->studentanswer; + else + $guess = textlib::substr( $g, $pos, $len); + $len_guess = textlib::strlen( $guess);; $pos += $len; @@ -202,7 +206,7 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters, $letterword= textlib::substr( $word, $i, 1); if( $letterword != $letterguess) { - if( ($letterguess != ' ' and $letterguess != '_') or ($letterword == ' ')){ + if( ($letterguess != ' ' and $letterguess != '_')){ $wrongletters++; } game_setchar( $guess, $i, '_'); diff --git a/version.php b/version.php index d62c812..2380e6c 100755 --- a/version.php +++ b/version.php @@ -11,7 +11,7 @@ defined('MOODLE_INTERNAL') || die(); $module->component = 'mod_game'; // Full name of the plugin (used for diagnostics) -$module->version = 2013072603; // The current module version (Date: YYYYMMDDXX) +$module->version = 2013072604; // The current module version (Date: YYYYMMDDXX) $module->requires = 2010112400; // Requires Moodle 2.0 $module->cron = 0; // Period for cron to check this module (secs) -$module->release = '3.7.26.3'; +$module->release = '3.7.26.4';