Exemplo n.º 1
0
    // load data into class
    $qformat->setCategory($category);
    $qformat->setContexts($contexts->having_one_edit_tab_cap('import'));
    $qformat->setCourse($COURSE);
    $qformat->setFilename($importfile);
    $qformat->setRealfilename($realfilename);
    $qformat->setMatchgrades($form->matchgrades);
    $qformat->setCatfromfile(!empty($form->catfromfile));
    $qformat->setContextfromfile(!empty($form->contextfromfile));
    $qformat->setStoponerror($form->stoponerror);
    // Do anything before that we need to
    if (!$qformat->importpreprocess()) {
        print_error('cannotimport', '', $thispageurl->out());
    }
    // Process the uploaded file
    if (!$qformat->importprocess($category)) {
        print_error('cannotimport', '', $thispageurl->out());
    }
    // In case anything needs to be done after
    if (!$qformat->importpostprocess()) {
        print_error('cannotimport', '', $thispageurl->out());
    }
    $params = $thispageurl->params() + array('category' => $qformat->category->id . ',' . $qformat->category->contextid);
    echo $OUTPUT->continue_button(new moodle_url('edit.php', $params));
    echo $OUTPUT->footer();
    exit;
}
echo $OUTPUT->heading_with_help($txt->importquestions, 'importquestions', 'question');
/// Print upload form
$import_form->display();
echo $OUTPUT->footer();