Browse Source

Fix: PHP coding style problems

MOODLE_20_STABLE
bdaloukas 8 years ago
parent
commit
bdd03e33dd
  1. 2
      backup/moodle2/restore_game_stepslib.php
  2. 64
      bookquiz/play.php
  3. 2
      cross/cross_class.php
  4. 2
      cross/crossdb_class.php
  5. 258
      cross/play.php
  6. 2
      cryptex/cryptexdb_class.php
  7. 2
      db/access.php
  8. 2
      exporthtml_hangman.php
  9. 2
      exporthtml_millionaire.php
  10. 2
      exporthtml_snakes.php
  11. 2
      exportjavame.php
  12. 2
      headergame.php
  13. 2
      index.php
  14. 27
      lib.php
  15. 4
      locallib.php
  16. 2
      mod_form.php
  17. 2
      pagelib.php
  18. 2
      print.php
  19. 2
      report/overview/report.php
  20. 2
      showanswers.php
  21. 2
      showattempts.php
  22. 2
      snakes/createboard.php
  23. 10
      snakes/play.php
  24. 4
      sudoku/class.Sudoku.php
  25. 27
      sudoku/play.php
  26. 2
      sudoku/sdd/class.logfile.php

2
backup/moodle2/restore_game_stepslib.php

@ -20,6 +20,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Define all the restore steps that will be used by the restore_game_activity_task
*/

64
bookquiz/play.php

