|
@ -65,9 +65,7 @@ class CrossDB extends Cross |
|
|
$html = ''; |
|
|
$html = ''; |
|
|
$done = false; |
|
|
$done = false; |
|
|
|
|
|
|
|
|
if( $g == ""){ |
|
|
$loadfromdb = ( $g == ""); |
|
|
$game_questions = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->m_mincol = $this->m_minrow = 0; |
|
|
$this->m_mincol = $this->m_minrow = 0; |
|
|
$this->m_maxcol = $crossrec->cols; |
|
|
$this->m_maxcol = $crossrec->cols; |
|
@ -98,7 +96,7 @@ class CrossDB extends Cross |
|
|
$correctletters = $wrongletters = $restletters = 0; |
|
|
$correctletters = $wrongletters = $restletters = 0; |
|
|
|
|
|
|
|
|
foreach( $a as $rec){ |
|
|
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; |
|
|
$b[] = $rec; |
|
|
|
|
|
|
|
|
if( ($rec->col != 0) and ($rec->row != 0)){ |
|
|
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) { |
|
|
if( $correctletters > 1 or $wrongletters > 1) { |
|
|
$ret = get_string( 'cross_found_many', 'game'); |
|
|
$ret = get_string( 'cross_found_many', 'game'); |
|
|
}else |
|
|
}else if( count( $a)) |
|
|
{ |
|
|
{ |
|
|
$ret = get_string( 'cross_found_one', 'game'); |
|
|
$ret = get_string( 'cross_found_one', 'game'); |
|
|
} |
|
|
}else |
|
|
|
|
|
$ret = ''; |
|
|
|
|
|
|
|
|
$i = 0; |
|
|
$i = 0; |
|
|
foreach( $a as $msg) |
|
|
foreach( $a as $msg) |
|
@ -178,13 +177,18 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//rec is a record of cross_questions |
|
|
//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; |
|
|
global $DB, $USER; |
|
|
|
|
|
|
|
|
$word = $rec->answertext; |
|
|
$word = $rec->answertext; |
|
|
$len = textlib::strlen( $word); |
|
|
$len = textlib::strlen( $word); |
|
|
|
|
|
|
|
|
|
|
|
if( $loadfromdb) |
|
|
|
|
|
$guess = $rec->studentanswer; |
|
|
|
|
|
else |
|
|
$guess = textlib::substr( $g, $pos, $len); |
|
|
$guess = textlib::substr( $g, $pos, $len); |
|
|
|
|
|
|
|
|
$len_guess = textlib::strlen( $guess);; |
|
|
$len_guess = textlib::strlen( $guess);; |
|
|
$pos += $len; |
|
|
$pos += $len; |
|
|
|
|
|
|
|
@ -202,7 +206,7 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters, |
|
|
$letterword= textlib::substr( $word, $i, 1); |
|
|
$letterword= textlib::substr( $word, $i, 1); |
|
|
if( $letterword != $letterguess) |
|
|
if( $letterword != $letterguess) |
|
|
{ |
|
|
{ |
|
|
if( ($letterguess != ' ' and $letterguess != '_') or ($letterword == ' ')){ |
|
|
if( ($letterguess != ' ' and $letterguess != '_')){ |
|
|
$wrongletters++; |
|
|
$wrongletters++; |
|
|
} |
|
|
} |
|
|
game_setchar( $guess, $i, '_'); |
|
|
game_setchar( $guess, $i, '_'); |
|
|