Browse Source

phpdocs compatibility

MOODLE_20_STABLE
bdaloukas 8 years ago
parent
commit
f1d28dda08
  1. 4
      attempt.php
  2. 16
      backup/moodle2/backup_game_activity_task.class.php
  3. 29
      backup/moodle2/backup_game_settingslib.php
  4. 7
      backup/moodle2/backup_game_stepslib.php
  5. 74
      backup/moodle2/restore_game_stepslib.php
  6. 54
      bookquiz/play.php
  7. 8
      bookquiz/questions.php
  8. 23
      bookquiz/toc.php
  9. 8
      bookquiz/view.php
  10. 12
      classes/event/course_module_instance_list_viewed.php
  11. 2
      classes/event/course_module_viewed.php
  12. 9
      classes/event/game_played.php
  13. 9
      classes/plugininfo/gametool.php
  14. 153
      cross/cross_class.php
  15. 90
      cryptex/cryptexdb_class.php
  16. 47
      cryptex/play.php
  17. 6
      db/access.php
  18. 7
      db/createsnakes.php
  19. 8
      db/importsnakes.php
  20. 8
      db/importsudoku.php
  21. 48
      db/upgrade.php
  22. 10
      export.php
  23. 9
      export/exporthtml.php
  24. 9
      export/exporthtml_hangman.php
  25. 7
      export/exporthtml_millionaire.php
  26. 9
      export/exporthtml_snakes.php
  27. 7
      export/exportjavame.php
  28. 4
      export/html/snakes/css/game.css
  29. 19
      export/html/snakes/css/snakes.css
  30. 8
      export/html/snakes/css/style.css
  31. 20
      export/html/snakes/css/subModal.css
  32. 45
      export/html/snakes/js/snakes-mod.js
  33. 8
      hangman/play.php
  34. 7
      headergame.php
  35. 8
      hiddenpicture/picture.php
  36. 9
      hiddenpicture/play.php
  37. 8
      index.php
  38. 8
      lib.php
  39. 8
      locallib.php
  40. 9
      millionaire/play.php
  41. 8
      preview.php
  42. 7
      print.php
  43. 8
      report/default.php
  44. 8
      report/overview/report.php
  45. 5
      settings.php
  46. 7
      showanswers.php
  47. 8
      showattempts.php
  48. 8
      snakes/createboard.php
  49. 9
      snakes/play.php
  50. 10
      sudoku/class.Sudoku.php
  51. 7
      sudoku/create.php
  52. 8
      sudoku/export.php
  53. 8
      sudoku/play.php
  54. 7
      tabs.php
  55. 7
      translate.php
  56. 4
      version.php

4
attempt.php

