function game_OnExportHTML_hangman($game, $html, $destdir) { global $CFG, $DB; if ($html->filename == '') { $html->filename = 'hangman'; } $filename = $html->filename . '.htm'; $ret = game_export_printheader($html->title, false); $ret .= "\r<body onload=\"reset()\">\r"; $export_attachment = $html->type == 'hangmanp'; $map = game_exmportjavame_getanswers($game, $export_attachment); if ($map == false) { error('No Questions'); } ob_start(); //Here is the code of hangman require "exporthtml_hangman.php"; $output_string = ob_get_contents(); ob_end_clean(); $courseid = $game->course; $course = $DB->get_record('course', array('id' => $courseid)); $filename = $html->filename . '.htm'; file_put_contents($destdir . '/' . $filename, $ret . "\r\n" . $output_string); if ($html->type != 'hangmanp') { //Not copy the standard pictures when we use the "Hangman with pictures" $src = $CFG->dirroot . '/mod/game/hangman/1'; $handle = opendir($src); while (false !== ($item = readdir($handle))) { if ($item != '.' && $item != '..') { if (!is_dir($src . '/' . $item)) { $itemdest = $item; if (strpos($item, '.') === false) { continue; } copy($src . '/' . $item, $destdir . '/' . $itemdest); } } } } $filezip = game_create_zip($destdir, $courseid, $html->filename . '.zip'); game_send_stored_file($destdir . '/' . $filezip); }
function game_exportjavame_exportdata($src, $destmobiledir, $destdir, $game, $maxwidth, $maxheight) { global $CFG; mkdir($destdir . '/' . $destmobiledir); $handle = opendir($src); while (false !== ($item = readdir($handle))) { if ($item != '.' && $item != '..') { if (!is_dir($src . '/' . $item)) { if (substr($item, -4) == '.jpg') { copy($src . '/' . $item, $destdir . "/{$destmobiledir}/" . $item); } } } } $lang = $game->language; if ($lang == '') { $lang = current_language(); } copy($src . '/lang/' . $lang . '/language.txt', $destdir . "/{$destmobiledir}/language.txt"); $export_attachment = $destmobiledir == 'hangmanp'; $map = game_exmportjavame_getanswers($game, $export_attachment); if ($map == false) { error('No Questions'); } if ($destmobiledir == 'hangmanp') { game_exportjavame_exportdata_hangmanp($src, $destmobiledir, $destdir, $game, $map, $maxwidth, $maxheight); return; } $fp = fopen($destdir . "/{$destmobiledir}/hangman.txt", "w"); fputs($fp, "1.txt={$destmobiledir}\r\n"); fclose($fp); $fp = fopen($destdir . "/{$destmobiledir}/1.txt", "w"); foreach ($map as $line) { $s = game_upper($line->answer) . '=' . $line->question; fputs($fp, "{$s}\r\n"); } fclose($fp); }
* * @author bdaloukas * @version $Id: exporthtml_hangman.php,v 1.2 2009/08/29 00:05:53 bdaloukas Exp $ * @package game **/ ?> <script type="text/javascript"> // Hangman for Moodle by Vasilis Daloukas // The script is based on HangMan II script- By Chris Fortey (http://www.c-g-f.net/) var can_play = true; <?php $destdir = game_export_createtempdir(); $export_attachment = $html->type == 'hangmanp'; $map = game_exmportjavame_getanswers($game, $export_attachment); if ($map == false) { error('No Questions'); } $questions = ''; $words = ''; $lang = ''; $allletters = ''; $images = ''; foreach ($map as $line) { $answer = game_upper($line->answer); if ($lang == '') { $lang = $game->language; if ($lang == '') { $lang = game_detectlanguage($answer); }
function game_OnExportHTML_snakes($game, $html, $destdir) { require_once "exporthtml_millionaire.php"; global $CFG, $DB; if ($html->filename == '') { $html->filename = 'snakes'; } $filename = $html->filename . '.htm'; $ret = ''; $board = game_snakes_get_board($game); if ($game->sourcemodule == 'quiz' or $game->sourcemodule == 'question') { $questionsM = game_millionaire_html_getquestions($game, $context, $maxquestions, $countofquestionsM, $retfeedback, $files); } else { $questionsM = array(); $countofquestionsM = 0; $retfeedback = ''; } $questionsS = game_exmportjavame_getanswers($game, false); ob_start(); //Here is the code of hangman require "exporthtml_snakes.php"; $output_string = ob_get_contents(); ob_end_clean(); $courseid = $game->course; $course = $DB->get_record('course', array('id' => $courseid)); $filename = $html->filename . '.htm'; file_put_contents($destdir . '/' . $filename, $ret . "\r\n" . $output_string); $src = $CFG->dirroot . '/mod/game/export/html/snakes'; game_copyfiles($src, $destdir); mkdir($destdir . '/css'); $src = $CFG->dirroot . '/mod/game/export/html/snakes/css'; game_copyfiles($src, $destdir . '/css'); mkdir($destdir . '/js'); $src = $CFG->dirroot . '/mod/game/export/html/snakes/js'; game_copyfiles($src, $destdir . '/js'); mkdir($destdir . '/images'); $destfile = $destdir . '/images/' . $board->fileboard; if ($game->param3 != 0) { //Is a standard board copy($board->imagesrc, $destfile); } else { $cmg = get_coursemodule_from_instance('game', $game->id, $game->course); $modcontext = get_context_instance(CONTEXT_MODULE, $cmg->id); $fs = get_file_storage(); $files = $fs->get_area_files($modcontext->id, 'mod_game', 'snakes_board', $game->id); foreach ($files as $f) { if ($f->is_directory()) { continue; } break; } $f->copy_content_to($destfile); } $a = array('player1.png', 'dice1.png', 'dice2.png', 'dice3.png', 'dice4.png', 'dice5.png', 'dice6.png', 'numbers.png'); foreach ($a as $file) { copy($CFG->dirroot . '/mod/game/snakes/1/' . $file, $destdir . '/images/' . $file); } $filezip = game_create_zip($destdir, $courseid, $html->filename . '.zip'); game_send_stored_file($filezip); }
* * @author bdaloukas * @version $Id: exporthtml_hangman.php,v 1.10 2012/07/25 11:16:03 bdaloukas Exp $ * @package game **/ ?> <script type="text/javascript"> // Hangman for Moodle by Vasilis Daloukas // The script is based on HangMan II script- By Chris Fortey (http://www.c-g-f.net/) var can_play = true; <?php $destdir = game_export_createtempdir(); $export_attachment = $html->type == 'hangmanp'; $map = game_exmportjavame_getanswers($game, $context, $export_attachment, $destdir, $files); if ($map == false) { print_error('No Questions'); } $questions = ''; $words = ''; $lang = ''; $allletters = ''; $images = ''; foreach ($map as $line) { $answer = game_upper($line->answer); if ($game->param7) { //Have to delete space $answer = str_replace(' ', '', $answer); } if ($game->param8) {