function game_OnExportHTML_cross($game, $context, $html, $destdir) { global $CFG, $DB; if ($html->filename == '') { $html->filename = 'cross'; } $filename = $html->filename . '.htm'; require "cross/play.php"; $attempt = game_getattempt($game, $crossrec, true); if ($crossrec == false) { game_cross_new($game, $attempt->id, $crossm); $attempt = game_getattempt($game, $crossrec); } $ret = game_export_printheader($html->title); echo "{$ret}<br>"; ob_start(); game_cross_play(0, $game, $attempt, $crossrec, '', true, false, false, false, $html->checkbutton, true, $html->printbutton, false, $context); $output_string = ob_get_contents(); ob_end_clean(); $course = $DB->get_record('course', array('id' => $game->course)); $filename = $html->filename . '.htm'; file_put_contents($destdir . '/' . $filename, $ret . "\r\n" . $output_string); $filename = game_OnExportHTML_cross_repair_questions($game, $context, $filename, $destdir); game_send_stored_file($filename); }
function game_print_cross($game, $update) { global $CFG; require "cross/play.php"; $attempt = false; game_getattempt($game, &$crossrec); game_cross_play($update, $game, $attempt, $crossrec, '', true, false, false, true, false, false, false); }
function game_print_cryptex($game, $update, $context) { global $DB; require 'cross/cross_class.php'; require 'cross/crossdb_class.php'; require "cryptex/play.php"; $attempt = game_getattempt($game, $crossrec); $updateattempt = false; $onlyshow = true; $showsolution = false; $showhtmlprintbutton = false; $print = true; $crossm = $DB->get_record_select('game_cross', "id={$attempt->id}"); ?> <html dir="ltr" lang="el" xml:lang="el" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Print</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php game_cryptex_play($update, $game, $attempt, $crossrec, $crossm, $updateattempt, $onlyshow, $showsolution, $context, $print, $showhtmlprintbutton); }
function game_print_cross($game, $update, $context) { require "cross/play.php"; $attempt = game_getattempt($game, $crossrec); $g = ''; $onlyshow = true; $showsolution = false; $endofgame = false; $print = true; $checkbutton = false; $showhtmlsolutions = false; $showhtmlprintbutton = false; $showstudentguess = false; ?> <html dir="ltr" lang="el" xml:lang="el" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Print</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php game_cross_play($update, $game, $attempt, $crossrec, $g, $onlyshow, $showsolution, $endofgame, $print, $checkbutton, $showhtmlsolutions, $showhtmlprintbutton, $showstudentguess, $context); }
function game_OnExportHTML_cross($game, $html, $update, $destdir) { global $CFG; if ($html->filename == '') { $html->filename = 'cross'; } $filename = $html->filename . '.htm'; require "cross/play.php"; $attempt = false; game_getattempt($game, $crossrec); $ret = game_export_printheader($html->title); echo "{$ret}<br>"; ob_start(); game_cross_play($update, $game, $attempt, $crossrec, '', true, false, false, false, $html->checkbutton, true, $html->printbutton); $output_string = ob_get_contents(); ob_end_clean(); $course = get_record_select('course', "id={$game->course}"); $filename = $html->filename . '.htm'; file_put_contents($destdir . '/' . $filename, $ret . "\r\n" . $output_string); echo "{$ret}<a href=\"{$CFG->wwwroot}/file.php/{$game->course}/export/{$filename}\">{$filename}</a>"; }
// $Id: importodt.php,v 1.1 2008/03/26 17:40:39 arborrow Exp $ /** * This is a very rough importer for odt * * The script supports book * Is based on class office from http://www.phpclasses.org/browse/package/2586.html * * @version $Id: importodt.php,v 1.1 2008/03/26 17:40:39 arborrow Exp $ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package game **/ require_once "../../../config.php"; require_once "../header.php"; require_once "../locallib.php"; $attempt = game_getattempt($game, $detail); $bookid = $game->bookid; if ($bookid == 0) { error(get_string('bookquiz_not_select_book', 'game')); } if ($form = data_submitted()) { /// Filename if (empty($_FILES['newfile'])) { // file was just uploaded notify(get_string("uploadproblem")); } if (!is_uploaded_file($_FILES['newfile']['tmp_name']) or $_FILES['newfile']['size'] == 0) { notify(get_string("uploadnofilefound")); } else { // Valid file is found if (readdata($course->id, 'game', $dirtemp, $r_levels, $r_titles, $r_texts, $dirfordelete)) {
function game_create($game, $id, $forcenew, $course, $context) { global $USER, $CFG, $DB; $attempt = game_getattempt($game, $detail); switch ($game->gamekind) { case 'cross': game_cross_continue($id, $game, $attempt, $detail, '', $forcenew, $context); break; case 'hangman': if (array_key_exists('newletter', $_GET)) { $newletter = $_GET['newletter']; } else { $newletter = ''; } if (array_key_exists('action2', $_GET)) { $action2 = $_GET['action2']; } else { $action2 = ''; } game_hangman_continue($id, $game, $attempt, $detail, $newletter, $action2, $context); break; case 'millionaire': game_millionaire_continue($id, $game, $attempt, $detail, $context); break; case 'bookquiz': if (array_key_exists('chapterid', $_GET)) { $chapterid = (int) $_GET['chapterid']; } else { $chapterid = 0; } game_bookquiz_continue($id, $game, $attempt, $detail, $chapterid); break; case 'sudoku': game_sudoku_continue($id, $game, $attempt, $detail, '', $context); break; case 'cryptex': game_cryptex_continue($id, $game, $attempt, $detail, $forcenew, $context); break; case 'snakes': game_snakes_continue($id, $game, $attempt, $detail, $context); break; case 'hiddenpicture': game_hiddenpicture_continue($id, $game, $attempt, $detail, $context); break; default: error("Game {$game->gamekind} not found"); break; } }
function game_getattempt($game, &$detail, $autoadd = false) { global $DB, $USER; $select = "gameid={$game->id} AND userid={$USER->id} and timefinish=0 "; if ($USER->id == 1) { $key = 'mod/game:instanceid' . $game->id; if (array_key_exists($key, $_SESSION)) { $select .= ' AND id="' . $_SESSION[$key] . '"'; } else { $select .= ' AND id=-1'; } } if ($recs = $DB->get_records_select('game_attempts', $select)) { foreach ($recs as $attempt) { if ($USER->id == 1) { $_SESSION[$key] = $attempt->id; } $detail = $DB->get_record('game_' . $game->gamekind, array('id' => $attempt->id)); return $attempt; } } if ($autoadd) { game_addattempt($game); return game_getattempt($game, $detail, false); } return false; }
function game_create($game, $id, $forcenew, $course, $context) { global $USER, $CFG, $DB; $attempt = game_getattempt($game, $detail); $chapterid = optional_param('chapterid', 0, PARAM_INT); $newletter = optional_param('newletter', '', PARAM_ALPHA); $action2 = optional_param('action2', '', PARAM_ALPHA); switch ($game->gamekind) { case 'cross': game_cross_continue($id, $game, $attempt, $detail, '', $forcenew, $context); break; case 'hangman': game_hangman_continue($id, $game, $attempt, $detail, $newletter, $action2, $context); break; case 'millionaire': game_millionaire_continue($id, $game, $attempt, $detail, $context); break; case 'bookquiz': game_bookquiz_continue($id, $game, $attempt, $detail, $chapterid, $context); break; case 'sudoku': game_sudoku_continue($id, $game, $attempt, $detail, '', $context); break; case 'cryptex': game_cryptex_continue($id, $game, $attempt, $detail, $forcenew, $context); break; case 'snakes': game_snakes_continue($id, $game, $attempt, $detail, $context); break; case 'hiddenpicture': game_hiddenpicture_continue($id, $game, $attempt, $detail, $context); break; default: print_error("Game {$game->gamekind} not found"); break; } }
function game_create($game, $id, $forcenew, $course) { global $USER, $CFG; $attempt = game_getattempt($game, $detail); switch ($game->gamekind) { case 'cross': game_cross_continue($id, $game, $attempt, $detail, '', $forcenew); break; case 'hangman': if (array_key_exists('newletter', $_GET)) { $newletter = $_GET['newletter']; } else { $newletter = ''; } if (array_key_exists('action2', $_GET)) { $action2 = $_GET['action2']; } else { $action2 = ''; } game_hangman_continue($id, $game, $attempt, $detail, $newletter, $action2); break; case 'millionaire': game_millionaire_continue($id, $game, $attempt, $detail); break; case 'bookquiz': if (array_key_exists('chapterid', $_GET)) { $chapterid = (int) $_GET['chapterid']; } else { $chapterid = 0; } game_bookquiz_continue($id, $game, $attempt, $detail, $chapterid); break; case 'sudoku': game_sudoku_continue($id, $game, $attempt, $detail); break; case 'cryptex': game_cryptex_continue($id, $game, $attempt, $detail, $forcenew); break; case 'snakes': game_snakes_continue($id, $game, $attempt, $detail); break; case 'hiddenpicture': game_hiddenpicture_continue($id, $game, $attempt, $detail); break; case '': echo get_string('useupdategame', 'game'); print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id); break; default: error("Game {$game->gamekind} not found"); break; } }