@ -172,33 +172,33 @@ function game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $conte
}
}
?>
<table border="0" cellspacing="0" width="100%" valign="top" cellpadding="2">
<!-- subchapter title and upper navigation row //-->
<tr>
<td width="<?php echo 10;?>" valign="bottom">
</td>
<td valign="top">
<table border="0" cellspacing="0" width="100%" valign="top" cellpadding="0">
<tr>
<td align="right"><?php echo $chnavigation ?></td>
</tr>
</table>
</td>
</tr>
<!-- toc and chapter row //-->
<tr>
<td width="<?php echo $tocwidth ?>" valign="top" align="left">
<?php
echo $OUTPUT->box_start('generalbox');
echo $toc;
echo $OUTPUT->box_end();
?>
</td>
<td valign="top" align="left">
<?php
?>
<table border="0" cellspacing="0" width="100%" valign="top" cellpadding="2">
<!-- subchapter title and upper navigation row //-->
<tr>
<td width="<?php echo 10;?>" valign="bottom">
</td>
<td valign="top">
<table border="0" cellspacing="0" width="100%" valign="top" cellpadding="0">
<tr>
<td align="right"><?php echo $chnavigation ?></td>
</tr>
</table>
</td>
</tr>
<!-- toc and chapter row //-->
<tr>
<td width="<?php echo $tocwidth ?>" valign="top" align="left">
<?php
echo $OUTPUT->box_start('generalbox');
echo $toc;
echo $OUTPUT->box_end();
?>
</td>
<td valign="top" align="left">
<?php
echo $OUTPUT->box_start('generalbox');
$content = '';
if (!$book->customtitles) {
@ -227,12 +227,12 @@ function game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $conte
echo $OUTPUT->box_end();
// Lower navigation.
echo '<p align="right">'.$chnavigation.'</p>';
?>
</td>
</tr>
</table>
?>
</td>
</tr>
</table>
<?php
<?php
if ($showquestions) {
if ($game->param3 != 0) {
game_bookquiz_showquestions( $id, $questionid, $chapter->id, $nextid, $scoreattempt, $game, $context);

2
cross/cross_class.php

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/*
Crossing Words for
Codewalkers PHP Coding Contest of July 2002

2
cross/crossdb_class.php

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* This class is a cross that can load and save to a table
*

258
cross/play.php

@ -280,34 +280,34 @@ margin-top: 1em;
</head>
<?php
if ($print) {
echo '<body onload="window.print()">';
} else {
echo '<body>';
}
if ($print) {
echo '<body onload="window.print()">';
} else {
echo '<body>';
}
if ($game->toptext != '') {
echo $game->toptext.'<br>';
}
if ($game->toptext != '') {
echo $game->toptext.'<br>';
}
?>
<h1></h1>
<div id="waitmessage" class="answerboxstyle">
This interactive crossword puzzle requires JavaScript and a reasonably recent web browser, such as Internet Explorer 5.5
or later, Netscape 7, Mozilla, Firefox, or Safari. If you have disabled web page scripting, please re-enable it and refresh
the page.
This interactive crossword puzzle requires JavaScript and a reasonably recent web browser, such as Internet Explorer 5.5
or later, Netscape 7, Mozilla, Firefox, or Safari. If you have disabled web page scripting, please re-enable it and refresh
the page.
</div>
<p><table cellpadding="0" cellspacing="0" border="0">
<?php
if ($game->param3 == 2) {
echo "<tr>\r\n";
game_cross_show_welcome( $game);
echo "</tr>\r\n";
echo "<tr><tr><td>&nbsp</td></tr>\r\n";
}
if ($game->param3 == 2) {
echo "<tr>\r\n";
game_cross_show_welcome( $game);
echo "</tr>\r\n";
echo "<tr><tr><td>&nbsp</td></tr>\r\n";
}
?>
<tr>
@ -333,138 +333,125 @@ var CrosswordFinished, Initialized;
// Check the user's browser and then initialize the puzzle.
if (document.getElementById("waitmessage") != null)
{
document.getElementById("waitmessage").innerHTML = "<?php echo get_string( 'cross_pleasewait', 'game'); ?>";
// Current game variables
CurrentWord = -1;
PrevWordHorizontal = false;
document.getElementById("waitmessage").innerHTML = "<?php echo get_string( 'cross_pleasewait', 'game'); ?>";
// Current game variables
CurrentWord = -1;
PrevWordHorizontal = false;
<?php
echo $html;
?>
OnlyCheckOnce = false;
OnlyCheckOnce = false;
// Create the cell-to-word arrays.
TableAcrossWord = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++)
// Create the cell-to-word arrays.
TableAcrossWord = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++)
TableAcrossWord[x] = new Array(CrosswordHeight);
TableDownWord = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++){
TableDownWord[x] = new Array(CrosswordHeight);
}
TableDownWord = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++){
TableDownWord[x] = new Array(CrosswordHeight);
}
GuessLeter = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++)
{
GuessLeter[x] = new Array(CrosswordHeight);
for (var y = 0; y < CrosswordHeight; y++)
{
GuessLeter[ x][ y] = "_";
}
}
GuessLeter = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++) {
GuessLeter[x] = new Array(CrosswordHeight);
for (var y = 0; y < CrosswordHeight; y++) {
GuessLeter[ x][ y] = "_";
}
}
solu = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++)
{
solu[x] = new Array(CrosswordHeight);
for (var y = 0; y < CrosswordHeight; y++)
{
solu[ x][ y] = "";
}
}
solu = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++) {
solu[x] = new Array(CrosswordHeight);
for (var y = 0; y < CrosswordHeight; y++) {
solu[ x][ y] = "";
}
}
for (var y = 0; y < CrosswordHeight; y++)
for (var x = 0; x < CrosswordWidth; x++)
{
TableAcrossWord[x][y] = -1;
TableDownWord[x][y] = -1;
}
// First, add the horizontal words to the puzzle.
for (var i = 0; i <= LastHorizontalWord; i++)
{
x = WordX[i];
y = WordY[i];
s = Guess[ i];
so = Solutions[ i];
for (var j = 0; j < WordLength[i]; j++)
{
TableAcrossWord[x + j][y] = i;
if( j < s.length)
c = s.substr( j, 1);
else
c = '';
GuessLeter[ x+ j][ y] = c;
if( j < so.length)
c = so.substr( j, 1);
else
c = '';
solu[ x+j][ y] = c;
}
for (var y = 0; y < CrosswordHeight; y++) {
for (var x = 0; x < CrosswordWidth; x++) {
TableAcrossWord[x][y] = -1;
TableDownWord[x][y] = -1;
}
}
// First, add the horizontal words to the puzzle.
for (var i = 0; i <= LastHorizontalWord; i++) {
x = WordX[i];
y = WordY[i];
s = Guess[ i];
so = Solutions[ i];
for (var j = 0; j < WordLength[i]; j++) {
TableAcrossWord[x + j][y] = i;
if( j < s.length)
c = s.substr( j, 1);
else
c = '';
GuessLeter[ x+ j][ y] = c;
if( j < so.length)
c = so.substr( j, 1);
else
c = '';
solu[ x+j][ y] = c;
}
}
// Second, add the vertical words to the puzzle.
for (var i = LastHorizontalWord + 1; i < Words; i++)
{
x = WordX[i];
y = WordY[i];
s = Guess[ i];
so = Solutions[ i];
for (var j = 0; j < WordLength[i]; j++)
{
TableDownWord[x][y + j] = i;
if( j < s.length)
c = s.substr( j, 1);
else
c = '';
GuessLeter[ x][ y+j] = c;
if( j < so.length)
c = so.substr( j, 1);
else
c = '';
solu[ x][ y+j] = c;
}
}
// Second, add the vertical words to the puzzle.
for (var i = LastHorizontalWord + 1; i < Words; i++) {
x = WordX[i];
y = WordY[i];
s = Guess[ i];
so = Solutions[ i];
for (var j = 0; j < WordLength[i]; j++) {
TableDownWord[x][y + j] = i;
if( j < s.length)
c = s.substr( j, 1);
else
c = '';
GuessLeter[ x][ y+j] = c;
if( j < so.length)
c = so.substr( j, 1);
else
c = '';
solu[ x][ y+j] = c;
}
}
document.writeln("<tr><td></td>");
for (var x = 0; x < CrosswordWidth; x++)
{
document.write("<td align=center>" + (x+1) + " </td>"); //col numbers
}
document.writeln("<tr><td></td>");
for (var x = 0; x < CrosswordWidth; x++) {
document.write("<td align=center>" + (x+1) + " </td>"); //col numbers
}
// Now, insert the row HTML into the table.
for (var y = 0; y < CrosswordHeight; y++)
{
document.writeln("<tr>");
document.write("<td>" + (y+1)+" </td>"); //line numbers
for (var x = 0; x < CrosswordWidth; x++)
{
if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0)
{
// Now, insert the row HTML into the table.
for (var y = 0; y < CrosswordHeight; y++) {
document.writeln("<tr>");
document.write("<td>" + (y+1)+" </td>"); //line numbers
for (var x = 0; x < CrosswordWidth; x++) {
if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0) {
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] != '')
document.write( solu[x][y]);
else if( GuessLeter[x][y]== "_")
document.write( "&nbsp;");
else
document.write( GuessLeter[x][y]);
document.write("</td>");
}else
document.write("<td></td>"); //empty cell
}
document.writeln("</tr>");
}
if( solu[x][y] != '')
document.write( solu[x][y]);
else if( GuessLeter[x][y]== "_")
document.write( "&nbsp;");
else
document.write( GuessLeter[x][y]);
document.write("</td>");
} else {
document.write("<td></td>"); //empty cell
}
}
document.writeln("</tr>");
}
// Finally, show the crossword and hide the wait message.
Initialized = true;
document.getElementById("waitmessage").style.display = "none";
document.getElementById("crossword").style.display = "block";
// Finally, show the crossword and hide the wait message.
Initialized = true;
document.getElementById("waitmessage").style.display = "none";
document.getElementById("crossword").style.display = "block";
}
// ----------
@ -815,10 +802,8 @@ function OnPrint()
}
<?php
}
?>
<?php
if ($showhtmlprintbutton) {
?>
@ -988,7 +973,6 @@ function CheckHtmlClick()
</tr></table>
<?php
if ($onlyshow == false) {
echo '<div style="margin-top: 1em;">';
@ -1067,7 +1051,6 @@ function CheckHtmlClick()
?>
</body>
<?php
@ -1137,7 +1120,6 @@ function game_cross_show_welcome1() {
onkeypress="WordEntryKeyPress(event)" onchange="WordEntryKeyPress(event)" autocomplete="off"></div>
<div id="worderror" style="color:#c00000;font-weight:bold;display:none;margin-top:1em;"></div>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="margin-top:1em;"><tr>
<td align="right">
<button id="okbutton" type="button" class="button" onclick="OKClick();" style="font-weight: bold;">OK</button> &nbsp;
@ -1146,18 +1128,14 @@ function game_cross_show_welcome1() {
</td><td>&nbsp</td><td>
<div id="answerbox2" class="answerboxstyle" style="display:none;">
<h3 id="wordlabel" style="text-transform:uppercase;margin:0;"> </h3>
<div id="wordinfo" style="font-size:8pt;color:#808080"> </div>
<div id="wordclue" class="cluebox"> </div>
</div>
</div>
</td>
<?php
}

2
cryptex/cryptexdb_class.php

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
class CryptexDB extends CrossDB {
public function savecryptex( $game, &$crossm, $crossd, $id, $letters) {
global $USER;

2
db/access.php

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Capability definitions for the game module.
*

2
exporthtml_hangman.php

@ -21,6 +21,8 @@
* @package game
**/
defined('MOODLE_INTERNAL') || die();
?>
<script type="text/javascript">

2
exporthtml_millionaire.php

@ -21,6 +21,8 @@
* @package game
**/
defined('MOODLE_INTERNAL') || die();
function game_millionaire_html_getquestions( $game, $context, &$maxanswers, &$countofquestions, &$retfeedback, $destdir, &$files) {
global $CFG, $DB, $USER;

2
exporthtml_snakes.php

@ -21,6 +21,8 @@
* @package game
**/
defined('MOODLE_INTERNAL') || die();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

2
exportjavame.php

@ -21,6 +21,8 @@
* @package game
**/
defined('MOODLE_INTERNAL') || die();
function game_onexportjavame( $game, $javame) {
global $CFG, $DB;

2
headergame.php

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/mod/game/locallib.php');

2
index.php

@ -17,7 +17,7 @@
/**
* This page lists all the instances of game module in a particular course
*
* @author
* @author Vasilis Daloukas
* @package game
**/

27
lib.php

@ -21,6 +21,8 @@
* @package game
**/
defined('MOODLE_INTERNAL') || die();
// Define CONSTANTS.
/*
@ -51,9 +53,9 @@ define('GAME_REVIEW_SOLUTIONS', 16 * 0x1041); // Show solutions.
define('GAME_REVIEW_GENERALFEEDBACK', 32 * 0x1041); // Show general feedback.
/**
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* will create a new instance and return the id number
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* will create a new instance and return the id number
* of the new instance.
*
* @param object $instance An object from the form in mod.html
@ -79,8 +81,8 @@ function game_add_instance($game) {
}
/**
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* will update an existing instance with new data.
*
* @param object $instance An object from the form in mod.html
@ -178,8 +180,8 @@ function game_before_add_or_update(&$game) {
/**
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
* this function will permanently delete the instance
* and any data that depends on it.
*
* @param int $id Id of the module instance
* @return boolean Success/Failure
@ -236,7 +238,7 @@ function game_delete_instance($gameid) {
}
/**
* Return a small object with summary information about what a
* Return a small object with summary information about what a
* user has done with a given particular instance of this module
* Used for user activity reports.
* $return->time = the time they did it
@ -287,8 +289,8 @@ function game_user_complete($course, $user, $mod, $game) {
}
/**
* Given a course and a time, this module should find recent activity
* that has occurred in game activities and print it out.
* Given a course and a time, this module should find recent activity
* that has occurred in game activities and print it out.
* Return true if there was output, or false is there was none.
*
* @uses $CFG
@ -303,9 +305,10 @@ function game_print_recent_activity($course, $isteacher, $timestart) {
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
*
* @uses $CFG
* @return boolean
* @todo Finish documenting this function

4
locallib.php

@ -14,9 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
}
defined('MOODLE_INTERNAL') || die();
// Include those library functions that are also used by core Moodle or other modules.
require_once($CFG->dirroot . '/mod/game/lib.php');

2
mod_form.php

@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Form for creating and modifying a game
* Form for creating and modifying a game
*
* @package game
* @author Alastair Munro <alastair@catalyst.net.nz>

2
pagelib.php

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
require_once( $CFG->libdir.'/pagelib.php');
require_once( $CFG->dirroot.'/course/lib.php'); // Needed for some blocks.

2
print.php

@ -16,7 +16,7 @@
/**
* This page export the game to html
*
*
* @author bdaloukas
* @package game
**/

2
report/overview/report.php

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* This script lists student attempts
*

2
showanswers.php

@ -16,7 +16,7 @@
/**
* This page shows the answers of the current game
*
*
* @author bdaloukas
* @package game
**/

2
showattempts.php

@ -16,7 +16,7 @@
/**
* This page shows the answers of the current game
*
*
* @author bdaloukas
* @package game
**/

2
snakes/createboard.php

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
// This file creates a board for "Snakes and Ladders".
function game_createsnakesboard($imageasstring, $colsx, $colsy, $ofstop, $ofsbottom,
$ofsright, $ofsleft, $board, $setwidth, $setheight) {

10
snakes/play.php

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
// This files plays the game "Snakes and Ladders".
function game_snakes_continue( $id, $game, $attempt, $snakes, $context) {
@ -95,9 +97,9 @@ function game_snakes_play( $id, $game, $attempt, $snakes, $context) {
-->
</script>
<table>
<tr>
<td>
<table>
<tr>
<td>
<div id="board" STYLE="position:relative; left:0px;top:0px;
width:<?php p($board->width); ?>px; height:<?php p($board->height); ?>px;">
@ -109,7 +111,7 @@ function game_snakes_play( $id, $game, $attempt, $snakes, $context) {
game_snakes_showdice( $snakes, $board);
}
?>
</td>
</td>
</tr>
</table>
<?php

4
sudoku/class.Sudoku.php

@ -54,6 +54,8 @@
* attempting to distribute clues more optimally.
*/
defined('MOODLE_INTERNAL') || die();
@require_once("SDD/class.SDD.php");
/*
@ -477,7 +479,7 @@ class rcs extends ObjectS{
* @param integer $theRow the row coordinate on the board of the cell.
* @param integer $theColumn the column coordinate on the board of the cell.
* @return integer the degree of coupling between the cell and the rest of the cells
* within the row/column/square.
* within the row/column/square.
*/
public function coupling($therow, $thecolumn) {

27
sudoku/play.php

@ -273,20 +273,19 @@ function game_sudoku_showsudoku( $data, $guess, $bshowlegend, $bshowsolution, $o
$href = $CFG->wwwroot.'/mod/game/attempt.php?action=sudokucheckn&id='.$id;
?>
<script language="javascript">
function OnCheck( pos)
{
s = window.prompt( "<?php echo get_string ( 'sudoku_guessnumber', 'game') ?>", "");
if (s < "1")
return;
if (s > "9")
return;
window.location.href = "<?php echo $href; ?>&pos=" + pos + "&num=" + s;
}
</script>
<?php
<script language="javascript">
function OnCheck( pos) {
s = window.prompt( "<?php echo get_string ( 'sudoku_guessnumber', 'game') ?>", "");
if (s < "1")
return;
if (s > "9")
return;
window.location.href = "<?php echo $href; ?>&pos=" + pos + "&num=" + s;
}
</script>
<?php
// Here are the congratulations.
if ($attempt->timefinish) {

2
sudoku/sdd/class.logfile.php

@ -28,6 +28,8 @@
* Initial version created/
*/
defined('MOODLE_INTERNAL') || die();
require_once('SDD/class.SDD.php');
class logfile extends SDD {

Loading…
Cancel
Save