Browse Source

Fix:Coding style

MOODLE_20_STABLE
Vasilis Daloukas 9 years ago
parent
commit
acbd0158ff
  1. 20
      classes/event/course_module_instance_list_viewed.php
  2. 16
      classes/event/course_module_viewed.php
  3. 18
      classes/event/game_played.php
  4. 17
      classes/plugininfo/booktool.php
  5. 17
      classes/plugininfo/gametool.php
  6. 730
      cross/cross_class.php
  7. 147
      cross/crossdb_class.php
  8. 117
      cross/play.php

20
classes/event/course_module_instance_list_viewed.php

@ -1,4 +1,18 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
@ -13,7 +27,7 @@
namespace mod_game\event; namespace mod_game\event;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/** /*
* The mod_game instance list viewed event class. * The mod_game instance list viewed event class.
* *
* @package mod_game * @package mod_game
@ -35,5 +49,5 @@ class course_module_instance_list_viewed extends \core\event\course_module_insta
$event = \mod_game\event\course_module_instance_list_viewed::create( $params); $event = \mod_game\event\course_module_instance_list_viewed::create( $params);
$event->add_record_snapshot('course', $course); $event->add_record_snapshot('course', $course);
return $event; return $event;
}} }
}

16
classes/event/course_module_viewed.php

@ -1,4 +1,18 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
@ -36,7 +50,6 @@ class course_module_viewed extends \core\event\course_module_viewed {
'context' => $context, 'context' => $context,
'objectid' => $game->id 'objectid' => $game->id
); );
/** @var course_module_viewed $event */
$event = self::create($data); $event = self::create($data);
$event->add_record_snapshot('game', $game); $event->add_record_snapshot('game', $game);
return $event; return $event;
@ -47,7 +60,6 @@ class course_module_viewed extends \core\event\course_module_viewed {
'context' => $context, 'context' => $context,
'objectid' => $game->id 'objectid' => $game->id
); );
/** @var course_module_viewed $event */
$event = self::create($data); $event = self::create($data);
$event->add_record_snapshot('game', $game); $event->add_record_snapshot('game', $game);
return $event; return $event;

18
classes/event/game_played.php