@ -18,7 +18,8 @@
* This page prints a particular attempt of game * This page prints a particular attempt of game
* *
* @author bdaloukas * @author bdaloukas
* @package game * @copyright 2007 Vasilis Daloukas
* @package mod_game
**/ **/
require_once( "../../config.php"); require_once( "../../config.php");
require_once( "lib.php"); require_once( "lib.php");
@ -126,6 +127,7 @@ function game_show_header( &$id, &$game, &$course, &$context) {
* *
* @param int $id * @param int $id
* @param stdClass $game * @param stdClass $game
* @param string $action
* @param stdClass $course * @param stdClass $course
* @param stdClass $context * @param stdClass $context
*/ */

16
backup/moodle2/backup_game_activity_task.class.php

@ -15,19 +15,21 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Defines backup_glossary_activity_task class
*
* @package mod_game * @package mod_game
* @subpackage backup-moodle2 * @subpackage backup-moodle2
* class backup_game_activity_task * @copyright 2007 Vasilis Daloukas
* @author * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package game
**/ **/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/game/backup/moodle2/backup_game_stepslib.php'); // Because it exists (must). require_once($CFG->dirroot . '/mod/game/backup/moodle2/backup_game_stepslib.php'); // Because it exists (must).
require_once($CFG->dirroot . '/mod/game/backup/moodle2/backup_game_settingslib.php'); // Because it exists (optional).
/** /**
* Defines backup_game_activity_task class
*
* game backup task that provides all the settings and steps to perform one * game backup task that provides all the settings and steps to perform one
* complete backup of the activity * complete backup of the activity
*/ */
@ -49,8 +51,10 @@ class backup_game_activity_task extends backup_activity_task {
} }
/** /**
* Code the transformations to perform in the activity in * Encodes URLs to the index.php and view.php scripts
* order to get transportable (encoded) links *
* @param string $content some HTML text that eventually contains URLs to the activity instance scripts
* @return string the content with the URLs encoded
*/ */
static public function encode_content_links($content) { static public function encode_content_links($content) {
global $CFG; global $CFG;

29
backup/moodle2/backup_game_settingslib.php

@ -1,29 +0,0 @@
<?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/>.
/**
* @package game
* @subpackage backup-moodle2
* @copyright 2010 onwards YOUR_NAME_GOES_HERE {@link YOUR_URL_GOES_HERE}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/** This activity has not particular settings but the inherited from the generic
* backup_activity_task so here there isn't any class definition, like the ones
* existing in /backup/moodle2/backup_settingslib.php (activities section)
*/
defined('MOODLE_INTERNAL') || die();

7
backup/moodle2/backup_game_stepslib.php

@ -15,13 +15,12 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Define all the backup steps that will be used by the backup_game_activity_task
*
* @package mod_game * @package mod_game
* @subpackage backup-moodle2 * @subpackage backup-moodle2
* @author bdaloukas * @author bdaloukas
*/ backup_game_settingslib.php
/**
* Define all the backup steps that will be used by the backup_game_activity_task
*/ */
/** /**

74
backup/moodle2/restore_game_stepslib.php

@ -15,6 +15,8 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Define all the restore steps that will be used by the restore_game_activity_task
*
* @package mod_game * @package mod_game
* @subpackage backup-moodle2 * @subpackage backup-moodle2
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@ -22,10 +24,6 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/**
* Define all the restore steps that will be used by the restore_game_activity_task
*/
/** /**
* Structure step to restore one game activity * Structure step to restore one game activity
*/ */
@ -67,6 +65,8 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game table. * Restores the game table.
*
* @param stdClass $data
*/ */
protected function process_game($data) { protected function process_game($data) {
global $DB; global $DB;
@ -85,6 +85,8 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_export_html table. * Restores the game_export_html table.
*
* @param stdClass $data
*/ */
protected function process_game_export_html($data) { protected function process_game_export_html($data) {
global $DB; global $DB;
@ -99,8 +101,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_export_javame table. * Restores the game_export_javame table.
*
* @param stdClass $game
*/ */
protected function process_game_export_javame($data) { protected function process_game_export_javame( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -113,8 +117,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_grades table. * Restores the game_grades table.
*
* @param stdClass $data
*/ */
protected function process_game_grade($data) { protected function process_game_grade( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -128,8 +134,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_repetitions table. * Restores the game_repetitions table.
*
* @param stdClass $data
*/ */
protected function process_game_repetition($data) { protected function process_game_repetition( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -143,8 +151,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_attempts table. * Restores the game_attempts table.
*
* @param stdClass $data
*/ */
protected function process_game_attempt($data) { protected function process_game_attempt( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -173,8 +183,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_queries table. * Restores the game_queries table.
*
* @param stdClass $data
*/ */
protected function process_game_query($data) { protected function process_game_query( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -190,8 +202,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_bookquiz table. * Restores the game_bookquiz table.
*
* @param stdClass $data
*/ */
protected function process_game_bookquiz($data) { protected function process_game_bookquiz( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -203,8 +217,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_bookauiz_chapters table. * Restores the game_bookauiz_chapters table.
*
* @param stdClass $data
*/ */
protected function process_game_bookquiz_chapter($data) { protected function process_game_bookquiz_chapter( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -216,8 +232,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_bookquiz_questions table. * Restores the game_bookquiz_questions table.
*
* @param stdClass $data
*/ */
protected function process_game_bookquiz_question($data) { protected function process_game_bookquiz_question( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -229,8 +247,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_cross table. * Restores the game_cross table.
*
* @param stdClass $data
*/ */
protected function process_game_cross($data) { protected function process_game_cross( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -242,8 +262,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_cryptex table. * Restores the game_cryptex table.
*
* @param stdClass $data
*/ */
protected function process_game_cryptex($data) { protected function process_game_cryptex( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -255,8 +277,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_hangman table. * Restores the game_hangman table.
*
* @param stdClass $data
*/ */
protected function process_game_hangman($data) { protected function process_game_hangman( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -269,8 +293,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_hiddenpicture table. * Restores the game_hiddenpicture table.
*
* @param stdClass $data
*/ */
protected function process_game_hiddenpicture($data) { protected function process_game_hiddenpicture( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -282,8 +308,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_millionaire table. * Restores the game_millionaire table.
*
* @param stdClass $data
*/ */
protected function process_game_millionaire($data) { protected function process_game_millionaire( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -296,8 +324,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_snakes table. * Restores the game_snakes table.
*
* @param stdClass $data
*/ */
protected function process_game_snake($data) { protected function process_game_snake( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -310,8 +340,10 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
/** /**
* Restores the game_sudoku table. * Restores the game_sudoku table.
*
* @param stdClass $data
*/ */
protected function process_game_sudoku($data) { protected function process_game_sudoku( $data) {
global $DB; global $DB;
$data = (object)$data; $data = (object)$data;
@ -321,7 +353,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st
$DB->insert_record('game_sudoku', $data); $DB->insert_record('game_sudoku', $data);
} }
// Add Game related files, no need to match by itemname (just internally handled context). /**
* Add Game related files, no need to match by itemname (just internally handled context).
*/
protected function after_execute() { protected function after_execute() {
$this->add_related_files('mod_game', 'snakes_file', null); $this->add_related_files('mod_game', 'snakes_file', null);
$this->add_related_files('mod_game', 'snakes_board', null); $this->add_related_files('mod_game', 'snakes_board', null);

54
bookquiz/play.php

@ -16,6 +16,17 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/**
* Plays the game bookquiz.
*
* @param int $id
* @param stdClass $game
* @param stdClass $attempt
* @param stdClass $bookquiz
* @param int $bookquizid
* @param int $chapterid
* @param stdClass $context
*/
function game_bookquiz_continue( $id, $game, $attempt, $bookquiz, $chapterid, $context) { function game_bookquiz_continue( $id, $game, $attempt, $bookquiz, $chapterid, $context) {
if ($attempt != false and $bookquiz != false) { if ($attempt != false and $bookquiz != false) {
return game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $context); return game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $context);
@ -37,6 +48,16 @@ function game_bookquiz_continue( $id, $game, $attempt, $bookquiz, $chapterid, $c
return game_bookquiz_play( $id, $game, $attempt, $bookquiz, 0, $context); return game_bookquiz_play( $id, $game, $attempt, $bookquiz, 0, $context);
} }
/**
* Plays the game bookquiz.
*
* @param int $id
* @param stdClass $game
* @param stdClass $attempt
* @param stdClass $bookquiz
* @param int $chapterid
* @param stdClass $context
*/
function game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $context) { function game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $context) {
global $DB, $OUTPUT, $cm; global $DB, $OUTPUT, $cm;
@ -240,6 +261,12 @@ function game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $conte
} }
} }
/**
* Computes the last chapter.
*
* @param stdClass $game
* @param stdClass $bookquiz
*/
function game_bookquiz_play_computelastchapter( $game, &$bookquiz) { function game_bookquiz_play_computelastchapter( $game, &$bookquiz) {
global $DB; global $DB;
@ -262,6 +289,17 @@ function game_bookquiz_play_computelastchapter( $game, &$bookquiz) {
} }
} }
/**
* Shows questions.
*
* @param int $id
* @param int $questionid
* @param int $chapterid
* @param int $nextchapterid
* @param int $scoreattempt
* @param stdClass $game
* @param stdClass $context
*/
function game_bookquiz_showquestions( $id, $questionid, $chapterid, $nextchapterid, $scoreattempt, $game, $context) { function game_bookquiz_showquestions( $id, $questionid, $chapterid, $nextchapterid, $scoreattempt, $game, $context) {
$onlyshow = false; $onlyshow = false;
$showsolution = false; $showsolution = false;
@ -306,6 +344,13 @@ function game_bookquiz_showquestions( $id, $questionid, $chapterid, $nextchapter
echo "</form>\n"; echo "</form>\n";
} }
/**
* Selects random one question from the input list.
*
* @param array $questions
*
* @return the position of the random question.
*/
function game_bookquiz_selectrandomquestion( $questions) { function game_bookquiz_selectrandomquestion( $questions) {
global $DB; global $DB;
@ -333,6 +378,15 @@ function game_bookquiz_selectrandomquestion( $questions) {
} }
} }
/**
* Check if the answers are correct.
*
* @param int $id
* @param stdClass $game
* @param stdClass $attempt
* @param stdClass $bookquiz
* @param stdClass $context
*/
function game_bookquiz_check_questions( $id, $game, $attempt, $bookquiz, $context) { function game_bookquiz_check_questions( $id, $game, $attempt, $bookquiz, $context) {
global $USER, $DB; global $USER, $DB;

8
bookquiz/questions.php

@ -123,6 +123,14 @@ if (($recs = $DB->get_records( 'book_chapters', array('bookid' => $game->bookid)
echo $OUTPUT->footer($course); echo $OUTPUT->footer($course);
/**
* Save infos to database.
*
* @param int $gameid
* @param int $bookid
* @param array $ids
* @param stdClass $form
*/
function game_bookquiz_save( $gameid, $bookid, $ids, $form) { function game_bookquiz_save( $gameid, $bookid, $ids, $form) {
global $DB; global $DB;

23
bookquiz/toc.php

@ -14,6 +14,14 @@
// 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/>.
/**
* Table of contents.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
define('NUM_NONE', '0'); define('NUM_NONE', '0');
@ -21,21 +29,6 @@ define('NUM_NUMBERS', '1');
define('NUM_BULLETS', '2'); define('NUM_BULLETS', '2');
define('NUM_INDENTED', '3'); define('NUM_INDENTED', '3');
/* Included from mod/book/view.php and print.php.
*
* uses:
* $chapters - all book chapters
* $chapter - may be false
* $cm - course module
* $book - book
* $edit - force editing view
*
* fills:
* $toc
* $title (not for print)
*/
$currtitle = ''; // Active chapter title (plain text). $currtitle = ''; // Active chapter title (plain text).
$currsubtitle = ''; // Active subchapter if any. $currsubtitle = ''; // Active subchapter if any.
$prevtitle = '&nbsp;'; $prevtitle = '&nbsp;';

8
bookquiz/view.php

@ -14,6 +14,14 @@
// 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/>.
/**
* View a bookquiz.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php'); require_once('../../config.php');
require_once('lib.php'); require_once('lib.php');

12
classes/event/course_module_instance_list_viewed.php

@ -31,10 +31,18 @@ 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
* @since Moodle 2.7 * @copyright 2007 Vasilis Daloukas
* @copyright 2014 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
/**
* The mod_game instance list viewed event class.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
public static function create_from_course(\stdClass $course) { public static function create_from_course(\stdClass $course) {
$params = array( $params = array(

2
classes/event/course_module_viewed.php

@ -20,7 +20,7 @@
* The mod_game course module viewed event. * The mod_game course module viewed event.
* *
* @package mod_game * @package mod_game
* @copyright 2014 Vasilis Daloukas * @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */

9
classes/event/game_played.php

@ -47,6 +47,15 @@ class game_played extends \core\event\base {
"course module id '$this->contextinstanceid'."; "course module id '$this->contextinstanceid'.";
} }
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \stdClass $game
* @param \context_module $context
* @return event
*/
public static function played(\stdClass $game, \context_module $context) { public static function played(\stdClass $game, \context_module $context) {
$data = array( $data = array(
'context' => $context, 'context' => $context,

9
classes/plugininfo/gametool.php

@ -29,7 +29,14 @@ use core\plugininfo\base;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/**
* The mod_game gametool.
*
* @package mod_game
* @since Moodle 2.6
* @copyright 2014 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gametool extends base { class gametool extends base {
public function is_uninstall_allowed() { public function is_uninstall_allowed() {
return true; return true;

153
cross/cross_class.php

@ -26,8 +26,13 @@ Codewalkers PHP Coding Contest of July 2002
Author Àngel Fenoy from Arenys de Mar, Barcelona. Author Àngel Fenoy from Arenys de Mar, Barcelona.
*/ */
defined('MOODLE_INTERNAL') || die(); /**
* The class cross computes a crossword.
*
* @package mod_game
* @copyright 2014 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class Cross class Cross
{ {
public $minputanswers; // Contains the words and the answers. public $minputanswers; // Contains the words and the answers.
@ -58,6 +63,15 @@ class Cross
public $mreps; // Repetition of each word. public $mreps; // Repetition of each word.
public $maveragereps; // Average of repetitions. public $maveragereps; // Average of repetitions.
/**
* Set words for computing.
*
* @param array $answers
* @param int $maxcols
* @param array reps
*
* @return \moodle_url
*/
public function setwords( $answers, $maxcols, $reps) { public function setwords( $answers, $maxcols, $reps) {
$this->mreps = array(); $this->mreps = array();
foreach ($reps as $word => $r) { foreach ($reps as $word => $r) {
@ -114,6 +128,9 @@ class Cross
return count( $this->mwords); return count( $this->mwords);
} }
/**
* Randomizes the words.
*/
public function randomize() { public function randomize() {
$n = count( $this->mwords); $n = count( $this->mwords);
for ($j = 0; $j <= $n / 4; $j++) { for ($j = 0; $j <= $n / 4; $j++) {
@ -123,6 +140,18 @@ class Cross
} }
} }
/**
* Compute one crossword.
*
* @param stdClass crossm
* @param stdClass crossm
* @param string $letters
* @param int minwords
* @param int maxwords
* @param int mtimelimit
*
* @return the crossword
*/
public function computedata( &$crossm, &$crossd, &$letters, $minwords, $maxwords, $mtimelimit=3) { public function computedata( &$crossm, &$crossd, &$letters, $minwords, $maxwords, $mtimelimit=3) {
$t1 = time(); $t1 = time();
@ -141,7 +170,7 @@ class Cross
// Selects the size of the cross. // Selects the size of the cross.
$n20 = mt_rand( $this->mn20min, $this->mn20max); $n20 = mt_rand( $this->mn20min, $this->mn20max);
if (!$this->computenextcross( $n20, $t1, $ctries, $minwords, $maxwords, $nochange)) { if (!$this->computenextcross( $n20, $ctries, $minwords, $maxwords, $nochange)) {
break; break;
} }
@ -160,7 +189,18 @@ class Cross
return $this->savepuzzle( $crossm, $crossd, $ctries, time() - $t1); return $this->savepuzzle( $crossm, $crossd, $ctries, time() - $t1);
} }
public function computenextcross( $n20, $t1, $ctries, $minwords, $maxwords, &$nochange) { /**
* Compute the next crossword.
*
* @param int $n20
* @param int $ctries
* @param int $minwords
* @param int $maxwords
* @param int &$nochange
*
* @return \moodle_url
*/
public function computenextcross( $n20, $ctries, $minwords, $maxwords, &$nochange) {
$maxw = $n20; $maxw = $n20;
$n21 = $n20 + 1; $n21 = $n20 + 1;
@ -247,6 +287,22 @@ class Cross
return true; return true;
} }
/**
* Compute the scrore of one crossword.
*
* @param string $puzzle
* @param int $n20
* @param int $n22
* @param int $n2222
* @param int $nwords
* @param int @$nconnectors
* @param int @$nfilleds
* @param int @$cspaces
* @param stdClass $crossword
* @param array reps
*
* @return \moodle_url
*/
public function computescore( $puzzle, $n20, $n22, $n2222, $nwords, &$nconnectors, &$nfilleds, &$cspaces, $crossword) { public function computescore( $puzzle, $n20, $n22, $n2222, $nwords, &$nconnectors, &$nfilleds, &$cspaces, $crossword) {
$nconnectors = $nfilleds = 0; $nconnectors = $nfilleds = 0;
$puzzle00 = str_replace('.', '0', $puzzle); $puzzle00 = str_replace('.', '0', $puzzle);
@ -279,6 +335,15 @@ class Cross
return $score - 10 * $sumrep; return $score - 10 * $sumrep;
} }
/**
* Compute puzzle info.
*
* @param int $n20
* @param int $crosspos
* @param int $crossdir
* @param stdClass $crossword
* @param boolean bprint
*/
public function computepuzzleinfo( $n20, $crosspos, $crossdir, $crossword, $bprint=false) { public function computepuzzleinfo( $n20, $crosspos, $crossdir, $crossword, $bprint=false) {
$bprint = false; $bprint = false;
$n22 = $n20 + 2; $n22 = $n20 + 2;
@ -344,6 +409,14 @@ class Cross
} }
} }
/**
* Save the crossword to database.
*
* @param array &$crossm
* @param array &$crossd
* @param int ctries
* @param int time
*/
public function savepuzzle( &$crossm, &$crossd, $ctries, $time) { public function savepuzzle( &$crossm, &$crossd, $ctries, $time) {
$n22 = $this->mbestn20 + 2; $n22 = $this->mbestn20 + 2;
@ -410,12 +483,24 @@ class Cross
return (count( $crossd) > 0); return (count( $crossd) > 0);
} }
/**
* Swaps two variables.
*
* @param $a
* @param $b
*/
public function swap( &$a, &$b) { public function swap( &$a, &$b) {
$temp = $a; $temp = $a;
$a = $b; $a = $b;
$b = $temp; $b = $temp;
} }
/**
* Displays a crossword.
*
* @param sting $puzzle
* @param int $n20
*/
public function displaycross($puzzle, $n20) { public function displaycross($puzzle, $n20) {
$n21 = $n20 + 1; $n21 = $n20 + 1;
$n22 = $n20 + 2; $n22 = $n20 + 2;
@ -453,6 +538,23 @@ class Cross
return $ret.'</tr></table>'; return $ret.'</tr></table>';
} }
/**
* Scans a positions.
*
* @param int $pos
* @param int $dir
* @param int $valblanc
* @param string &$puzzle
* @param array &$words
* @param &$magics
* @param poss
* @param #ccrosspos
* @param crossdir
* @param crosssword
* @param int $n20
*
* @return true if it is ok.
*/
public function scan_pos($pos, $dir, $valblanc, &$puzzle, &$words, &$magics, public function scan_pos($pos, $dir, $valblanc, &$puzzle, &$words, &$magics,
&$poss, &$crosspos, &$crossdir, &$crossword, $n20) { &$poss, &$crosspos, &$crossdir, &$crossword, $n20) {
@ -578,6 +680,15 @@ class Cross
return false; return false;
} }
/**
* my_preg_match (backward compatibility).
*
* @param $w
* @param @words
* @param &$word
*
* @return true if it is ok.
*/
public function my_preg_match( $w, $words, &$word) { public function my_preg_match( $w, $words, &$word) {
$a = explode( ";", $words); $a = explode( ";", $words);
$lenw = game_strlen( $w); $lenw = game_strlen( $w);
@ -604,6 +715,13 @@ class Cross
return false; return false;
} }
/**
* Set a char to the specified position.
*
* @param @$s
* @param int $pos
* @param char $char
*/
public function setchar( &$s, $pos, $char) { public function setchar( &$s, $pos, $char) {
$ret = ""; $ret = "";
@ -614,6 +732,17 @@ class Cross
$s = $ret . $char . game_substr( $s, $pos + 1, game_strlen( $s) - $pos - 1); $s = $ret . $char . game_substr( $s, $pos + 1, game_strlen( $s) - $pos - 1);
} }
/**
* Show html base.
*
* @param $crossm
* @param $crossd
* @param boolean $showsolution
* @param boolean $showhtmlsolutions
* @param boolean $showstudentguess
* @param stdClass $context
* @param stdClass $game
*/
public function showhtml_base( $crossm, $crossd, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game) { public function showhtml_base( $crossm, $crossd, $showsolution, $showhtmlsolutions, $showstudentguess, $context, $game) {
$this->mLegendh = array(); $this->mLegendh = array();
$this->mLegendv = array(); $this->mLegendv = array();
@ -735,10 +864,26 @@ class Cross
return $sret; return $sret;
} }
/**
* Compares length of two strings.
*
* @param string $a
* @param string $b
*
* @return -1 if a < b, 0 if equal
*/
public function cmp($a, $b) { public function cmp($a, $b) {
return game_strlen($b) - game_strlen($a); return game_strlen($b) - game_strlen($a);
} }
/**
* Compares two strings with random
*
* @param string $a
* @param string $b
*
* @return -1 if a < b, 0 if equal
*/
public function cmp_magic($a, $b) { public function cmp_magic($a, $b) {
return (game_strlen($a) + mt_rand(0, 3)) - (game_strlen($b) - mt_rand(0, 1)); return (game_strlen($a) + mt_rand(0, 3)) - (game_strlen($b) - mt_rand(0, 1));
} }

90
cryptex/cryptexdb_class.php

@ -16,7 +16,25 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/**
* The class CryptexDB loads/save the cryptex from/to database.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class CryptexDB extends CrossDB { class CryptexDB extends CrossDB {
/**
* Save cryptex.
*
* @param stdClass $game
* @param array &$crossm
* @param array &$crossd
* @param int id
* @param $letters
*
* @return the saved record
*/
public function savecryptex( $game, &$crossm, $crossd, $id, $letters) { public function savecryptex( $game, &$crossm, $crossd, $id, $letters) {
global $USER; global $USER;
@ -39,6 +57,14 @@ class CryptexDB extends CrossDB {
return $newrec; return $newrec;
} }
/**
* Compute letters.
*
* @param array &$crossm
* @param array &$crossd
*
* @return the letters.
*/
public function computeletters( $crossm, $crossd) { public function computeletters( $crossm, $crossd) {
$letters = ''; $letters = '';
$cols = $crossm->cols + 1; $cols = $crossm->cols + 1;
@ -97,6 +123,16 @@ class CryptexDB extends CrossDB {
return $retletters; return $retletters;
} }
/**
* Displays the cryptex.
*
* @param $cols
* @param $rows
* @param $letters
* @param $mask
* @param boolean $showsolution
* @param $textdir
*/
public function displaycryptex( $cols, $rows, $letters, $mask, $showsolution, $textdir) { public function displaycryptex( $cols, $rows, $letters, $mask, $showsolution, $textdir) {
echo "<table border=1 $textdir>"; echo "<table border=1 $textdir>";
for ($row = 0; $row < $rows; $row++) { for ($row = 0; $row < $rows; $row++) {
@ -119,6 +155,15 @@ class CryptexDB extends CrossDB {
echo "</table>"; echo "</table>";
} }
/**
* Inserts a char.
*
* @param $letters
* @param $cols
* @param $rows
* @param $char
* @param int &$spaces
*/
public function insertchar( &$letters, $cols, $rows, $char, &$spaces) { public function insertchar( &$letters, $cols, $rows, $char, &$spaces) {
$len = game_strlen( $letters); $len = game_strlen( $letters);
for ($i = 0; $i < $len; $i++) { for ($i = 0; $i < $len; $i++) {
@ -130,6 +175,15 @@ class CryptexDB extends CrossDB {
} }
} }
/**
* Inserts chars.
*
* @param $letters
* @param $cols
* @param $rows
* @param $char
* @param int &$spaces
*/
public function insertchars( &$letters, $cols, $rows, $char, &$spaces) { public function insertchars( &$letters, $cols, $rows, $char, &$spaces) {
$len = game_strlen( $letters); $len = game_strlen( $letters);
for ($i = 0; $i < $len; $i++) { for ($i = 0; $i < $len; $i++) {
@ -150,6 +204,13 @@ class CryptexDB extends CrossDB {
return false; return false;
} }
/**
* Gets the hash of a word.
*
* @param string $word
*
* @return the hash
*/
public function gethash( $word) { public function gethash( $word) {
$x = 37; $x = 37;
$len = count( game_strlen( $word)); $len = count( game_strlen( $word));
@ -161,6 +222,16 @@ class CryptexDB extends CrossDB {
return $x; return $x;
} }
/**
* Loads the cryptex from database.
*
* @param array $crossm
* @param &$mask
* @param &$corrects
* @param &$language
*
* @return questions
*/
public function loadcryptex( $crossm, &$mask, &$corrects, &$language) { public function loadcryptex( $crossm, &$mask, &$corrects, &$language) {
global $DB; global $DB;
@ -206,10 +277,29 @@ class CryptexDB extends CrossDB {
return $questions; return $questions;
} }
/**
* Calss the setwords of class Cross.
*
* @param $answers
* @param $maxcols
* @param $reps
*
* @return Cross::setwords
*/
public function setwords( $answers, $maxcols, $reps) { public function setwords( $answers, $maxcols, $reps) {
return Cross::setwords( $answers, $maxcols, $reps); return Cross::setwords( $answers, $maxcols, $reps);
} }
/**
* Calss the computedata of class Cross.
*
* @param &$crossm
* @param &$crossd
* @param &$letters
* @param $minwords
* @param $maxwords
* @param $mtimelimit
*/
public function computedata( &$crossm, &$crossd, &$letters, $minwords, $maxwords, $mtimelimit=3) { public function computedata( &$crossm, &$crossd, &$letters, $minwords, $maxwords, $mtimelimit=3) {
if (!cross::computedata( $crossm, $crossd, $letters, $minwords, $maxwords, $mtimelimit)) { if (!cross::computedata( $crossm, $crossd, $letters, $minwords, $maxwords, $mtimelimit)) {
return false; return false;

47
cryptex/play.php

@ -25,6 +25,16 @@ defined('MOODLE_INTERNAL') || die();
require_once( "cryptexdb_class.php"); require_once( "cryptexdb_class.php");
/**
* Plays the game cryptex.
*
* @param int $id
* @param stdClass $game
* @param stdClass $atttempt
* @param $cryptexrec
* @param $endofgame
* @param stdClass $context
*/
function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $context) { function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $context) {
global $DB, $USER; global $DB, $USER;
@ -99,7 +109,18 @@ function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $
return game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm, false, false, false, $context); return game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm, false, false, false, $context);
} }
// The q means game_queries.id. /**
* Checks if is correct.
*
* @param int $id
* @param stdClass $game
* @param stdClass $atttempt
* @param $cryptexrec
* @param $q (The q means game_queries.id).
* @param $answer
* @param $finishattempt
* @param stdClass $context
*/
function game_cryptex_check( $id, $game, $attempt, $cryptexrec, $q, $answer, $finishattempt, $context) { function game_cryptex_check( $id, $game, $attempt, $cryptexrec, $q, $answer, $finishattempt, $context) {
global $DB; global $DB;
@ -144,6 +165,21 @@ function game_cryptex_check( $id, $game, $attempt, $cryptexrec, $q, $answer, $fi
game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm, true, $onlyshow, $showsolution, $context); game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm, true, $onlyshow, $showsolution, $context);
} }
/**
* Plays the game cryptex.
*
* @param int $id
* @param stdClass $game
* @param stdClass $atttempt
* @param $cryptexrec
* @param $crosssm
* @param boolean $updateattempt
* @param boolean $onlyshow
* @param boolean $showsolution
* @param stdClass $context
* @param boolean $print
* @param boolean $showhtmlprintbutton
*/
function game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm, function game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm,
$updateattempt = false, $onlyshow = false, $showsolution = false, $context, $updateattempt = false, $onlyshow = false, $showsolution = false, $context,
$print = false, $showhtmlprintbutton = true) { $print = false, $showhtmlprintbutton = true) {
@ -366,7 +402,14 @@ if ($print) {
echo '<body>'; echo '<body>';
} }
} }
/**
* On finished.
*
* @param int $id
* @param stdClass $game
* @param stdClass $atttempt
* @param $cryptexrec
*/
function game_cryptex_onfinished( $id, $game, $attempt, $cryptexrec) { function game_cryptex_onfinished( $id, $game, $attempt, $cryptexrec) {
global $CFG, $DB; global $CFG, $DB;

6
db/access.php

@ -17,9 +17,11 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/* /*
* Capability definitions for the game module. * Plugin capabilities
* *
* For naming conventions, see lib/db/access.php. * @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
$capabilities = array( $capabilities = array(

7
db/createsnakes.php

@ -14,6 +14,13 @@
// 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/>.
/**
* Creates the snakes database.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require( "../../../config.php"); require( "../../../config.php");
require_login(); require_login();
execute_sql("truncate TABLE {game_snakes_database}"); execute_sql("truncate TABLE {game_snakes_database}");

8
db/importsnakes.php

@ -14,6 +14,14 @@
// 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/>.
/**
* Imports the snakes database.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
game_importsnakes(); game_importsnakes();

8
db/importsudoku.php

@ -14,6 +14,14 @@
// 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/>.
/**
* Imports the sudoku database.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$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, ".

48
db/upgrade.php

@ -13,24 +13,30 @@
// //
// 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/>.
//
// Sometimes, changes between versions involve
// alterations to database structures and other
// major things that may break installations.
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
// your older installation to the current version.
//
// If there's something it cannot do itself, it
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
// using the methods of database_manager class
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
/* This file keeps track of upgrades to the game module /**
* Sometimes, changes between versions involve * This file keeps track of upgrades to the game module
* alterations to database structures and other
* major things that may break installations.
* *
* The upgrade function in this file will attempt * @package mod_game
* to perform all the necessary actions to upgrade * @copyright 2007 Vasilis Daloukas
* your older installation to the current version. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* If there's something it cannot do itself, it
* will tell you what you need to do.
*
* The commands in here will all be database-neutral,
* using the methods of database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
@ -853,16 +859,6 @@ function xmldb_game_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2007111310, 'game'); upgrade_mod_savepoint(true, 2007111310, 'game');
} }
if ($oldversion < 2007111303) {
$table = new xmldb_table('game');
$field = new xmldb_field('bottomtext', XMLDB_TYPE_TEXT);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2007111303, 'game');
}
if ($oldversion < 2007111842) { if ($oldversion < 2007111842) {
$table = new xmldb_table( 'game_queries'); $table = new xmldb_table( 'game_queries');
$field = new xmldb_field( 'gameinstanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0'); $field = new xmldb_field( 'gameinstanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0');

10
export.php

@ -14,13 +14,13 @@
// 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/>.
/* /**
* This page exports a game to another platform e.g. html, jar * This page exports a game to another platform e.g. html, jar
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php'); require_once(dirname(__FILE__) . '/../../config.php');
ob_start(); ob_start();

9
export/exporthtml.php

@ -14,12 +14,13 @@
// 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/>.
/* /**
* This page export the game to html for games: cross, hangman * This page export the game to html for games: cross, hangman
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

9
export/exporthtml_hangman.php

@ -14,12 +14,13 @@
// 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/>.
/* /**
* This page export the game hangman to html * This page export the game hangman to html
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

7
export/exporthtml_millionaire.php

@ -17,9 +17,10 @@
/** /**
* This page export the game millionaire to html * This page export the game millionaire to html
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

9
export/exporthtml_snakes.php

@ -14,12 +14,13 @@
// 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/>.
/* /**
* This page export the game snakes to html * This page export the game snakes to html
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

7
export/exportjavame.php

@ -17,9 +17,10 @@
/** /**
* This page export the game to javame for mobile phones * This page export the game to javame for mobile phones
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

4
export/html/snakes/css/game.css

@ -19,8 +19,8 @@
background-repeat: repeat; background-repeat: repeat;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-weight: normal; font-weight: normal;
color: #ffffff; color: #fff;
border: 0.5em solid #333333; border: 0.5em solid #333;
top: 30px; top: 30px;
position: absolute; position: absolute;
left: 500px; left: 500px;

19
export/html/snakes/css/snakes.css

@ -37,7 +37,7 @@ Any Duplication of this code should be avoided*/
} }
body { body {
background:#cccccc; background:#ccc;
} }
#player { #player {
@ -58,8 +58,8 @@ body {
background-repeat: repeat; background-repeat: repeat;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-weight: bold; font-weight: bold;
color: #ffffff; color: #fff;
border: 0.5em solid #333333; border: 0.5em solid #333;
top: 30px; top: 30px;
position: absolute; position: absolute;
right: 880px; right: 880px;
@ -69,8 +69,8 @@ body {
margin-left: 0.5em; margin-left: 0.5em;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-weight: bold; font-weight: bold;
color: #000000; color: #000;
background-color: #FC0; background-color: #fc0;
padding: 1em; padding: 1em;
} }
@ -79,13 +79,16 @@ body {
#fade { /*--Transparent background layer--*/ #fade { /*--Transparent background layer--*/
display: none; /*--hidden by default--*/ display: none; /*--hidden by default--*/
background: #000; background: #000;
position: fixed; left: 0; top: 0; position: fixed;
width: 100%; height: 100%; left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: .80; opacity: .80;
z-index: 9999; z-index: 9999;
} }
.popup_block{ .popup_block {
display: none; /*--hidden by default--*/ display: none; /*--hidden by default--*/
background: #fff; background: #fff;
padding: 20px; padding: 20px;

8
export/html/snakes/css/style.css

@ -2,14 +2,16 @@ body {
background-color: #efefef; background-color: #efefef;
} }
body, html, input { body,
html,
input {
font-family: Verdana, Arial, Helvetica, sans-serif; font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px; font-size: 11px;
color: #333333; color: #333;
} }
.info { .info {
font-style: italic; font-style: italic;
font-size: 0.9em; font-size: 0.9em;
color: #666666; color: #666;
} }

20
export/html/snakes/css/subModal.css

@ -4,8 +4,8 @@
#popupMask { #popupMask {
position: absolute; position: absolute;
z-index: 200; z-index: 200;
top: 0px; top: 0;
left: 0px; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
opacity: .4; opacity: .4;
@ -15,12 +15,12 @@
* than the PNG solution. * than the PNG solution.
*/ */
background-color:transparent !important; background-color:transparent !important;
background-color: #333333; background-color: #333;
/* this hack is for opera support /* this hack is for opera support
* you can uncomment the background-image if you don't care about opera. * you can uncomment the background-image if you don't care about opera.
* this gives you the flexibility to use any bg color that you want, instead of the png * this gives you the flexibility to use any bg color that you want, instead of the png
*/ */
background-image/**/: url("../images/maskBG.png") !important; // For browsers Moz, Opera, etc. background-image: url("../images/maskBG.png") !important; // For browsers Moz, Opera, etc.
background-image:none; background-image:none;
background-repeat: repeat; background-repeat: repeat;
display:none; display:none;
@ -29,14 +29,14 @@
#popupContainer { #popupContainer {
position: absolute; position: absolute;
z-index: 201; z-index: 201;
top: 0px; top: 0;
left: 0px; left: 0;
display:none; display:none;
padding: 0px; padding: 0;
} }
#popupInner { #popupInner {
border: 2px solid #000000; border: 2px solid #000;
background-color: #ffffff; background-color: #fff;
} }
#popupFrame { #popupFrame {
@ -52,7 +52,7 @@
font-weight: bold; font-weight: bold;
height: 1.3em; height: 1.3em;
padding: 5px; padding: 5px;
border-bottom: 2px solid #000000; border-bottom: 2px solid #000;
border-top: 1px solid #7878a3f2; border-top: 1px solid #7878a3f2;
border-left: 1px solid #7878a3f2; border-left: 1px solid #7878a3f2;
border-right: 1px solid #204095; border-right: 1px solid #204095;

45
export/html/snakes/js/snakes-mod.js

@ -5,7 +5,6 @@ Husain Limdiyawala(MSc IT DA-IICT) */
var totblocks = 0; var totblocks = 0;
var data = ""; var data = "";
var currentblock = 0; var currentblock = 0;
var position = 0;
var lastposition = new Array(); var lastposition = new Array();
var randomno = 0; var randomno = 0;
var tots = new Array(); var tots = new Array();
@ -16,8 +15,8 @@ var destsnake = new Array(4);
var ladsrc = new Array(3); var ladsrc = new Array(3);
var laddest = new Array(3); var laddest = new Array(3);
var quest = new Array(); // Available questions along with multiple answers. var quest = new Array(); // Available questions along with multiple answers.
var cor_answered = new Array(); // Record all questions (along with answers) the user responded CORRECTLY. var coranswered = new Array(); // Record all questions (along with answers) the user responded CORRECTLY.
var wro_answered = new Array(); // Record all questions (along with answers) the user responded WRONGLY. var wroanswered = new Array(); // Record all questions (along with answers) the user responded WRONGLY.
var user = new Array(); var user = new Array();
// Constract table with questions and answers and pick question to display. // Constract table with questions and answers and pick question to display.
@ -38,9 +37,14 @@ quest[12] = "Spell 4";
quest[13] = "four"; quest[13] = "four";
quest[14] = "three"; quest[14] = "three";
quest[15] = "one"; quest[15] = "one";
z = 0;
for (z = 0; quest[z] != null; z++) { var z = 0;
// Do nothing. var allQuest;
for () {
if (quest[z] === null) {
break;
}
} }
allQuest = z / 4; allQuest = z / 4;
@ -65,6 +69,8 @@ function hideAll() {
// The Below Function will Render The Main Board. // The Below Function will Render The Main Board.
function paintBoard(a) { function paintBoard(a) {
var j;
totblocks = (a * a); totblocks = (a * a);
if ((a * a) % 2 == 0) { if ((a * a) % 2 == 0) {
currentblock = (a * a) - a + 1; currentblock = (a * a) - a + 1;
@ -105,9 +111,9 @@ function paintBoard(a) {
document.getElementById("cont").style.width = (a * 52 + 52) + "px" document.getElementById("cont").style.width = (a * 52 + 52) + "px"
document.getElementById("cont").innerHTML = data; document.getElementById("cont").innerHTML = data;
$("#cont").slideDown("slow"); $("#cont").slideDown( "slow");
$("#cont").effect("shake",3000); $("#cont").effect( "shake",3000);
$("img:hidden").fadeIn(5000); $("img:hidden").fadeIn( 5000);
if (a == 6) { if (a == 6) {
registerSnake(158, 196, "img1", 14, 3, 0); registerSnake(158, 196, "img1", 14, 3, 0);
@ -188,22 +194,6 @@ function laddercheck(k) {
} }
} }
// The below Function checks for pythons.
function pythoncheck(k) {
i = 0;
for (i = 0; i < pythons.length; i++) {
if (pythons[i] == tots[k]) {
alert("You have been eaten up by a python.Your game is over");
document.getElementById(tots[k]).style.background = "url(images/csnake.gif) #000000";
lastposition[k] = null;
tots[k] = null;
break;
}
}
}
// The below function will register a snake. // The below function will register a snake.
function registerSnake(tp, lft, dv, src, dest, i) { function registerSnake(tp, lft, dv, src, dest, i) {
document.getElementById(dv).style.top = tp + "px"; document.getElementById(dv).style.top = tp + "px";
@ -225,7 +215,6 @@ function selectBoard() {
totblocks = 0; totblocks = 0;
data = ""; data = "";
currentblock = 0; currentblock = 0;
position = 0;
hideAll(); hideAll();
if (document.getElementById("boardtype").value != null) { if (document.getElementById("boardtype").value != null) {
@ -307,10 +296,10 @@ function question() {
alert("Σωστά!") alert("Σωστά!")
doit(l); doit(l);
cor_answered.concat(quest.splice(picked * 4, 4)); coranswered.concat(quest.splice(picked * 4, 4));
} else { } else {
alert("Η απάντηση δεν ήταν σωστή. Χάνεις τη σειρά σου για αυτό το γύρο!") alert("Η απάντηση δεν ήταν σωστή. Χάνεις τη σειρά σου για αυτό το γύρο!")
wro_answered.concat(quest.splice(picked * 4, 4)); wroanswered.concat(quest.splice(picked * 4, 4));
} }
// Remove question and answers from available questions - (thus not allowing to have a Repeated question). // Remove question and answers from available questions - (thus not allowing to have a Repeated question).

8
hangman/play.php

@ -14,7 +14,13 @@
// 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/>.
// This file plays the game hangman. /**
* This file plays the game hangman.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

7
headergame.php

@ -14,6 +14,13 @@
// 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/>.
/**
* The header for many .php files.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__) . '/../../config.php'); require_once(dirname(__FILE__) . '/../../config.php');

8
hiddenpicture/picture.php

@ -14,6 +14,14 @@
// 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/>.
/**
* Creates an image dynamically.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require( '../../../config.php'); require( '../../../config.php');
require_login(); require_login();

9
hiddenpicture/play.php

@ -14,7 +14,14 @@
// 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/>.
// This file plays the game Hidden Picture.
/**
* This file plays the game Hidden Picture.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

8
index.php

@ -17,10 +17,10 @@
/** /**
* This page lists all the instances of game module in a particular course * This page lists all the instances of game module in a particular course
* *
* @author Vasilis Daloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php"); require_once("../../config.php");
require_once("lib.php"); require_once("lib.php");
require_once("locallib.php"); require_once("locallib.php");

8
lib.php

@ -17,10 +17,10 @@
/** /**
* Library of functions and constants for module game * Library of functions and constants for module game
* *
* @author Vasilis Daloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
// Define CONSTANTS. // Define CONSTANTS.

8
locallib.php

@ -14,6 +14,14 @@
// 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/>.
/**
* Basic library.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
// Include those library functions that are also used by core Moodle or other modules. // Include those library functions that are also used by core Moodle or other modules.

9
millionaire/play.php

@ -15,11 +15,12 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* This file plays the game millionaire * This file plays the game millionaire.
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();

8
preview.php

@ -17,10 +17,10 @@
/** /**
* This page prints a particular attempt of game * This page prints a particular attempt of game
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php"); require_once("../../config.php");
require_login(); require_login();

7
print.php

@ -17,9 +17,10 @@
/** /**
* This page export the game to html * This page export the game to html
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php"); require_once("../../config.php");
require_once("lib.php"); require_once("lib.php");
require_once("locallib.php"); require_once("locallib.php");

8
report/default.php

@ -29,6 +29,14 @@
// Included by ../report.php. // Included by ../report.php.
/**
* the default report.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
class game_default_report { class game_default_report {

8
report/overview/report.php

@ -17,11 +17,11 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/* /*
* This script lists student attempts * This script lists student attempts.
* *
* @author bdaloukas. * @package mod_game
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @copyright 2007 Vasilis Daloukas
* @package game * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
require_once($CFG->libdir.'/tablelib.php'); require_once($CFG->libdir.'/tablelib.php');

5
settings.php

@ -17,11 +17,10 @@
/** /**
* Form for creating and modifying a game * Form for creating and modifying a game
* *
* @package game * @package mod_game
* @author Vasilis Daloukas * @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) { if ($ADMIN->fulltree) {

7
showanswers.php

@ -17,9 +17,10 @@
/** /**
* This page shows the answers of the current game * This page shows the answers of the current game
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php"); require_once("../../config.php");
require_once( "headergame.php"); require_once( "headergame.php");

8
showattempts.php

@ -17,10 +17,10 @@
/** /**
* This page shows the answers of the current game * This page shows the answers of the current game
* *
* @author bdaloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php"); require_once("../../config.php");
require_login(); require_login();

8
snakes/createboard.php

@ -16,7 +16,13 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
// This file creates a board for "Snakes and Ladders". /**
* This file creates a board for "Snakes and Ladders".
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function game_createsnakesboard($imageasstring, $colsx, $colsy, $ofstop, $ofsbottom, function game_createsnakesboard($imageasstring, $colsx, $colsy, $ofstop, $ofsbottom,
$ofsright, $ofsleft, $board, $setwidth, $setheight) { $ofsright, $ofsleft, $board, $setwidth, $setheight) {
global $CFG; global $CFG;

9
snakes/play.php

@ -16,8 +16,13 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
// This files plays the game "Snakes and Ladders". /**
* This files plays the game "Snakes and Ladders".
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function game_snakes_continue( $id, $game, $attempt, $snakes, $context) { function game_snakes_continue( $id, $game, $attempt, $snakes, $context) {
if ($attempt != false and $snakes != false) { if ($attempt != false and $snakes != false) {
return game_snakes_play( $id, $game, $attempt, $snakes, $context); return game_snakes_play( $id, $game, $attempt, $snakes, $context);

10
sudoku/class.Sudoku.php

@ -65,15 +65,13 @@ defined('MOODLE_INTERNAL') || die();
* @package Sudoku * @package Sudoku
*/ */
/* /**
* Basic functionality needed for ObjectSs in the Sudoku solver. * Basic functionality needed for ObjectSs in the Sudoku solver.
* *
* Technically speaking these aren't restricted to the Sudoku classes * @package mod_game
* and are of use generally. * @copyright 2007 Vasilis Daloukas
* * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package Sudoku
*/ */
class objects { class objects {
/** /**
* @desc Are two array's equal (have the same contents). * @desc Are two array's equal (have the same contents).

7
sudoku/create.php

@ -14,6 +14,13 @@
// 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/>.
/**
* Creates a sudoku.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require( "../../../config.php"); require( "../../../config.php");
require_once("class.Sudoku.php"); require_once("class.Sudoku.php");
require( '../header.php'); require( '../header.php');

8
sudoku/export.php

@ -14,6 +14,14 @@
// 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/>.
/**
* Exports a sudoku.
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require( "../../../config.php"); require( "../../../config.php");
require_login(); require_login();

8
sudoku/play.php

@ -14,6 +14,14 @@
// 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/>.
/**
* Plays the game "Sudoku".
*
* @package mod_game
* @copyright 2007 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once( "../../lib/questionlib.php"); require_once( "../../lib/questionlib.php");

7
tabs.php

@ -17,11 +17,10 @@
/** /**
* Sets up the tabs used by the game pages based on the users capabilites. * Sets up the tabs used by the game pages based on the users capabilites.
* *
* @author Vasilis Daloukas. * @package mod_game
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @copyright 2007 Vasilis Daloukas
* @package game * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
if (empty($game)) { if (empty($game)) {

7
translate.php

@ -17,9 +17,10 @@
/** /**
* Check translation of module Game * Check translation of module Game
* *
* @author Vasilis Daloukas * @package mod_game
* @package game * @copyright 2007 Vasilis Daloukas
**/ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require( "../../config.php"); require( "../../config.php");
require_login(); require_login();

4
version.php

@ -35,10 +35,10 @@ if (!isset( $plugin)) {
} }
$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics).
$plugin->version = 2017061001; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2017061101; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2010112400; // Requires Moodle 2.0. $plugin->requires = 2010112400; // Requires Moodle 2.0.
$plugin->cron = 0; // Period for cron to check this module (secs). $plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->release = '2017-06-10'; $plugin->release = '2017-06-11';
if ($useplugin != 2) { if ($useplugin != 2) {
$module = $plugin; $module = $plugin;

Loading…
Cancel
Save