diff --git a/attempt.php b/attempt.php index 611fc4d..bf31588 100755 --- a/attempt.php +++ b/attempt.php @@ -150,7 +150,7 @@ break; case 'cryptexcheck': //the user tries to guess a question $attempt = game_getattempt( $game, $detail); - game_cryptex_check( $id, $game, $attempt, $detail, $q, $answer, $context); + game_cryptex_check( $id, $game, $attempt, $detail, $q, $answer, $finishattempt, $context); break; case 'bookquizcheck': //the student tries to answer a question $attempt = game_getattempt( $game, $detail); diff --git a/cryptex/play.php b/cryptex/play.php index 5829aef..8c199ec 100755 --- a/cryptex/play.php +++ b/cryptex/play.php @@ -85,12 +85,21 @@ function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $ } //q means game_queries.id -function game_cryptex_check( $id, $game, $attempt, $cryptexrec, $q, $answer, $context) +function game_cryptex_check( $id, $game, $attempt, $cryptexrec, $q, $answer, $finishattempt, $context) { global $DB; - if( $attempt === false){ - game_cryptex_continue( $id, $game, $attempt, $cryptexrec, false); + + if( $finishattempt) + { + game_updateattempts( $game, $attempt, -1, true); + game_cryptex_continue( $id, $game, false, false, true, $context); + return; + } + + if( $attempt === false) + { + game_cryptex_continue( $id, $game, $attempt, $cryptexrec, false, $context); return; } @@ -256,8 +265,10 @@ width: 240pt; '.get_string( 'print', 'game'); - echo ''; + echo '
'; + echo '
'; } if( $showhtmlprintbutton){ @@ -272,14 +283,23 @@ if( $showhtmlprintbutton){ document.getElementById("printbutton").style.display = "block"; } -function OnPrint() -{ -id"; - echo "window.open( \"{$CFG->wwwroot}/mod/game/print.php?$params\")"; -?> -} + function OnPrint() + { + id"; + echo "window.open( \"{$CFG->wwwroot}/mod/game/print.php?$params\");"; + ?> + } + + function OnEndGame() + { + wwwroot}/mod/game/attempt.php?$params\";\r\n"; + ?> + } '; - }else{ - echo ''; - } + else + echo ''; } diff --git a/lib.php b/lib.php index 6a36b61..ce8db7d 100755 --- a/lib.php +++ b/lib.php @@ -1166,7 +1166,7 @@ function game_reset_userdata($data) { if (!$cm = get_coursemodule_from_instance('game', $rec->id)) { continue; } - $context = get_context_instance(CONTEXT_MODULE, $cm->id); + $context = game_get_context_module_instance( $cm->id); $fs->delete_area_files($context->id, 'mod_game', 'gnakes_file'); $fs->delete_area_files($context->id, 'mod_game', 'gnakes_board'); @@ -1278,3 +1278,11 @@ function game_scale_used_anywhere($scaleid) { return false; } } + +function game_get_context_module_instance( $moduleid) +{ + if( class_exists( 'context_module')) + return context_module::instance( $moduleid); + + return get_context_instance( CONTEXT_MODULE, $moduleid); +} diff --git a/locallib.php b/locallib.php index b169046..bee8c6e 100755 --- a/locallib.php +++ b/locallib.php @@ -2080,14 +2080,6 @@ function game_get_context_course_instance( $courseid) return get_context_instance( 50, $courseid); } -function game_get_context_module_instance( $moduleid) -{ - if( class_exists( 'context_module')) - return context_module::instance( $moduleid); - - return get_context_instance( CONTEXT_MODULE, $moduleid); -} - function game_show_query( $game, $query, $text) { if( $game->glossaryid) diff --git a/version.php b/version.php index 7a26bf7..cd2cda8 100755 --- a/version.php +++ b/version.php @@ -22,10 +22,10 @@ if( !isset( $plugin)) $useplugin = 2; $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics) -$plugin->version = 2015071204; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2015071205; // 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 = '3.30.12.4'; +$plugin->release = '3.30.12.5'; if( $useplugin != 2) $module = $plugin;