@ -1,4 +1,18 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
@ -38,7 +52,6 @@ class game_played extends \core\event\base {
'context' => $context, 'context' => $context,
'objectid' => $game->id 'objectid' => $game->id
); );
/** @var chapter_viewed $event */
$event = self::create($data); $event = self::create($data);
$event->add_record_snapshot('game', $game); $event->add_record_snapshot('game', $game);
return $event; return $event;
@ -50,7 +63,8 @@ class game_played extends \core\event\base {
* @return array|null * @return array|null
*/ */
protected function get_legacy_logdata() { protected function get_legacy_logdata() {
return array($this->courseid, 'game', 'view', 'view.php?id=' . $this->contextinstanceid, $this->objectid, $this->contextinstanceid); return array($this->courseid, 'game', 'view', 'view.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
} }
/** /**

17
classes/plugininfo/booktool.php

@ -1,4 +1,21 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Subplugin info class. * Subplugin info class.
* *

17
classes/plugininfo/gametool.php

@ -1,4 +1,21 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Subplugin info class. * Subplugin info class.
* *

730
cross/cross_class.php

File diff suppressed because it is too large

147
cross/crossdb_class.php

@ -1,4 +1,21 @@
<?php // $Id: crossdb_class.php,v 1.17 2012/07/25 11:16:05 bdaloukas Exp $ <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* This class is a cross that can load and save to a table * This class is a cross that can load and save to a table
* *
@ -7,10 +24,8 @@
* @package game * @package game
**/ **/
class CrossDB extends Cross class CrossDB extends Cross {
{ public function savecross( $game, &$crossm, $crossd, $id) {
function savecross( $game, &$crossm, $crossd, $id)
{
global $DB, $USER; global $DB, $USER;
$crossm->id = $id; $crossm->id = $id;
@ -22,8 +37,7 @@ class CrossDB extends Cross
print_error( 'Insert page: new page game_cross not inserted'); print_error( 'Insert page: new page game_cross not inserted');
} }
foreach( $crossd as $rec) foreach ($crossd as $rec) {
{
$rec->attemptid = $id; $rec->attemptid = $id;
$rec->questiontext = addslashes( $rec->questiontext); $rec->questiontext = addslashes( $rec->questiontext);
@ -41,8 +55,7 @@ class CrossDB extends Cross
return true; return true;
} }
function delete_records( $id) public function delete_records( $id) {
{
global $DB; global $DB;
if (!$DB->delete_records( 'game_queries', array( 'attemptid' => $id))) { if (!$DB->delete_records( 'game_queries', array( 'attemptid' => $id))) {
@ -54,22 +67,22 @@ class CrossDB extends Cross
} }
function loadcross( $g, &$done, &$html, $game, $attempt, $crossrec, $onlyshow, $showsolution, &$finishattempt, $showhtmlsolutions, &$language, $showstudentguess, $context) public function loadcross( $g, &$done, &$html, $game, $attempt, $crossrec, $onlyshow, $showsolution,
{ &$finishattempt, $showhtmlsolutions, &$language, $showstudentguess, $context) {
global $DB; global $DB;
$info = ''; $info = '';
$correctLetters = 0; $correctletters = 0;
$allLetters = 0; $allletters = 0;
$wrongLetters = 0; $wrongletters = 0;
$html = ''; $html = '';
$done = false; $done = false;
$loadfromdb = ( $g == ""); $loadfromdb = ( $g == "");
$this->m_mincol = $this->m_minrow = 0; $this->mmincol = $this->mminrow = 0;
$this->m_maxcol = $crossrec->cols; $this->mmaxcol = $crossrec->cols;
$this->m_maxrow = $crossrec->rows; $this->mmaxrow = $crossrec->rows;
if ($g == "") { if ($g == "") {
$g = str_repeat( ' ', $this->m_maxcol * $this->m_maxrow); $g = str_repeat( ' ', $this->m_maxcol * $this->m_maxrow);
@ -78,16 +91,14 @@ class CrossDB extends Cross
$load = false; $load = false;
$puzzle = str_repeat('.', $this->m_maxrow * $this->m_maxcol); $puzzle = str_repeat('.', $this->m_maxrow * $this->m_maxcol);
if ($recs = $DB->get_records( 'game_queries', array( 'attemptid' => $crossrec->id))) if ($recs = $DB->get_records( 'game_queries', array( 'attemptid' => $crossrec->id))) {
{
$a = array(); $a = array();
foreach ($recs as $rec) foreach ($recs as $rec) {
{ if ($rec->horizontal) {
if( $rec->horizontal)
$key = sprintf( 'h%10d %10d', $rec->row, $rec->col); $key = sprintf( 'h%10d %10d', $rec->row, $rec->col);
else } else {
$key = sprintf( 'v%10d %10d', $rec->col, $rec->row); $key = sprintf( 'v%10d %10d', $rec->col, $rec->row);
}
$a[ $key] = $rec; $a[ $key] = $rec;
} }
@ -96,7 +107,8 @@ 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, $loadfromdb); $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)) {
@ -106,54 +118,52 @@ class CrossDB extends Cross
$language = game_detectlanguage( $rec->answertext); $language = game_detectlanguage( $rec->answertext);
} }
} }
$info = $this->game_cross_computecheck( $correctletters, $wrongletters, $restletters, $game, $attempt, $done, $onlyshow, $showsolution, $finishattempt); $info = $this->game_cross_computecheck( $correctletters, $wrongletters,
$restletters, $game, $attempt, $done, $onlyshow, $showsolution, $finishattempt);
$html = $this->showhtml_base( $crossrec, $b, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game); $html = $this->showhtml_base( $crossrec, $b, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game);
} }
if( $load == false) if ($load == false) {
{
$finishattempt = true; $finishattempt = true;
} }
return $info; return $info;
} }
function game_cross_computecheck( $correctletters, $wrongletters, $restletters, $game, $attempt, &$done, $onlyshow, $showsolution, $finishattempt) public function game_cross_computecheck( $correctletters, $wrongletters, $restletters, $game,
{ $attempt, &$done, $onlyshow, $showsolution, $finishattempt) {
$ret = '';
//if( $correctletters == 0 and $wrongletters == 0){ $ret = '';
// return $ret;
//}
$and = get_string( 'and', 'game'); $and = get_string( 'and', 'game');
$a = array(); $a = array();
if( $correctletters) if ($correctletters) {
$a[] = $correctletters.' '.( $correctletters > 1 ? get_string( 'cross_corrects', 'game') :get_string( 'cross_correct', 'game')); $a[] = $correctletters.' '.
if( $wrongletters) ( $correctletters > 1 ? get_string( 'cross_corrects', 'game') : get_string( 'cross_correct', 'game'));
$a[] = '<b>'.$wrongletters.' '.( $wrongletters > 1 ? get_string( 'cross_errors', 'game') : get_string( 'cross_error', 'game')).'</b>'; }
if ($wrongletters) {
$a[] = '<b>'.$wrongletters.' '.
( $wrongletters > 1 ? get_string( 'cross_errors', 'game') : get_string( 'cross_error', 'game')).'</b>';
}
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 if( count( $a)) } else if ( count( $a)) {
{
$ret = get_string( 'cross_found_one', 'game'); $ret = get_string( 'cross_found_one', 'game');
}else } else {
$ret = ''; $ret = '';
}
$i = 0; $i = 0;
foreach( $a as $msg) foreach ($a as $msg) {
{
$i++; $i++;
if ($i == 1) { if ($i == 1) {
$ret .= ' '.$msg; $ret .= ' '.$msg;
}else if( $i == count($a)) } else if ( $i == count($a)) {
{
$ret .= ' '.get_string( 'and', 'game').' '.$msg; $ret .= ' '.get_string( 'and', 'game').' '.$msg;
}else } else {
{
$ret .= ', '.$msg; $ret .= ', '.$msg;
} }
} }
@ -176,36 +186,37 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters,
return $ret; return $ret;
} }
//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, $loadfromdb) public 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 = game_strlen( $word); $len = game_strlen( $word);
if( $loadfromdb) if ($loadfromdb) {
$guess = $rec->studentanswer; $guess = $rec->studentanswer;
else } else {
$guess = game_substr( $g, $pos, $len); $guess = game_substr( $g, $pos, $len);
}
$len_guess = game_strlen( $guess);; $lenguess = game_strlen( $guess);;
$pos += $len; $pos += $len;
$is_empty = true; $isempty = true;
for($i = 0; $i < $len; $i++) for ($i = 0; $i < $len; $i++) {
{ if ($i < $lenguess) {
if( $i < $len_guess)
$letterguess = game_substr( $guess, $i, 1); $letterguess = game_substr( $guess, $i, 1);
else } else {
$letterguess = " "; $letterguess = " ";
}
if( $letterguess != ' ') if ($letterguess != ' ') {
$is_empty = false; $isempty = false;
}
$letterword = game_substr( $word, $i, 1); $letterword = game_substr( $word, $i, 1);
if( $letterword != $letterguess) if ($letterword != $letterguess) {
{
if (($letterguess != ' ' and $letterguess != '_')) { if (($letterguess != ' ' and $letterguess != '_')) {
$wrongletters++; $wrongletters++;
} }
@ -214,18 +225,13 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters,
} else if ($letterguess == ' ') { } else if ($letterguess == ' ') {
if ($guess == $word) { if ($guess == $word) {
$correctletters++; $correctletters++;
}else
{
//$wrongletters++;
//game_setchar( $guess, $i, '_');
} }
}else } else {
{
$correctletters++; $correctletters++;
} }
} }
if( $is_empty){ if ($isempty) {
return; return;
} }
if (($rec->studentanswer == $guess )) { if (($rec->studentanswer == $guess )) {
@ -245,4 +251,3 @@ function game_cross_computecheck( $correctletters, $wrongletters, $restletters,
game_update_queries( $game, $attempt, $rec, $score, $guess); game_update_queries( $game, $attempt, $rec, $score, $guess);
} }
} }

