Ejemplo n.º 1
0
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<body onload=\"Reset();\">\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
    $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);
    //Copy the standard pictures of Millionaire
    $src = $CFG->dirroot . '/mod/game/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_millionaire($game, $html, $update, $destdir)
{
    global $CFG;
    if ($html->filename == '') {
        $html->filename = 'millionaire';
    }
    $filename = $html->filename . '.htm';
    $ret = game_export_printheader($html->title, false);
    $ret .= "\r<body onload=\"Reset();\">\r";
    ob_start();
    //Here is the code of millionaire
    require "exporthtml_millionaire.php";
    //End of millionaire code
    $output_string = ob_get_contents();
    ob_end_clean();
    $courseid = $game->course;
    $course = get_record_select('course', "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/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');
    if ($destdir != '') {
        remove_dir($destdir);
    }
    echo "{$ret}<a href=\"{$CFG->wwwroot}/file.php/{$courseid}/export/{$filezip}\">{$filezip}</a>";
}