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_cross_continue($id, $game, $attempt, $cross, $g = '', $endofgame = '') { if ($endofgame) { if ($g == '') { game_updateattempts($game, $attempt, -1, true); $endofgame = false; } } if ($attempt != false and $cross != false) { return game_cross_play($id, $game, $attempt, $cross, $g, false, false, $endofgame, false, false, false, false); } if ($attempt == false) { $attempt = game_addattempt($game); } $textlib = textlib_get_instance(); $cross = new CrossDB(); $questions = array(); $infos = array(); $answers = array(); $recs = game_questions_shortanswer($game); if ($recs == false) { error('game_cross_continue: ' . get_string('cross_nowords', 'game')); } $infos = array(); foreach ($recs as $rec) { if ($game->param7 == false) { if ($textlib->strpos($rec->answertext, ' ')) { continue; //spaces not allowed } } $rec->answertext = game_upper($rec->answertext); $answers[$rec->answertext] = game_repairquestion($rec->questiontext); $infos[$rec->answertext] = array($game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment); } $cross->setwords($answers, $game->param1); if ($cross->computedata($crossm, $crossd, $game->param2)) { $new_crossd = array(); foreach ($crossd as $rec) { $info = $infos[$rec->answertext]; if ($info != false) { $rec->sourcemodule = $info[0]; $rec->questionid = $info[1]; $rec->glossaryentryid = $info[2]; $rec->attachment = $info[3]; } $new_crossd[] = $rec; } $cross->save($game, $crossm, $new_crossd, $attempt->id); game_updateattempts($game, $attempt, 0, 0); return game_cross_play($id, $game, $attempt, $crossm, '', false, false, false, false, false, false, false); } if (count($crossd) == 0) { error('game_cross_continue: ' . get_string('cross_nowords', 'game')); } }
function game_cross_continue($id, $game, $attempt, $cross, $g, $endofgame, $context) { if ($endofgame) { if ($g == '') { game_updateattempts($game, $attempt, -1, true); $endofgame = false; } } if ($attempt != false and $cross != false) { return game_cross_play($id, $game, $attempt, $cross, $g, false, false, $endofgame, false, false, false, false, true, $context); } if ($attempt == false) { $attempt = game_addattempt($game); } game_cross_new($game, $attempt->id, $crossm); game_updateattempts($game, $attempt, 0, 0); return game_cross_play($id, $game, $attempt, $crossm, '', false, false, false, false, false, false, false, true, $context); }
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>"; }
function game_do_attempt($id, $game, $action, $course, $context) { global $OUTPUT; $forcenew = optional_param('forcenew', false, PARAM_BOOL); // Teacher has requested new preview $continue = false; /// Print the main part of the page switch ($action) { case 'crosscheck': $attempt = game_getattempt($game, $detail); $g = game_cross_unpackpuzzle($_GET['g']); $finishattempt = array_key_exists('finishattempt', $_GET); game_cross_continue($id, $game, $attempt, $detail, $g, $finishattempt, $context); break; case 'crossprint': $attempt = game_getattempt($game, $detail); game_cross_play($id, $game, $attempt, $detail, '', true, false, false, true, $context); break; case 'sudokucheck': //the student tries to answer a question $attempt = game_getattempt($game, $detail); $finishattempt = array_key_exists('finishattempt', $_POST); game_sudoku_check_questions($id, $game, $attempt, $detail, $finishattempt, $course, $context); $continue = true; break; case 'sudokucheckg': //the student tries to guess a glossaryenry $attempt = game_getattempt($game, $detail); $endofgame = array_key_exists('endofgame', $_GET); $continue = game_sudoku_check_glossaryentries($id, $game, $attempt, $detail, $endofgame, $course); $continue = true; break; case 'sudokucheckn': //the user tries to guess a number $attempt = game_getattempt($game, $detail); $pos = $_GET['pos']; $num = $_GET['num']; game_sudoku_check_number($id, $game, $attempt, $detail, $pos, $num, $context); $continue = false; break; case 'cryptexcheck': //the user tries to guess a question $attempt = game_getattempt($game, $detail); $q = $_GET['q']; $answer = $_GET['answer']; game_cryptex_check($id, $game, $attempt, $detail, $q, $answer, $context); break; case 'bookquizcheck': //the student tries to answer a question $attempt = game_getattempt($game, $detail); game_bookquiz_check_questions($id, $game, $attempt, $detail); break; case 'snakescheck': //the student tries to answer a question $attempt = game_getattempt($game, $detail); game_snakes_check_questions($id, $game, $attempt, $detail, $context); break; case 'snakescheckg': //the student tries to answer a question from glossary $attempt = game_getattempt($game, $detail); game_snakes_check_glossary($id, $game, $attempt, $detail, $context); break; case 'hiddenpicturecheck': //the student tries to answer a question $attempt = game_getattempt($game, $detail); $finishattempt = array_key_exists('finishattempt', $_POST); $continue = game_hiddenpicture_check_questions($id, $game, $attempt, $detail, $finishattempt, $context); break; case 'hiddenpicturecheckg': //the student tries to guess a glossaryenry $attempt = game_getattempt($game, $detail); $endofgame = array_key_exists('endofgame', $_GET); game_hiddenpicture_check_mainquestion($id, $game, $attempt, $detail, $endofgame, $context); break; default: $continue = true; break; } if ($continue) { game_create($game, $id, $forcenew, $course, $context); } /// Finish the page echo $OUTPUT->footer(); }
$_GET['id'] = $update; require_once "header.php"; if (!isteacherinanycourse($USER->id)) { error(get_string('only_teachers', 'game')); } $gamekind = $_GET['gamekind']; $id = $update; $attemptid = (int) $_GET['attemptid']; $attempt = get_record_select('game_attempts', "id={$attemptid}"); $game = get_record_select('game', "id={$attempt->gameid}"); $detail = get_record_select('game_' . $gamekind, "id={$attemptid}"); if (array_key_exists('solution', $_GET)) { $solution = $_GET['solution']; } else { $solution = 0; } switch ($gamekind) { case 'cross': game_cross_play($update, $game, $attempt, $detail, '', true, $solution, false, false, false, false, true); break; case 'sudoku': game_sudoku_play($update, $game, $attempt, $detail, true, $solution); break; case 'hangman': game_hangman_play($update, $game, $attempt, $detail, true, $solution); break; case 'cryptex': $crossm = get_record_select('game_cross', "id={$attemptid}"); game_cryptex_play($update, $game, $attempt, $detail, $crossm, false, true, $solution); break; }
$attemptid = required_param('attemptid', PARAM_INT); $attempt = $DB->get_record('game_attempts', array('id' => $attemptid)); $game = $DB->get_record('game', array('id' => $attempt->gameid)); $detail = $DB->get_record('game_' . $gamekind, array('id' => $attemptid)); $solution = $action == 'solution'; $PAGE->navbar->add(get_string('preview', 'game')); switch ($gamekind) { case 'cross': $g = ''; $onlyshow = true; $endofgame = false; $print = false; $checkbutton = false; $showhtmlsolutions = false; $showhtmlprintbutton = true; $showstudentguess = false; game_cross_play($update, $game, $attempt, $detail, $g, $onlyshow, $solution, $endofgame, $print, $checkbutton, $showhtmlsolutions, $showhtmlprintbutton, $showstudentguess, $context); break; case 'sudoku': game_sudoku_play($update, $game, $attempt, $detail, true, $solution, $context); break; case 'hangman': $preview = $action == 'preview'; game_hangman_play($update, $game, $attempt, $detail, $preview, $solution, $context); break; case 'cryptex': $crossm = $DB->get_record('game_cross', array('id' => $attemptid)); game_cryptex_play($update, $game, $attempt, $detail, $crossm, false, true, $solution, $context); break; } echo $OUTPUT->footer();
require_once "bookquiz/play.php"; require_once "snakes/play.php"; require_once "hiddenpicture/play.php"; $forcenew = optional_param('forcenew', false, PARAM_BOOL); // Teacher has requested new preview /// Print the main part of the page switch ($action) { case 'crosscheck': $attempt = game_getattempt($game, $detail); $g = game_cross_unpackpuzzle($_GET['g']); $finishattempt = array_key_exists('finishattempt', $_GET); game_cross_continue($id, $game, $attempt, $detail, $g, $finishattempt); break; case 'crossprint': $attempt = game_getattempt($game, $detail); game_cross_play($id, $game, $attempt, $detail, '', true, false, false, true); break; case 'sudokucheck': //the student tries to answer a question $attempt = game_getattempt($game, $detail); $finishattempt = array_key_exists('finishattempt', $_POST); game_sudoku_check_questions($id, $game, $attempt, $detail, $finishattempt); break; case 'sudokucheckg': //the student tries to guess a glossaryenry $attempt = game_getattempt($game, $detail); $endofgame = array_key_exists('endofgame', $_GET); game_sudoku_check_glossaryentries($id, $game, $attempt, $detail, $endofgame); break; case 'sudokucheckn': //the user tries to guess a number