. /** * This page export the game millionaire to html * * @package mod_game * @copyright 2007 Vasilis Daloukas * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Exports millionaire. * * @param stdClass $game * @param stdClass $context * @param int $maxanswers * @param int $countofquestions * @param string $retfeedback * @param string $destdir * @param array $files */ 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; } /** * Exports to html a "Millionaire" game. * * @param stdClass $game * @param string $questions * @param int $maxquestions */ function game_millionaire_html_print( $game, $questions, $maxquestions) { $color1 = 'black'; $color2 = 'DarkOrange'; $colorback = "white"; $stylequestion = "background:$colorback;color:$color1"; $stylequestionselected = "background:$colorback;color:$color2"; ?>
> | > | ||||||||
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 " | \n"; echo "\n"; if ( $i == 1) { echo " | \n"; } echo "\n"; } ?> | |||||||