-
Notifications
You must be signed in to change notification settings - Fork 41
/
preview.php
87 lines (74 loc) · 2.9 KB
/
preview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?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/>.
/**
* This page prints a particular attempt of game
*
* @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_login();
require_once("lib.php");
require_once("locallib.php");
require_once( "hangman/play.php");
require_once( "cross/play.php");
require_once( "cryptex/play.php");
require_once( "millionaire/play.php");
require_once( "sudoku/play.php");
require_once( "bookquiz/play.php");
require_once( "headergame.php");
$context = game_get_context_module_instance( $cm->id);
if (!has_capability('mod/game:viewreports', $context)) {
throw new moodle_exception('only_teachers', 'game');
}
$action = required_param('action', PARAM_ALPHANUM);
$gamekind = required_param('gamekind', PARAM_ALPHANUM);
$update = required_param('update', PARAM_INT);
$attemptid = required_param('attemptid', PARAM_INT);
$attempt = $DB->get_record( 'game_attempts', ['id' => $attemptid]);
$game = $DB->get_record( 'game', [ 'id' => $attempt->gameid]);
$detail = $DB->get_record( 'game_'.$gamekind, [ 'id' => $attemptid]);
$solution = ($action == 'solution');
$PAGE->navbar->add(get_string('preview', 'game'));
$onlyshow = true;
$endofgame = false;
$print = false;
$checkbutton = false;
$showhtmlsolutions = false;
$showhtmlprintbutton = true;
$showstudentguess = true;
switch( $gamekind) {
case 'cross':
$g = '';
game_cross_play( $cm, $game, $attempt, $detail, $g, $onlyshow, $solution,
$endofgame, $print, $checkbutton, $showhtmlsolutions, $showhtmlprintbutton,
$showstudentguess, $context, $course);
break;
case 'sudoku':
game_sudoku_play( $cm, $game, $attempt, $detail, $onlyshow, $solution, $context, $course);
break;
case 'hangman':
$preview = ($action == 'preview');
game_hangman_play( $update, $game, $attempt, $detail, $preview, $solution, $context, $course);
break;
case 'cryptex':
$crossm = $DB->get_record( 'game_cross', ['id' => $attemptid]);
game_cryptex_play( $cm, $game, $attempt, $detail, $crossm, false, true, $solution, $context,
$print, $showhtmlprintbutton, $course);
break;
}
echo $OUTPUT->footer();