From 7fdf1ba09b81ca18b8241293607c9b6968d5e4a8 Mon Sep 17 00:00:00 2001 From: Vasilis Daloukas Date: Wed, 7 Jun 2017 12:15:29 +0300 Subject: [PATCH] Moodle 3.3 compatibility --- cross/cross_class.php | 1 - cross/play.php | 7 +- export/export_form.php~ | 190 ------------- export/exporthtml.php~ | 437 ----------------------------- export/exporthtml_snakes.php | 1 + exporthtml_hangman.php | 372 ------------------------- exporthtml_millionaire.php | 518 ---------------------------------- exporthtml_snakes.php | 519 ----------------------------------- lib.php | 4 +- 9 files changed, 7 insertions(+), 2042 deletions(-) delete mode 100644 export/export_form.php~ delete mode 100644 export/exporthtml.php~ delete mode 100644 exporthtml_hangman.php delete mode 100644 exporthtml_millionaire.php delete mode 100644 exporthtml_snakes.php diff --git a/cross/cross_class.php b/cross/cross_class.php index 557ce01..41171cb 100644 --- a/cross/cross_class.php +++ b/cross/cross_class.php @@ -63,7 +63,6 @@ class Cross foreach ($reps as $word => $r) { $this->mreps[ game_upper( $word)] = $r; } - $this->maveragereps = 0; foreach ($reps as $r) { $this->maveragereps += $r; diff --git a/cross/play.php b/cross/play.php index 5d90f3d..5554d8b 100644 --- a/cross/play.php +++ b/cross/play.php @@ -480,7 +480,7 @@ function ContainsBadChars(theirWord) { // Pads a number out to three characters. function PadNumber(number) { - if (number < 10) } + if (number < 10) { return "00" + number; } else if (number < 100) { return "0" + number; @@ -1135,8 +1135,9 @@ function game_cross_show_welcome1() { } function game_cross_show_legends( $cross) { - echo ''; + //echo ''; + ShowLegend( $cross->mlegendh, get_string( 'cross_across', 'game')); ShowLegend( $cross->mlegendv, get_string( 'cross_down', 'game')); - echo ''; + //echo ''; } diff --git a/export/export_form.php~ b/export/export_form.php~ deleted file mode 100644 index e25bc7b..0000000 --- a/export/export_form.php~ +++ /dev/null @@ -1,190 +0,0 @@ -_form; - $html = $this->_customdata['html']; - - $mform->addElement('header', 'general', get_string('general', 'form')); - - if ( $game->gamekind == 'hangman') { - $options = array(); - $options[ '0'] = 'Hangman with phrases'; - $options[ 'hangmanp'] = 'Hangman with pictures'; - $mform->addElement('select', 'type', get_string('javame_type', 'game'), $options); - if ( $html->type == 0) { - $mform->setDefault('type', '0'); - } else { - $mform->setDefault('type', 'hangmanp'); - } - } - - // Input the filename. - $mform->addElement('text', 'filename', get_string('javame_filename', 'game'), array('size' => '30')); - $mform->setDefault('filename', $html->filename); - $mform->setType('filename', PARAM_TEXT); - - // Input the html title. - $mform->addElement('text', 'title', get_string('html_title', 'game'), array('size' => '80')); - $mform->setDefault('title', $html->title); - $mform->setType('title', PARAM_TEXT); - - // Inputs special fields for hangman. - if ($game->gamekind == 'hangman') { - $mform->addElement('text', 'maxpicturewidth', get_string('javame_maxpicturewidth', 'game'), array('size' => '5')); - $mform->setDefault('maxpicturewidth', $html->maxpicturewidth); - $mform->setType('maxpicturewidth', PARAM_INT); - $mform->addElement('text', 'maxpictureheight', get_string('javame_maxpictureheight', 'game'), array('size' => '5')); - $mform->setDefault('maxpictureheight', $html->maxpictureheight); - $mform->setType('maxpictureheight', PARAM_INT); - } - - // Input special fields for crossword. - if ( $game->gamekind == 'cross') { - $mform->addElement('selectyesno', 'checkbutton', get_string('html_hascheckbutton', 'game')); - $mform->setDefault('checkbutton', $html->checkbutton); - $mform->addElement('selectyesno', 'printbutton', get_string('html_hasprintbutton', 'game')); - $mform->setDefault('printbutton', $html->printbutton); - } - - $mform->addElement('hidden', 'q', $game->id); - $mform->setType('q', PARAM_INT); - $mform->addElement('hidden', 'target', 'html'); - $mform->setType('target', PARAM_TEXT); - - $mform->addElement('submit', 'submitbutton', get_string( 'export', 'game')); - $mform->closeHeaderBefore('submitbutton'); - } - - public function validation($data, $files) { - global $CFG, $USER, $DB; - $errors = parent::validation($data, $files); - - return $errors; - } - - public function export() { - global $game, $DB; - - $mform = $this->_form; - - $html = new stdClass(); - $html->id = $this->_customdata['html']->id; - $html->type = optional_param('type', 0, PARAM_ALPHANUM); - $html->filename = $mform->getElementValue('filename'); - $html->title = $mform->getElementValue('title'); - $html->maxpicturewidth = optional_param('maxpicturewidth', 0, PARAM_INT); - $html->maxpictureheight = optional_param('maxpictureheight', 0, PARAM_INT); - if ( $mform->elementExists( 'checkbutton')) { - $checkbuttonvalue = $mform->getElementValue('checkbutton'); - $html->checkbutton = $checkbuttonvalue[ 0]; - } - if ( $mform->elementExists( 'printbutton')) { - $printbuttonvalue = $mform->getElementValue('printbutton'); - $html->printbutton = $printbuttonvalue[ 0]; - } - - if (!($DB->update_record( 'game_export_html', $html))) { - print_error("game_export_html: not updated id=$html->id"); - } - - $cm = get_coursemodule_from_instance('game', $game->id, $game->course); - $context = game_get_context_module_instance( $cm->id); - - require_once("exporthtml.php"); - game_OnExportHTML( $game, $context, $html); - } -} - -class mod_game_exportjavame_form extends moodleform { - - public function definition() { - global $CFG, $DB, $game; - - $mform = $this->_form; - $javame = $this->_customdata['javame']; - - $mform->addElement('header', 'general', get_string('general', 'form')); - - if ( $game->gamekind == 'hangman') { - $options = array(); - $options[ '0'] = 'Hangman with phrases'; - $options[ 'hangmanp'] = 'Hangman with pictures'; - $mform->addElement('select', 'type', get_string('javame_type', 'game'), $options); - } - - $mform->addElement('text', 'filename', get_string('javame_filename', 'game'), array('size' => '30')); - $mform->setDefault('filename', $javame->filename); - $mform->setType('filename', PARAM_TEXT); - $mform->addElement('text', 'icon', get_string('javame_icon', 'game')); - $mform->setDefault('icon', $javame->icon); - $mform->setType('icon', PARAM_TEXT); - $mform->addElement('text', 'createdby', get_string('javame_createdby', 'game')); - $mform->setDefault('createdby', $javame->createdby); - $mform->setType('createdby', PARAM_TEXT); - $mform->addElement('text', 'vendor', get_string('javame_vendor', 'game')); - $mform->setDefault('vendor', $javame->vendor); - $mform->setType('vendor', PARAM_TEXT); - $mform->addElement('text', 'name', get_string('javame_name', 'game'), array('size' => '80')); - $mform->setDefault('name', $javame->name); - $mform->setType('name', PARAM_TEXT); - $mform->addElement('text', 'description', get_string('javame_description', 'game'), array('size' => '80')); - $mform->setDefault('description', $javame->description); - $mform->setType('description', PARAM_TEXT); - $mform->addElement('text', 'version', get_string('javame_version', 'game'), array('size' => '10')); - $mform->setDefault('version', $javame->version); - $mform->setType('version', PARAM_TEXT); - $mform->addElement('text', 'maxpicturewidth', get_string('javame_maxpicturewidth', 'game'), array('size' => '5')); - $mform->setDefault('maxpicturewidth', $javame->maxpicturewidth); - $mform->setType('maxpicturewidth', PARAM_INT); - $mform->addElement('text', 'maxpictureheight', get_string('javame_maxpictureheight', 'game'), array('size' => '5')); - $mform->setDefault('maxpictureheight', $javame->maxpictureheight); - $mform->setType('maxpictureheight', PARAM_INT); - - $mform->addElement('hidden', 'q', $game->id); - $mform->setType('q', PARAM_INT); - $mform->addElement('hidden', 'target', 'javame'); - $mform->setType('target', PARAM_TEXT); - - $mform->addElement('submit', 'submitbutton', get_string( 'export', 'game')); - $mform->closeHeaderBefore('submitbutton'); - } - - public function validation($data, $files) { - global $CFG, $USER, $DB; - $errors = parent::validation($data, $files); - - return $errors; - } - - public function export() { - global $game, $DB; - - $mform = $this->_form; - - $javame = $this->_customdata['javame']; - - $javame->type = optional_param('type', 0, PARAM_ALPHANUM); - $javame->filename = $mform->getElementValue('filename'); - $javame->icon = $mform->getElementValue('icon'); - $javame->createdby = $mform->getElementValue('createdby'); - $javame->vendor = $mform->getElementValue('vendor'); - $javame->name = $mform->getElementValue('name'); - $javame->description = $mform->getElementValue('description'); - $javame->version = $mform->getElementValue('version'); - $javame->maxpicturewidth = $mform->getElementValue('maxpicturewidth'); - $javame->maxpictureheight = $mform->getElementValue('maxpictureheight'); - - if (!($DB->update_record( 'game_export_javame', $javame))) { - print_error("game_export_javame: not updated id=$javame->id"); - } - - require_once("exportjavame.php"); - game_OnExportJavaME( $game, $javame); - } - -} - diff --git a/export/exporthtml.php~ b/export/exporthtml.php~ deleted file mode 100644 index b15a20d..0000000 --- a/export/exporthtml.php~ +++ /dev/null @@ -1,437 +0,0 @@ -. - -/* - * This page export the game to html for games: cross, hangman - * - * @author bdaloukas - * @package game - **/ - -defined('MOODLE_INTERNAL') || die(); - -require_once( "locallib.php"); -require_once( "exportjavame.php"); - -function game_onexporthtml( $game, $context, $html) { - global $CFG; - - $destdir = game_export_createtempdir(); - - switch( $game->gamekind) { - case 'cross'; - game_onexporthtml_cross( $game, $context, $html, $destdir); - break; - case 'hangman': - game_onexporthtml_hangman( $game, $context, $html, $destdir); - break; - case 'snakes': - game_onexporthtml_snakes( $game, $html, $destdir, $context); - break; - case 'millionaire': - game_onexporthtml_millionaire( $game, $context, $html, $destdir); - break; - } - - remove_dir( $destdir); -} - -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
"; - - ob_start(); - - game_cross_play( 0, $game, $attempt, $crossrec, '', true, false, false, false, - $html->checkbutton, true, $html->printbutton, false, $context); - - $outputstring = 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" . $outputstring); - - $filename = game_onexporthtml_cross_repair_questions( $game, $context, $filename, $destdir); - - game_send_stored_file( $filename); -} - -function game_onexporthtml_cross_repair_questions( $game, $context, $filename, $destdir) { - global $CFG, $DB; - - $filehandle = fopen( $destdir.'/'.$filename, "rb"); - - $found = false; - $files = array(); - $contextcourse = false; - $linesbefore = array(); - $linesafter = array(); - while (!feof($filehandle) ) { - $line = fgets( $filehandle); - - if ($found) { - if ( strpos( $line, 'new Array')) { - $linesafter[] = $line; - break; - } - $array .= $line; - continue; - } - - if (strpos( $line, 'Clue = new Array') === false) { - $linesbefore[] = $line; - continue; - } - - $array = $line; - $found = true; - } - while (!feof($filehandle) ) { - $linesafter[] = fgets( $filehandle); - } - - fclose($filehandle); - - $search = $CFG->wwwroot.'/pluginfile.php'; - $pos = 0; - $search = '"'.$CFG->wwwroot.'/pluginfile.php/'.$context->id.'/mod_game/'; - $len = strlen( $search); - $start = 0; - $filescopied = false; - for (;;) { - $pos1 = strpos( $array, $search, $start); - if ( $pos1 == false) { - break; - } - - $pos2 = strpos( $array, '\"', $pos1 + $len); - if ( $pos2 == false) { - break; - } - - // Have to copy the files. - if ($contextcourse === false) { - mkdir( $destdir.'/images'); - if (!$contextcourse = get_context_instance(CONTEXT_COURSE, $game->course)) { - print_error('nocontext'); - } - $fs = get_file_storage(); - } - - $inputs = explode( '/', substr( $array, $pos1 + $len, $pos2 - $pos1 - $len)); - - $filearea = $inputs[ 0]; - $id = $inputs[ 1]; - $fileimage = urldecode( $inputs[ 2]); - $component = 'question'; - - $params = array( 'component' => $component, 'filearea' => $filearea, - 'itemid' => $id, 'filename' => $fileimage, 'contextid' => $context, 'contextid' => $contextcourse->id); - $rec = $DB->get_record( 'files', $params); - if ( $rec == false) { - break; - } - - if (!$file = $fs->get_file_by_hash($rec->pathnamehash) or $file->is_directory()) { - continue; - } - - $posext = strrpos( $fileimage, '.'); - $filenoext = substr( $fileimage, $posext); - $ext = substr( $fileimage, $posext + 1); - for ($i = 0;; $i++) { - $newfile = $filenoext.$i; - $newfile = md5( $newfile).'.'.$ext; - if (!array_search( $newfile, $files)) { - break; - } - } - $file->copy_content_to( $destdir.'/images/'.$newfile); - $filescopied = true; - - $array = substr( $array, 0, $pos1 + 1).'images/'.$newfile.substr( $array, $pos2); - } - - if ($filescopied == false) { - return $destdir.'/'.$filename; - } - - $linesbefore[] = $array; - foreach ($linesafter as $line) { - $linesbefore [] = $line; - } - file_put_contents( $destdir.'/'.$filename, $linesbefore); - - $pos = strrpos( $filename, '.'); - if ($pos === false) { - $filezip = $filename.'.zip'; - } else { - $filezip = substr( $filename, 0, $pos).'.zip'; - } - - $filezip = game_create_zip( $destdir, $game->course, $filezip); - - return $filezip; -} - -function game_export_printheader( $title, $showbody=true) { - $ret = ''."\n"; - $ret .= ''."\n"; - $ret .= "\n"; - $ret .= ''."\n"; - $ret .= ''."\n"; - $ret .= "$title\n"; - $ret .= "\n"; - if ($showbody) { - $ret .= ""; - } - - return $ret; -} - -function game_onexporthtml_hangman( $game, $context, $html, $destdir) { - - global $CFG, $DB; - - if ($html->filename == '') { - $html->filename = 'hangman'; - } - - if ($game->param10 <= 0) { - $game->param10 = 6; - } - - $filename = $html->filename . '.htm'; - - $ret = game_export_printheader( $html->title, false); - $ret .= "\r\r"; - - $exportattachment = ( $html->type == 'hangmanp'); -print_r( $game); - $map = game_exmportjavame_getanswers( $game, $context, $exportattachment, $destdir, $files); - if ($map == false) { - print_error( get_string('no_words', 'game')); - } - - ob_start(); - - // Here is the code of hangman. - require_once( "exporthtml_hangman.php"); - - $outputstring = 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" . $outputstring); - - if ($html->type != 'hangmanp') { - // Not copy the standard pictures when we use the "Hangman with pictures". - $src = $CFG->dirroot.'/mod/game/pix/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( $filezip); -} - -function game_onexporthtml_millionaire( $game, $context, $html, $destdir) { - - global $CFG, $DB; - - if ($html->filename == '') { - $html->filename = 'millionaire'; - } - - $filename = $html->filename . '.htm'; - - $ret = game_export_printheader( $html->title, false); - $ret .= "\r\r"; - - // Here is the code of millionaire. - require( "exporthtml_millionaire.php"); - - $questions = game_millionaire_html_getquestions( $game, $context, $maxanswers, $maxquestions, $retfeedback, $destdir, $files); - ob_start(); - - game_millionaire_html_print( $game, $questions, $maxanswers); - - // End of millionaire code. - $outputstring = 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" . $outputstring); - - // Copy the standard pictures of Millionaire. - $src = $CFG->dirroot.'/mod/game/pix/millionaire/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($filezip); -} - -function game_onexporthtml_snakes( $game, $html, $destdir, $context) { - 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, $destdir, $files); - } else { - $questionsm = array(); - $countofquestionsm = 0; - $retfeedback = ''; - } - $questionss = game_exmportjavame_getanswers( $game, $context, false, $destdir, $files); - - ob_start(); - - // Here is the code of Snakes and Ladders. - require( "exporthtml_snakes.php"); - - $outputstring = 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" . $outputstring); - - $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'); - unzip_file($destdir.'/js/js.zip', $destdir.'/js', false); - unlink( $destdir.'/js/js.zip'); - - 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); -} - -function game_copyfiles( $src, $destdir) { - $handle = opendir( $src); - while (($item = readdir($handle)) !== false) { - if ( $item == '.' or $item == '..') { - continue; - } - - if ( strpos( $item, '.') === false) { - continue; - } - - if (is_dir($src.'/'.$item)) { - continue; - } - - copy( $src.'/'.$item, $destdir.'/'.$item); - } - closedir($handle); -} diff --git a/export/exporthtml_snakes.php b/export/exporthtml_snakes.php index dd921a6..d63aa0d 100644 --- a/export/exporthtml_snakes.php +++ b/export/exporthtml_snakes.php @@ -113,6 +113,7 @@ pawn_height [0]= 40; echo "var countofquestionsM=$countofquestionsm;\r\n"; echo 'var countofquestionsS='.count($questionss).";\r\n"; +$questionsm = ''; foreach ($questionss as $line) { $s = $line->question.'#'.str_replace( array( '"', '#'), array( "'", ' '), $line->answer); if ($questionsm != '') { diff --git a/exporthtml_hangman.php b/exporthtml_hangman.php deleted file mode 100644 index 9629de5..0000000 --- a/exporthtml_hangman.php +++ /dev/null @@ -1,372 +0,0 @@ -. - -/* - * This page export the game hangman to html - * - * @author bdaloukas - * @package game - **/ - -defined('MOODLE_INTERNAL') || die(); - -?> - - - -
- - -
-
-
-
-
- - diff --git a/exporthtml_millionaire.php b/exporthtml_millionaire.php deleted file mode 100644 index cf91793..0000000 --- a/exporthtml_millionaire.php +++ /dev/null @@ -1,518 +0,0 @@ -. - -/** - * This page export the game millionaire to html - * - * @author bdaloukas - * @package game - **/ - -defined('MOODLE_INTERNAL') || die(); - -function game_millionaire_html_getquestions( $game, $context, &$maxanswers, &$countofquestions, &$retfeedback, $destdir, &$files) { - global $CFG, $DB, $USER; - - $maxanswers = 0; - $countofquestions = 0; - - $files = array(); - - if ( ($game->sourcemodule != 'quiz') and ($game->sourcemodule != 'question')) { - print_error( get_string('millionaire_sourcemodule_must_quiz_question', 'game', get_string( 'modulename', 'quiz')). - ' '.get_string( 'modulename', $game->sourcemodule)); - } - - if ( $game->sourcemodule == 'quiz') { - if ( $game->quizid == 0) { - print_error( get_string( 'must_select_quiz', 'game')); - } - $select = "qtype='multichoice' AND quiz='$game->quizid' ". - " AND qqi.question=q.id"; - $table = "{question} q,{quiz_question_instances} qqi"; - } else { - if ( $game->questioncategoryid == 0) { - print_error( get_string( 'must_select_questioncategory', 'game')); - } - - // Include subcategories. - $select = 'category='.$game->questioncategoryid; - if ( $game->subcategories) { - $cats = question_categorylist( $game->questioncategoryid); - if (strpos( $cats, ',') > 0) { - $select = 'category in ('.$cats.')'; - } - } - $select .= " AND qtype='multichoice'"; - - $table = "{question} q"; - } - $select .= " AND q.hidden=0"; - $sql = "SELECT q.id as id, q.questiontext FROM $table WHERE $select"; - $recs = $DB->get_records_sql( $sql); - $ret = ''; - $retfeedback = ''; - foreach ($recs as $rec) { - $recs2 = $DB->get_records( 'question_answers', array( 'question' => $rec->id), 'fraction DESC', 'id,answer,feedback'); - - // Must parse the questiontext and get the name of files. - $line = $rec->questiontext; - $line = game_export_split_files( $game->course, $context, 'questiontext', $rec->id, $rec->questiontext, $destdir, $files); - $linefeedback = ''; - foreach ($recs2 as $rec2) { - $line .= '#'.str_replace( array( '"', '#'), array( "'", ' '), - game_export_split_files( $game->course, $context, 'answer', $rec2->id, $rec2->answer, $destdir, $files)); - $linefeedback .= '#'.str_replace( array( '"', '#'), array( "'", ' '), $rec2->feedback); - } - if ( $ret != '') { - $ret .= ",\r"; - } - $ret .= '"'.base64_encode( $line).'"'; - - if ( $retfeedback != '') { - $retfeedback .= ",\r"; - } - $retfeedback .= '"'.base64_encode( $linefeedback).'"'; - - if ( count( $recs2) > $maxanswers) { - $maxanswers = count( $recs2); - } - $countofquestions++; - } - - return $ret; -} - -function game_millionaire_html_print( $game, $questions, $maxquestions) { - $color1 = 'black'; - $color2 = 'DarkOrange'; - $colorback = "white"; - $stylequestion = "background:$colorback;color:$color1"; - $stylequestionselected = "background:$colorback;color:$color2"; -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"; - echo "\n"; - echo "\n"; - if ( $i == 1) { - echo "\n"; - } - echo "\n"; -} -?> - - - -
>              >        
-  -  -  -  - style='background:#408080'>      15      150000
14 800000
13 400000
-
aa
12 200000
11 10000
10 5000
9 4000
8 2000
7 1500
6 1000
5 500
4 400
3 300
2 200
1 100
     
"; - echo ""; - echo "  
     
- - - - -. - -/* - * This page export the game snakes to html - * - * @author bdaloukas - * @package game - **/ - -defined('MOODLE_INTERNAL') || die(); - -?> - - - - -<?php echo $html->title;?> - - - - - - - - - - - - - - - - - diff --git a/lib.php b/lib.php index fc8da5b..19b4530 100644 --- a/lib.php +++ b/lib.php @@ -1360,12 +1360,12 @@ function game_get_context_course_instance( $courseid) { return get_context_instance( CONTEXT_COURSE, $courseid); } -function game_pix_url( $filename) { +function game_pix_url( $filename, $module='') { global $OUTPUT; if (game_get_moodle_version() >= '03.03') { return $OUTPUT->image_url($filename, 'mod_game'); } else { - return $OUTPUT->pix_url($filename, 'mod_game'); + return $OUTPUT->pix_url($filename, $module); } }