Esempio n. 1
0
    $thiscontext = $contexts->lowest();
    if (!is_readable("format/$from_form->format/format.php")) {
        print_error('unknowformat', '', '', $from_form->format);
    }
    $withcategories = 'nocategories';
    if (!empty($from_form->cattofile)) {
        $withcategories = 'withcategories';
    }
    $withcontexts = 'nocontexts';
    if (!empty($from_form->contexttofile)) {
        $withcontexts = 'withcontexts';
    }

    $classname = 'qformat_' . $from_form->format;
    $qformat = new $classname();
    $filename = question_default_export_filename($COURSE, $category) .
            $qformat->export_file_extension();
    $export_url = question_make_export_url($thiscontext->id, $category->id,
            $from_form->format, $withcategories, $withcontexts, $filename);

    echo $OUTPUT->box_start();
    echo get_string('yourfileshoulddownload', 'question', $export_url->out());
    echo $OUTPUT->box_end();

    $PAGE->requires->js_function_call('document.location.replace', array($export_url->out()), false, 1);

    echo $OUTPUT->continue_button(new moodle_url('edit.php', $thispageurl->params()));
    echo $OUTPUT->footer();
    exit;
}
Esempio n. 2
0
echo $OUTPUT->header();
$export_form = new question_export_form($thispageurl, array('contexts' => $contexts->having_one_edit_tab_cap('export'), 'defaultcategory' => $pagevars['cat']));
if ($from_form = $export_form->get_data()) {
    $thiscontext = $contexts->lowest();
    if (!is_readable("format/{$from_form->format}/format.php")) {
        print_error('unknowformat', '', '', $from_form->format);
    }
    $withcategories = 'nocategories';
    if (!empty($from_form->cattofile)) {
        $withcategories = 'withcategories';
    }
    $withcontexts = 'nocontexts';
    if (!empty($from_form->contexttofile)) {
        $withcontexts = 'withcontexts';
    }
    $classname = 'qformat_' . $from_form->format;
    $qformat = new $classname();
    $filename = question_default_export_filename($COURSE, $category) . $qformat->export_file_extension();
    $export_url = question_make_export_url($thiscontext->id, $category->id, $from_form->format, $withcategories, $withcontexts, $filename);
    echo $OUTPUT->box_start();
    echo get_string('yourfileshoulddownload', 'question', $export_url->out());
    echo $OUTPUT->box_end();
    $PAGE->requires->js_function_call('document.location.replace', array($export_url->out()), false, 1);
    echo $OUTPUT->continue_button(new moodle_url('edit.php', $thispageurl->params()));
    echo $OUTPUT->footer();
    exit;
}
/// Display export form
echo $OUTPUT->heading_with_help($strexportquestions, 'exportquestions', 'question');
$export_form->display();
echo $OUTPUT->footer();
Esempio n. 3
0
$questiondata = $DB->get_record('question', array('id' => $questionid), '*', MUST_EXIST);
get_question_options($questiondata);
$question = question_bank::load_question($questionid);
// Process any other URL parameters, and do require_login.
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($question);
$contexts = new question_edit_contexts($context);
// Check permissions.
question_require_capability_on($questiondata, 'edit');
require_sesskey();
// Initialise $PAGE.
$nexturl = new moodle_url('/question/type/stack/questiontestrun.php', $urlparams);
$PAGE->set_url($nexturl);
// Since this script always ends in a redirect.
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_pagelayout('admin');
// Set up the export format.
$qformat = new qformat_xml();
$filename = question_default_export_filename($COURSE, $questiondata) . $qformat->export_file_extension();
$qformat->setContexts($contexts->having_one_edit_tab_cap('export'));
$qformat->setCourse($COURSE);
$qformat->setQuestions(array($questiondata));
$qformat->setCattofile(false);
$qformat->setContexttofile(false);
// Do the export.
if (!$qformat->exportpreprocess()) {
    send_file_not_found();
}
if (!($content = $qformat->exportprocess(true))) {
    send_file_not_found();
}
send_file($content, $filename, 0, 0, true, true, $qformat->mime_type());