Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 89 lines (71 sloc) 3.256 kb
aeb1553 @skodak MDL-20700 coding style cleanup - cvs keywords removed, closign php tag r...
skodak authored
1 <?php
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
aca318e Moving import/export to new question area.
thepurpleblob authored
17 /**
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
18 * Script for importing questions into the question bank.
4323d02 Give the question bank code sensible PHPdocumentor package names.
tjhunt authored
19 *
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
20 * @package moodlecore
21 * @subpackage questionbank
22 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4323d02 Give the question bank code sensible PHPdocumentor package names.
tjhunt authored
24 */
aca318e Moving import/export to new question area.
thepurpleblob authored
25
26
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
27 require_once(dirname(__FILE__) . '/../config.php');
28 require_once($CFG->dirroot . '/question/editlib.php');
29 require_once($CFG->dirroot . '/question/export_form.php');
44a7f38 @timhunt MDL-29474 fix qtype and qbehaviour plugins to use proper pluginname stri...
timhunt authored
30 require_once($CFG->dirroot . '/question/format.php');
56ed242 @samhemelryk navigation MDL-20276 Fixed up the navigation for the quiz module and que...
samhemelryk authored
31
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
32 list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
33 question_edit_setup('export', '/question/export.php');
0c1e3a1 Changing the category on the import or export page also changes it on th...
gustav_delius authored
34
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
35 // get display strings
36 $strexportquestions = get_string('exportquestions', 'question');
aca318e Moving import/export to new question area.
thepurpleblob authored
37
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
38 list($catid, $catcontext) = explode(',', $pagevars['cat']);
5e8a85a @timhunt MDL-20636 Massively reduce the number of references to quiz in the quest...
timhunt authored
39 $category = $DB->get_record('question_categories', array("id" => $catid, 'contextid' => $catcontext), '*', MUST_EXIST);
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
40
41 /// Header
f19ed87 @timhunt MDL-26199 further changes needed to make the question bank navigation be...
timhunt authored
42 $PAGE->set_url($thispageurl);
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
43 $PAGE->set_title($strexportquestions);
44 $PAGE->set_heading($COURSE->fullname);
45 echo $OUTPUT->header();
46
87b564d @timhunt MDL-32246 question export: should cope with unrecognised qtypes.
timhunt authored
47 $export_form = new question_export_form($thispageurl,
48 array('contexts' => $contexts->having_one_edit_tab_cap('export'), 'defaultcategory' => $pagevars['cat']));
22afe6d MDL-9123:
thepurpleblob authored
49
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
50
51 if ($from_form = $export_form->get_data()) {
52 $thiscontext = $contexts->lowest();
53 if (!is_readable("format/$from_form->format/format.php")) {
54 print_error('unknowformat', '', '', $from_form->format);
55 }
56 $withcategories = 'nocategories';
57 if (!empty($from_form->cattofile)) {
58 $withcategories = 'withcategories';
aca318e Moving import/export to new question area.
thepurpleblob authored
59 }
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
60 $withcontexts = 'nocontexts';
61 if (!empty($from_form->contexttofile)) {
62 $withcontexts = 'withcontexts';
63 }
64
65 $classname = 'qformat_' . $from_form->format;
66 $qformat = new $classname();
67 $filename = question_default_export_filename($COURSE, $category) .
68 $qformat->export_file_extension();
69 $export_url = question_make_export_url($thiscontext->id, $category->id,
70 $from_form->format, $withcategories, $withcontexts, $filename);
aca318e Moving import/export to new question area.
thepurpleblob authored
71
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
72 echo $OUTPUT->box_start();
73 echo get_string('yourfileshoulddownload', 'question', $export_url->out());
74 echo $OUTPUT->box_end();
aca318e Moving import/export to new question area.
thepurpleblob authored
75
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
76 $PAGE->requires->js_function_call('document.location.replace', array($export_url->out()), false, 1);
271e6de merging MOODLE_19_QUESTIONS with HEAD
jamiesensei authored
77
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
78 echo $OUTPUT->continue_button(new moodle_url('edit.php', $thispageurl->params()));
9b59580 MDL-19820 Converted all print_footer() calls
nicolasconnault authored
79 echo $OUTPUT->footer();
d360315 @timhunt MDL-20636 Add @package and GPL boiler-plate to files in /question.
timhunt authored
80 exit;
81 }
82
83 /// Display export form
84 echo $OUTPUT->heading_with_help($strexportquestions, 'exportquestions', 'question');
85
86 $export_form->display();
87
88 echo $OUTPUT->footer();
Something went wrong with that request. Please try again.