category = get_string('category','quiz'); $txt->download = get_string('download','quiz'); $txt->downloadextra = get_string('downloadextra','quiz'); $txt->exporterror = get_string('exporterror','quiz'); $txt->exportname = get_string('exportname','quiz'); $txt->exportquestions = get_string('exportquestions', 'quiz'); $txt->fileformat = get_string('fileformat','quiz'); $txt->exportcategory = get_string('exportcategory','quiz'); $txt->modulename = get_string('modulename','quiz'); $txt->modulenameplural = get_string('modulenameplural','quiz'); $txt->tofile = get_string('tofile','quiz'); if (!$course = get_record("course", "id", $courseid)) { error("Course does not exist!"); } if (!$category = get_record("question_categories", "id", $pagevars['cat'])) { $category = get_default_question_category($courseid); } if (!$categorycourse = get_record("course", "id", $category->course)) { print_error('nocategory','quiz'); } // check role capability $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('moodle/question:export', $context); // ensure the files area exists for this course make_upload_directory( "$course->id" ); // check category is valid if (!empty($pagevars['cat'])) { $validcats = question_category_options( $course->id, true, false ); if (!array_key_exists( $pagevars['cat'], $validcats)) { print_error( 'invalidcategory','quiz' ); } } /// Header if ($cm!==null) { $strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id)) ? update_module_button($cm->id, $course->id, get_string('modulename', $cm->modname)) : ""; $crumbs = array(); $crumbs[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$course->id", 'type' => 'activity'); $crumbs[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?cmid={$cm->id}", 'type' => 'title'); $crumbs[] = array('name' => $txt->exportquestions, 'link' => '', 'type' => 'title'); $navigation = build_navigation($crumbs); print_header_simple($txt->exportquestions, '', $navigation, "", "", true, $strupdatemodule); $currenttab = 'edit'; $mode = 'export'; ${$cm->modname} = $module; include($CFG->dirroot."/mod/$cm->modname/tabs.php"); } else { // Print basic page layout. $crumbs = array(); $crumbs[] = array('name' => $txt->exportquestions, 'link' => '', 'type' => 'title'); $navigation = build_navigation($crumbs); print_header_simple($txt->exportquestions, '', $navigation); // print tabs $currenttab = 'export'; include('tabs.php'); } if (!empty($format)) { /// Filename if (!confirm_sesskey()) { print_error( 'sesskey' ); } if (! is_readable("format/$format/format.php")) { error( "Format not known ($format)" ); } // load parent class for import/export require("format.php"); // and then the class for the selected format require("format/$format/format.php"); $classname = "qformat_$format"; $qformat = new $classname(); $qformat->setCategory( $category ); $qformat->setCourse( $course ); $qformat->setFilename( $exportfilename ); $qformat->setCattofile( $cattofile ); if (! $qformat->exportpreprocess()) { // Do anything before that we need to error( $txt->exporterror, $thispageurl->out()); } if (! $qformat->exportprocess()) { // Process the export data error( $txt->exporterror, $thispageurl->out()); } if (! $qformat->exportpostprocess()) { // In case anything needs to be done after error( $txt->exporterror, $thispageurl->out()); } echo "