diff --git a/CHANGES.md b/CHANGES.md index 100b130..c16e176 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,6 @@ +Changes in version 2017-06-10 (20170610) +- Fix phpdocs problems + Changes in version 2017-06-09 (20170609) - Fix Moodle 3.4 compatibility problems - Fix stylings problems diff --git a/attempt.php b/attempt.php index 91a008a..2b04dae 100644 --- a/attempt.php +++ b/attempt.php @@ -40,6 +40,11 @@ game_do_attempt( $id, $game, $action, $course, $context); /** * Do the required checks and print header. + * + * @param int $id + * @param stdClass $game + * @param stdClass $course + * @param stdClass $context */ function game_show_header( &$id, &$game, &$course, &$context) { global $DB, $USER, $PAGE, $OUTPUT; @@ -118,8 +123,12 @@ function game_show_header( &$id, &$game, &$course, &$context) { /** * Do one attempt. + * + * @param int $id + * @param stdClass $game + * @param stdClass $course + * @param stdClass $context */ - function game_do_attempt( $id, $game, $action, $course, $context) { global $OUTPUT; @@ -194,6 +203,12 @@ function game_do_attempt( $id, $game, $action, $course, $context) { /** * Creates one game. + * + * @param stdClass $game + * @param int $id + * @param int $forcenew + * @param stdClass $course + * @param stdClass $context */ function game_create( $game, $id, $forcenew, $course, $context) { global $USER, $CFG, $DB; @@ -236,6 +251,8 @@ function game_create( $game, $id, $forcenew, $course, $context) { /** * Unpacks the cross. + * + * @param string $g */ function game_cross_unpackpuzzle( $g) { $ret = ""; diff --git a/db/upgrade.php b/db/upgrade.php index d8a39ba..7b85f27 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -853,6 +853,16 @@ function xmldb_game_upgrade($oldversion) { 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) { $table = new xmldb_table( 'game_queries'); $field = new xmldb_field( 'gameinstanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0'); @@ -872,16 +882,6 @@ function xmldb_game_upgrade($oldversion) { upgrade_mod_savepoint(true, 2007111843, '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 < 2007111844) { $table = new xmldb_table('game_queries'); $field = new xmldb_field('questiontext', XMLDB_TYPE_TEXT, null, null, null, null, '', 'glossaryentryid'); diff --git a/export.php b/export.php index 9199913..277a848 100644 --- a/export.php +++ b/export.php @@ -41,6 +41,9 @@ $target = optional_param('target', "", PARAM_ALPHANUM); // The target is HTML or class mod_game_exporthtml_form extends moodleform { + /** + * Definition of form. + */ public function definition() { global $CFG, $game; @@ -98,6 +101,14 @@ class mod_game_exporthtml_form extends moodleform { $mform->closeHeaderBefore('submitbutton'); } + /** + * Validation of form. + * + * @param stdClass $data + * @param stdClass $files + * + * @return errors + */ public function validation($data, $files) { global $CFG, $USER, $DB; $errors = parent::validation($data, $files); @@ -105,6 +116,9 @@ class mod_game_exporthtml_form extends moodleform { return $errors; } + /** + * Do the exporting. + */ public function export() { global $game, $DB; @@ -140,6 +154,9 @@ class mod_game_exporthtml_form extends moodleform { class mod_game_exportjavame_form extends moodleform { + /** + * Definition of form. + */ public function definition() { global $CFG, $DB, $game; @@ -192,6 +209,14 @@ class mod_game_exportjavame_form extends moodleform { $mform->closeHeaderBefore('submitbutton'); } + /** + * Validation of form. + * + * @param stdClass $data + * @param stdClass $files + * + * @return errors + */ public function validation($data, $files) { global $CFG, $USER, $DB; $errors = parent::validation($data, $files); @@ -199,6 +224,9 @@ class mod_game_exportjavame_form extends moodleform { return $errors; } + /** + * Do the exporting. + */ public function export() { global $game, $DB; @@ -271,6 +299,11 @@ if ($mform->is_cancelled()) { } echo $OUTPUT->footer(); +/** + * Sends via html a file. + * + * @param string file + */ function game_send_stored_file($file) { if (file_exists($file)) { header('Content-Description: File Transfer'); diff --git a/export/html/snakes/css/game.css b/export/html/snakes/css/game.css index bd597b9..be82a2e 100644 --- a/export/html/snakes/css/game.css +++ b/export/html/snakes/css/game.css @@ -1,29 +1,25 @@ -.nodis -{ - list-style-type:none; +.nodis { + list-style-type: none; } -#cont -{ - position:relative; - display:none; +#cont { + position: relative; + display: none; } -.img1 -{ - position:absolute; - display:none; +.img1 { + position: absolute; + display: none; } -#dicecont -{ - float:right; - width:250px; +#dicecont { + float: right; + width: 250px; background-image: url(../images/meter.png); background-repeat: repeat; font-family: Arial, Helvetica, sans-serif; font-weight: normal; - color: #FFFFFF; + color: #ffffff; border: 0.5em solid #333333; top: 30px; position: absolute; diff --git a/export/html/snakes/css/modal.css b/export/html/snakes/css/modal.css index cc0ab50..868e2e5 100644 --- a/export/html/snakes/css/modal.css +++ b/export/html/snakes/css/modal.css @@ -7,7 +7,8 @@ opacity: .80; z-index: 9999; } -.popup_block{ + +.popup_block { display: none; /*--hidden by default--*/ background: #fff; padding: 20px; @@ -18,22 +19,25 @@ top: 50%; left: 50%; z-index: 99999; /*--CSS3 Box Shadows--*/ - -webkit-box-shadow: 0px 0px 20px #000; - -moz-box-shadow: 0px 0px 20px #000; - box-shadow: 0px 0px 20px #000; + -webkit-box-shadow: 0 0 20px #000; + -moz-box-shadow: 0 0 20px #000; + box-shadow: 0 0 20px #000; /*--CSS3 Rounded Corners--*/ -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; } + img.btn_close { float: right; margin: -55px -55px 0 0; } + /*--Making IE6 Understand Fixed Positioning--*/ *html #fade { position: absolute; } + *html .popup_block { position: absolute; } diff --git a/export/html/snakes/css/snakes.css b/export/html/snakes/css/snakes.css index 4047561..db54951 100644 --- a/export/html/snakes/css/snakes.css +++ b/export/html/snakes/css/snakes.css @@ -2,81 +2,71 @@ Husain Limdiyawala(MSc IT DA-IICT) Any Duplication of this code should be avoided*/ -.blocks -{ +.blocks { font-family: Arial, Helvetica, sans-serif; margin-left: 5px; - margin-top:2px; - margin-bottom:2px; + margin-top: 2px; + margin-bottom: 2px; padding: 0px; - float:left; + float: left; height: 52px; width: 52px; - display:block; - position:relative; + display: block; + position: relative; background-image: url(../square52.png); } -.nodis -{ - list-style-type:none; +.nodis { + list-style-type: none; } -#cont -{ - position:relative; - display:none; +#cont { + position: relative; + display: none; } -#diceimg -{ - display:none; - width:45px; - height:44px; +#diceimg { + display: none; + width: 45px; + height: 44px; } -.img1 -{ +.img1 { position:absolute; display:none; } -body -{ - background:#CCCCCC; +body { + background:#cccccc; } -#player -{ - display:none; - z-index:5; - position:absolute; +#player { + display: none; + z-index: 5; + position: absolute; } -#players -{ +#players { margin-top: 0.3em; margin-bottom: 1em; } -#dicecont -{ - float:right; - width:170px; +#dicecont { + float: right; + width: 170px; background-image: url(../images/meter.png); background-repeat: repeat; font-family: Arial, Helvetica, sans-serif; font-weight: bold; - color: #FFFFFF; + color: #ffffff; border: 0.5em solid #333333; top: 30px; position: absolute; right: 880px; } -#playbtn -{ - margin-left:0.5em; +#playbtn { + margin-left: 0.5em; font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #000000; @@ -94,6 +84,7 @@ body opacity: .80; z-index: 9999; } + .popup_block{ display: none; /*--hidden by default--*/ background: #fff; @@ -113,15 +104,18 @@ body -moz-border-radius: 10px; border-radius: 10px; } + img.btn_close { float: right; margin: -55px -55px 0 0; border: 0; } + /*--Making IE6 Understand Fixed Positioning--*/ *html #fade { position: absolute; } + *html .popup_block { position: absolute; } diff --git a/export/html/snakes/css/style.css b/export/html/snakes/css/style.css index 7f5a35e..297ce3f 100644 --- a/export/html/snakes/css/style.css +++ b/export/html/snakes/css/style.css @@ -3,13 +3,13 @@ body { } body, html, input { - font-family:Verdana, Arial, Helvetica, sans-serif; - font-size:11px; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; color: #333333; } .info { - font-style:italic; + font-style: italic; font-size: 0.9em; color: #666666; } diff --git a/export/html/snakes/css/subModal.css b/export/html/snakes/css/subModal.css index 30e7958..14cbef7 100644 --- a/export/html/snakes/css/subModal.css +++ b/export/html/snakes/css/subModal.css @@ -53,8 +53,8 @@ height: 1.3em; padding: 5px; border-bottom: 2px solid #000000; - border-top: 1px solid #78A3F2; - border-left: 1px solid #78A3F2; + border-top: 1px solid #7878a3f2; + border-left: 1px solid #7878a3f2; border-right: 1px solid #204095; position: relative; z-index: 203; diff --git a/export/html/snakes/js/snakes-mod.js b/export/html/snakes/js/snakes-mod.js index b7c8e00..e223958 100644 --- a/export/html/snakes/js/snakes-mod.js +++ b/export/html/snakes/js/snakes-mod.js @@ -1,10 +1,5 @@ -/*This code was originally based on code by -Husain Limdiyawala(MSc IT DA-IICT)*/ - -$(document).ready(function () { - -}); - +/* This code was originally based on code by +Husain Limdiyawala(MSc IT DA-IICT) */ // Global Variables. var totblocks = 0; @@ -21,8 +16,8 @@ var destsnake = new Array(4); var ladsrc = new Array(3); var laddest = new Array(3); 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 WRO_answered = new Array(); // Record all questions (along with answers) the user responded WRONGLY. +var cor_answered = 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 user = new Array(); // Constract table with questions and answers and pick question to display. @@ -156,7 +151,7 @@ function throwDice(i) { // The below Function Checks The Snake Biting for a user. function snakescheck(k) { - i = 0; + var i; for(i = 0; i <= srcsnake.length; i++) { if (srcsnake[i] == tots[k]) { @@ -176,7 +171,7 @@ function snakescheck(k) { // The below function checks the ladders for a user. function laddercheck(k) { - i = 0; + var i; for(i = 0; i <= ladsrc.length; i++) { if (ladsrc[i] == tots[k]) { @@ -254,11 +249,17 @@ function selectPlayer() { // The below function starts the play. function play() { if (tots[l] != null) { + var s; + + s = ""; disableField(); - document.getElementById("status").innerHTML = ""; + document.getElementById("status").innerHTML = s; - Question(); - document.getElementById("status").innerHTML = ""; + question(); + s = ""; + document.getElementById("status").innerHTML = s; } else { document.getElementById("status").innerHTML = ""; } @@ -277,13 +278,13 @@ function doit(i) { snakescheck(i); laddercheck(i); } else { - alert("ÏëïêëÞñùóåò ôçí ðßóôá, óõã÷áñçôÞñéá!!!"); + alert("Congatulations!!!"); } } // The below function checks whether the player has won or not. function checkWin(i) { - if( tots[i] == totblocks) { + if (tots[i] == totblocks) { return false; } else { return true; @@ -296,18 +297,20 @@ function disableField() { document.getElementById("boardtype").disabled = "disabled"; } -function Question() { +function question() { + var picked, q1; + picked = selectQuest(allQuest); alert("Randomly selected number:" + picked); - Q1 = prompt(quest[picked * 4], "Απάντηση"); - if (Q1 == quest[picked * 4 + 1]) { + q1 = prompt(quest[picked * 4], "Απάντηση"); + if (q1 == quest[picked * 4 + 1]) { alert("Σωστά!") doit(l); - COR_answered.concat(quest.splice(picked * 4, 4)); + cor_answered.concat(quest.splice(picked * 4, 4)); } else { alert("Η απάντηση δεν ήταν σωστή. Χάνεις τη σειρά σου για αυτό το γύρο!") - WRO_answered.concat(quest.splice(picked * 4, 4)); + wro_answered.concat(quest.splice(picked * 4, 4)); } // Remove question and answers from available questions - (thus not allowing to have a Repeated question). diff --git a/lib.php b/lib.php index 9ddc153..daa7c6e 100644 --- a/lib.php +++ b/lib.php @@ -61,7 +61,6 @@ define('GAME_REVIEW_GENERALFEEDBACK', 32 * 0x1041); // Show general feedback. * @param object $instance An object from the form in mod.html * @return int The id of the newly inserted game record **/ - function game_add_instance($game) { global $DB; @@ -138,6 +137,11 @@ function game_update_instance($game) { return true; } +/** + * Updates some fields before writing to database. + * + * @param stdClass $game + */ function game_before_add_or_update(&$game) { if (isset( $game->questioncategoryid)) { $pos = strpos( $game->questioncategoryid, ','); @@ -264,7 +268,12 @@ function game_user_outline($course, $user, $mod, $game) { /** * Print a detailed representation of what a user has done with * a given particular instance of this module, for user activity reports. - **/ + + * @param stdClass $course + * @param stdClass $user + * @param string $mod + * @param stdClass $game + */ function game_user_complete($course, $user, $mod, $game) { global $DB; @@ -296,11 +305,17 @@ function game_user_complete($course, $user, $mod, $game) { * @uses $CFG * @return boolean * @todo Finish documenting this function - **/ + * + * @param stdClass $course + * @param int $isteacher + * @param int $timestart + * + * @return True if anything was printed, otherwise false. + */ function game_print_recent_activity($course, $isteacher, $timestart) { global $CFG; - return false; // True if anything was printed, otherwise false. + return false; } /** @@ -308,7 +323,6 @@ function game_print_recent_activity($course, $isteacher, $timestart) { * 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 @@ -512,6 +526,13 @@ function game_grade_item_delete( $game) { /** * Returns all game graded users since a given time for specified game + * @param stdClass $activities + * @param int $index + * @param int $timestart + * @param int courseid + * @param int cmid + * @param int userid + * @param int groupid */ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0) { global $DB, $COURSE, $USER; @@ -607,6 +628,14 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course } } +/** + * Prints recent activity. + * + * @param stdClass $activity + * @param int $courseid + * @param stdClass $detail + * @param array $modgames + */ function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames) { global $CFG, $OUTPUT; @@ -755,10 +784,26 @@ function game_num_attempt_summary($game, $cm, $returnzero = false, $currentgroup return ''; } +/** + * Converts score of game to grade. + * + * @param stdClass $game + * @param float $score + * + * @return float the score + */ function game_format_score($game, $score) { return format_float($game->grade * $score / 100, $game->decimalpoints); } +/** + * Converts grade to score. + * + * @param stdClass $game + * @param float $grade + * + * @return foat score + */ function game_format_grade($game, $grade) { return format_float($grade, $game->decimalpoints); } @@ -1103,6 +1148,18 @@ if (defined('USE_GET_SHORTCUTS')) { } } +/** + * Serves the game attachents. + * + * @param stdClass $course + * @param stdClass $cm + * @param stdClass $context + * @param string filearea + * @param array args + * @param boolean forcedownload + * + * @return boolean false if not exists file + */ function mod_game_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) { global $CFG, $DB; @@ -1176,6 +1233,8 @@ function game_reset_course_form_definition(&$mform) { /** * Course reset form defaults. + * @param stdClass $course + * * @return array */ function game_reset_course_form_defaults($course) { @@ -1188,6 +1247,7 @@ function game_reset_course_form_defaults($course) { * * @global object * @param $data the data submitted from the reset course. + * * @return array status array */ function game_reset_userdata($data) { @@ -1295,6 +1355,7 @@ function game_reset_userdata($data) { * @param object $cm Course-module * @param int $userid User ID * @param bool $type Type of comparison (or/and; can be used as return value if no conditions) + * * @return bool True if completed, false if not, $type if conditions not set. */ function game_get_completion_state($course, $cm, $userid, $type) { @@ -1340,6 +1401,14 @@ function game_scale_used_anywhere($scaleid) { } } +/** + * Returns the context instance of a Module. Is the same for all version of Moodle. + * + * This is used to find out if scale used anywhere + * + * @param int $moduleid + * @return stdClass context + */ function game_get_context_module_instance( $moduleid) { if (class_exists( 'context_module')) { return context_module::instance( $moduleid); @@ -1348,6 +1417,14 @@ function game_get_context_module_instance( $moduleid) { return get_context_instance( CONTEXT_MODULE, $moduleid); } +/** + * Returns the context instance of a course. Is the same for all version of Moodle. + * + * This is used to find out if scale used anywhere + * + * @param int $moduleid + * @return stdClass context + */ function game_get_context_course_instance( $courseid) { if (class_exists( 'context_course')) { return context_course::instance( $courseid); @@ -1356,11 +1433,18 @@ function game_get_context_course_instance( $courseid) { return get_context_instance( CONTEXT_COURSE, $courseid); } +/** + * Returns the url of a pix file. Is the same for all versions of Moodle. + * + * @param string $filename + * @param string module + * @return stdClass url + */ function game_pix_url( $filename, $module='') { global $OUTPUT; if (game_get_moodle_version() >= '03.03') { - return $OUTPUT->image_url($filename, 'mod_game'); + return $OUTPUT->image_url($filename, $module); } else { return $OUTPUT->pix_url($filename, $module); } diff --git a/locallib.php b/locallib.php index ddb128d..e0d49ad 100644 --- a/locallib.php +++ b/locallib.php @@ -38,6 +38,11 @@ $gamegrademethod = array ( GAME_GRADEMETHOD_HIGHEST => get_string("gradehighest" define( "CONST_GAME_TRIES_REPETITION", "3"); +/** + * Returns the version of Moodle. + * + * @return string version + */ function game_get_moodle_version() { global $DB; @@ -56,6 +61,13 @@ function game_get_moodle_version() { } } +/** + * Convert a string to upper. + * + * @param string $str + * @param string $lang + * @return string the uppercase of $str + */ function game_upper( $str, $lang='') { if ($lang == 'user') { return $str; @@ -80,6 +92,15 @@ function game_upper( $str, $lang='') { return $str; } +/** + * Returns the HTML of a select control. + * + * @param string $name + * @param array a + * @param string $input + * @param array $events + * @return string the HTML + */ function game_showselectcontrol( $name, $a, $input, $events='') { $ret = "'. - ''. - ''. - ''; - } - $buttons .= ''; - } else { - $buttons = ' '; - } - - print_header($title, $this->courserecord->fullname, $navigation); - } - - public function get_type() { - return PAGE_GAME_VIEW; - } -} diff --git a/print.php b/print.php index 92089b1..64a3f00 100644 --- a/print.php +++ b/print.php @@ -44,6 +44,13 @@ function game_print( $game, $update, $context) { } } +/** + * Prints a cross. + * + * @param stdClass $game + @param boolean $update + * @param stdClass $context + */ function game_print_cross( $game, $update, $context) { require( "cross/play.php"); @@ -70,6 +77,13 @@ function game_print_cross( $game, $update, $context) { $showstudentguess, $context); } +/** + * Prints a cryptex. + * + * @param stdClass $game + @param boolean $update + * @param stdClass $context + */ function game_print_cryptex( $game, $update, $context) { global $DB; diff --git a/version.php b/version.php index 2dda942..a6443ee 100644 --- a/version.php +++ b/version.php @@ -15,12 +15,12 @@ // along with Moodle. If not, see . /** - * Code fragment to define the version of game - * This fragment is called by moodle_needs_upgrading() and /admin/index.php + * Version information * - * @author - * @package game - **/ + * @package mod_game + * @copyright 2007 Vasilis Daloukas + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); @@ -35,10 +35,10 @@ if (!isset( $plugin)) { } $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2017060901; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017061001; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2010112400; // Requires Moodle 2.0. $plugin->cron = 0; // Period for cron to check this module (secs). -$plugin->release = '2017-06-09'; +$plugin->release = '2017-06-10'; if ($useplugin != 2) { $module = $plugin; diff --git a/view.php b/view.php index 13229d0..89d93aa 100644 --- a/view.php +++ b/view.php @@ -14,7 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -// This page prints a particular instance of game. +/** + * This file is the entry point to the game module. All pages are rendered from here + * + * @package mod_game + * @copyright 2007 Vasilis Daloukas + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late + */ require_once(dirname(__FILE__) . '/../../config.php'); require_once($CFG->libdir.'/gradelib.php');