117
cross/play.php

@ -1,12 +1,27 @@
<?php // $Id: play.php,v 1.23 2012/08/15 14:38:06 bdaloukas Exp $ <?php
// This file is part of Moodle - http://moodle.org/
// This files plays the game "Crossword" //
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// This files plays the game "Crossword".
require( "cross_class.php"); require( "cross_class.php");
require( "crossdb_class.php"); require( "crossdb_class.php");
function game_cross_continue( $id, $game, $attempt, $cross, $g, $endofgame, $context) function game_cross_continue( $id, $game, $attempt, $cross, $g, $endofgame, $context) {
{
if ($endofgame) { if ($endofgame) {
if ($g == '') { if ($g == '') {
game_updateattempts( $game, $attempt, -1, true); game_updateattempts( $game, $attempt, -1, true);
@ -15,7 +30,8 @@ function game_cross_continue( $id, $game, $attempt, $cross, $g, $endofgame, $con
} }
if ($attempt != false and $cross != false) { if ($attempt != false and $cross != false) {
return game_cross_play( $id, $game, $attempt, $cross, $g, false, false, $endofgame, false, false, false, false, true, $context); return game_cross_play( $id, $game, $attempt, $cross, $g, false, false, $endofgame,
false, false, false, false, true, $context);
} }
if ($attempt == false) { if ($attempt == false) {
@ -27,8 +43,7 @@ function game_cross_continue( $id, $game, $attempt, $cross, $g, $endofgame, $con
return game_cross_play( $id, $game, $attempt, $crossm, '', false, false, false, false, false, false, false, true, $context); return game_cross_play( $id, $game, $attempt, $crossm, '', false, false, false, false, false, false, false, true, $context);
} }
function game_cross_new( $game, $attemptid, &$crossm) function game_cross_new( $game, $attemptid, &$crossm) {
{
global $DB, $USER; global $DB, $USER;
$cross = new CrossDB(); $cross = new CrossDB();
@ -46,7 +61,7 @@ function game_cross_new( $game, $attemptid, &$crossm)
foreach ($recs as $rec) { foreach ($recs as $rec) {
if ($game->param7 == false) { if ($game->param7 == false) {
if (game_strpos( $rec->answertext, ' ')) { if (game_strpos( $rec->answertext, ' ')) {
continue; //spaces not allowed continue; // Spaces not allowed.
} }
} }
@ -54,7 +69,8 @@ function game_cross_new( $game, $attemptid, &$crossm)
$answers[ $rec->answertext] = game_repairquestion( $rec->questiontext); $answers[ $rec->answertext] = game_repairquestion( $rec->questiontext);
$infos[ $rec->answertext] = array( $game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment); $infos[ $rec->answertext] = array( $game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment);
$a = array( 'gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid); $a = array( 'gameid' => $game->id, 'userid' => $USER->id,
'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
if (($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions AS r')) != false) { if (($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions AS r')) != false) {
$reps[ $rec->answertext] = $rec2->r; $reps[ $rec->answertext] = $rec2->r;
} }
@ -62,12 +78,11 @@ function game_cross_new( $game, $attemptid, &$crossm)
$cross->setwords( $answers, $game->param1, $reps); $cross->setwords( $answers, $game->param1, $reps);
//game->param4 is minimum words in crossword // The game->param4 is minimum words in crossword.
//game->param2 is maximum words in crossword // The game->param2 is maximum words in crossword.
if ($cross->computedata( $crossm, $crossd, $lettets, $game->param4, $game->param2)) { if ($cross->computedata( $crossm, $crossd, $lettets, $game->param4, $game->param2)) {
$new_crossd = array(); $newcrossd = array();
foreach( $crossd as $rec) foreach ($crossd as $rec) {
{
$info = $infos[ $rec->answertext]; $info = $infos[ $rec->answertext];
if ($info != false) { if ($info != false) {
$rec->sourcemodule = $info[ 0]; $rec->sourcemodule = $info[ 0];
@ -75,9 +90,9 @@ function game_cross_new( $game, $attemptid, &$crossm)
$rec->glossaryentryid = $info[ 2]; $rec->glossaryentryid = $info[ 2];
$rec->attachment = $info[ 3]; $rec->attachment = $info[ 3];
} }
$new_crossd[] = $rec; $newcrossd[] = $rec;
} }
$cross->savecross( $game, $crossm, $new_crossd, $attemptid); $cross->savecross( $game, $crossm, $newcrossd, $attemptid);
} }
if (count( $crossd) == 0) { if (count( $crossd) == 0) {
@ -85,27 +100,28 @@ function game_cross_new( $game, $attemptid, &$crossm)
} }
} }
function showlegend( $legend, $title) function showlegend( $legend, $title) {
{ if (count( $legend) == 0) {
if( count( $legend) == 0)
return; return;
}
echo "<br><b>$title</b><br>"; echo "<br><b>$title</b><br>";
foreach( $legend as $key => $line) foreach ($legend as $key => $line) {
{
$line = game_repairquestion( $line); $line = game_repairquestion( $line);
echo game_filtertext( "$key: $line<br>", 0); echo game_filtertext( "$key: $line<br>", 0);
} }
} }
function game_cross_play( $id, $game, $attempt, $crossrec, $g, $onlyshow, $showsolution, $endofgame, $print, $checkbutton, $showhtmlsolutions, $showhtmlprintbutton,$showstudentguess, $context) function game_cross_play( $id, $game, $attempt, $crossrec, $g, $onlyshow, $showsolution,
{ $endofgame, $print, $checkbutton, $showhtmlsolutions, $showhtmlprintbutton, $showstudentguess, $context) {
global $CFG, $DB; global $CFG, $DB;
$cross = new CrossDB(); $cross = new CrossDB();
$language = $attempt->language; $language = $attempt->language;
$info = $cross->loadcross( $g, $done, $html, $game, $attempt, $crossrec, $onlyshow, $showsolution, $endofgame, $showhtmlsolutions, $attempt->language,$showstudentguess, $context); $info = $cross->loadcross( $g, $done, $html, $game, $attempt, $crossrec, $onlyshow,
$showsolution, $endofgame, $showhtmlsolutions, $attempt->language,
$showstudentguess, $context);
if ($language != $attempt->language) { if ($language != $attempt->language) {
if (!$DB->set_field( 'game_attempts', 'language', $attempt->language, array( 'id' => $attempt->id))) { if (!$DB->set_field( 'game_attempts', 'language', $attempt->language, array( 'id' => $attempt->id))) {
@ -121,24 +137,27 @@ function game_cross_play( $id, $game, $attempt, $crossrec, $g, $onlyshow, $shows
if ($endofgame == false) { if ($endofgame == false) {
echo '<B>'.get_string( 'win', 'game').'</B><BR>'; echo '<B>'.get_string( 'win', 'game').'</B><BR>';
} }
if( game_can_start_new_attempt( $game)) if (game_can_start_new_attempt( $game)) {
{
echo '<br>'; echo '<br>';
echo "<a href=\"{$CFG->wwwroot}/mod/game/attempt.php?id=$id&forcenew=1\">".get_string( 'nextgame', 'game').'</a> &nbsp; &nbsp; &nbsp; &nbsp; '; echo "<a href=\"{$CFG->wwwroot}/mod/game/attempt.php?id=$id&forcenew=1\">".
get_string( 'nextgame', 'game').'</a> &nbsp; &nbsp; &nbsp; &nbsp; ';
} }
} else if ($info != '') { } else if ($info != '') {
echo "<br>$info<br>"; echo "<br>$info<br>";
} }
if( $attempt->language != '') if ($attempt->language != '') {
$wordrtl = game_right_to_left( $attempt->language); $wordrtl = game_right_to_left( $attempt->language);
else } else {
$wordrtl = right_to_left(); $wordrtl = right_to_left();
}
$reverseprint = ($wordrtl != right_to_left()); $reverseprint = ($wordrtl != right_to_left());
if( $reverseprint) if ($reverseprint) {
$textdir = 'dir="'.($wordrtl ? 'rtl' : 'ltr').'"'; $textdir = 'dir="'.($wordrtl ? 'rtl' : 'ltr').'"';
else } else {
$textdir = ''; $textdir = '';
}
?> ?>
<style type="text/css"><!-- <style type="text/css"><!--
@ -267,7 +286,6 @@ if( $print){
echo $game->toptext.'<br>'; echo $game->toptext.'<br>';
} }
?> ?>
<h1></h1> <h1></h1>
<div id="waitmessage" class="answerboxstyle"> <div id="waitmessage" class="answerboxstyle">
@ -289,7 +307,8 @@ if( $print){
?> ?>
<tr> <tr>
<td class="crosswordarea"><table id="crossword" cellpadding="3" cellspacing="0" style="display: none; border-collapse: collapse;" <?php echo $textdir;?>> <td class="crosswordarea">
<table id="crossword" cellpadding="3" cellspacing="0" style="display: none; border-collapse: collapse;" <?php echo $textdir;?>>
<script language="JavaScript" type="text/javascript"><!-- <script language="JavaScript" type="text/javascript"><!--
@ -316,7 +335,7 @@ if (document.getElementById("waitmessage") != null)
CurrentWord = -1; CurrentWord = -1;
PrevWordHorizontal = false; PrevWordHorizontal = false;
<?PHP <?php
echo $html; echo $html;
?> ?>
@ -419,7 +438,10 @@ if (document.getElementById("waitmessage") != null)
{ {
if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0) if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0)
{ {
document.write("<td id=\"c" + PadNumber(x) + PadNumber(y) + "\" class=\"gamebox boxnormal_unsel\" onclick=\"SelectThisWord(event);\">"); var s;
s = "<td id=\"c" + PadNumber(x) + PadNumber(y);
s += "\" class=\"gamebox boxnormal_unsel\" onclick=\"SelectThisWord(event);\">";
document.write( s);
if( solu[x][y] != '') if( solu[x][y] != '')
document.write( solu[x][y]); document.write( solu[x][y]);
@ -749,7 +771,6 @@ function CheckServerClick( endofgame)
} }
?> ?>
} }
<?php <?php
} }
?> ?>
@ -907,9 +928,7 @@ function CheckHtmlClick()
<?php <?php
} }
if ($showhtmlsolutions) {
if( $showhtmlsolutions)
{
?> ?>
function decodeutf8(utftext) { function decodeutf8(utftext) {
var string = ""; var string = "";
@ -965,13 +984,14 @@ if( $showhtmlsolutions)
if ($onlyshow == false) { if ($onlyshow == false) {
echo '<div style="margin-top: 1em;">'; echo '<div style="margin-top: 1em;">';
echo '<button id="checkbutton" type="button" onclick="CheckServerClick( 0);" style="display: none;">'.get_string( 'cross_checkbutton', 'game'); echo '<button id="checkbutton" type="button" onclick="CheckServerClick( 0);" style="display: none;">'.
get_string( 'cross_checkbutton', 'game');
echo '</button>'; echo '</button>';
echo ' &nbsp;&nbsp;&nbsp;&nbsp;<button id="finishattemptbutton" type="button" onclick="CheckServerClick( 1);" style="display: none;">'.get_string( 'cross_endofgamebutton', 'game'); echo ' &nbsp;&nbsp;&nbsp;&nbsp;<button id="finishattemptbutton" type="button" onclick="CheckServerClick( 1);" style="display: none;">'.
get_string( 'cross_endofgamebutton', 'game');
echo '</button>'; echo '</button>';
if( $game->param5 == 1 or $game->param5 == NULL) if ($game->param5 == 1 or $game->param5 == NULL) {
{
echo ' &nbsp;&nbsp;&nbsp;&nbsp;<button id="printbutton" type="button" onclick="OnPrint( 0);" style="display: none;">'.get_string( 'print', 'game'); echo ' &nbsp;&nbsp;&nbsp;&nbsp;<button id="printbutton" type="button" onclick="OnPrint( 0);" style="display: none;">'.get_string( 'print', 'game');
echo '</button>'; echo '</button>';
} }
@ -1007,12 +1027,9 @@ if( $showhtmlsolutions)
echo '<br><br>'.$game->bottomtext; echo '<br><br>'.$game->bottomtext;
} }
if ($attempt != false) { if ($attempt != false) {
if( $attempt->timefinish == 0 and $endofgame == 0) if ($attempt->timefinish == 0 and $endofgame == 0) {
{
?> ?>
<script language="JavaScript" type="text/javascript"><!-- <script language="JavaScript" type="text/javascript"><!--
if (Initialized) if (Initialized)
{ {
@ -1021,8 +1038,7 @@ if( $attempt != false){
echo "document.getElementById(\"welcomemessage\").style.display = \"\";"; echo "document.getElementById(\"welcomemessage\").style.display = \"\";";
} }
if( $showsolution == false) if ($showsolution == false) {
{
?> ?>
document.getElementById("checkbutton").style.display = ""; document.getElementById("checkbutton").style.display = "";
document.getElementById("finishattemptbutton").style.display = ""; document.getElementById("finishattemptbutton").style.display = "";
@ -1051,7 +1067,6 @@ function game_cross_show_welcome( $game){
} else { } else {
game_cross_show_welcome1(); game_cross_show_welcome1();
} }
} }
function game_cross_show_welcome0( $game) { function game_cross_show_welcome0( $game) {

Loading…
Cancel
Save