2009-11-04 11:57:52 +00:00
|
|
|
<?php
|
2006-02-24 15:17:40 +00:00
|
|
|
/**
|
2007-03-19 17:22:46 +00:00
|
|
|
* Export quiz questions into the given category
|
|
|
|
*
|
|
|
|
* @author Martin Dougiamas, Howard Miller, and many others.
|
|
|
|
* {@link http://moodle.org}
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
|
|
|
* @package questionbank
|
|
|
|
* @subpackage importexport
|
|
|
|
*/
|
2006-02-24 15:17:40 +00:00
|
|
|
|
|
|
|
require_once("../config.php");
|
2007-08-09 21:51:09 +00:00
|
|
|
require_once("editlib.php");
|
|
|
|
require_once("export_form.php");
|
2006-02-24 15:17:40 +00:00
|
|
|
|
2010-05-21 03:15:48 +00:00
|
|
|
$PAGE->set_pagelayout('standard');
|
|
|
|
|
2010-04-12 13:31:42 +00:00
|
|
|
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
|
|
|
|
question_edit_setup('export', '/question/export.php');
|
2007-03-21 10:41:28 +00:00
|
|
|
|
2007-02-07 10:29:53 +00:00
|
|
|
// get display strings
|
MDL-21695 question: replaced help files with new help strings
AMOS BEGIN
HLP question/categoryparent.html,[parentcategory_help,core_question]
HLP question/categories.html,[editcategories_help,core_question]
HLP quiz/export.html,[exportquestions_help,core_question]
HLP quiz/exportcategory.html,[exportcategory_help,core_question]
HLP quiz/exportcategory.html,[exportcategory_help,core_question]
HLP quiz/importcategory.html,[importcategory_help,core_question]
HLP quiz/matchgrades.html,[matchgrades_help,core_question]
HLP quiz/quiz/stoponerror.html,[stoponerror_help,core_question]
HLP qtype_multichoice/multichoiceshuffle.html,[shuffleanswers_help,qtype_multichoice]
HLP quiz/matchshuffle.html,[shuffle_help,qtype_match]
HLP quiz/generalfeedback.html,[generalfeedback_help,mod_quiz]
AMOS END
2010-08-02 21:24:32 +00:00
|
|
|
$strexportquestions = get_string('exportquestions', 'question');
|
2006-05-01 22:26:06 +00:00
|
|
|
|
2007-07-26 13:50:59 +00:00
|
|
|
// make sure we are using the user's most recent category choice
|
|
|
|
if (empty($categoryid)) {
|
|
|
|
$categoryid = $pagevars['cat'];
|
|
|
|
}
|
2006-02-24 15:17:40 +00:00
|
|
|
|
2007-08-09 21:51:09 +00:00
|
|
|
list($catid, $catcontext) = explode(',', $pagevars['cat']);
|
2008-06-06 14:43:15 +00:00
|
|
|
if (!$category = $DB->get_record("question_categories", array("id" => $catid, 'contextid' => $catcontext))) {
|
2007-08-09 21:51:09 +00:00
|
|
|
print_error('nocategory','quiz');
|
2007-04-11 11:00:26 +00:00
|
|
|
}
|
|
|
|
|
2007-02-07 10:29:53 +00:00
|
|
|
/// Header
|
2009-10-16 03:22:20 +00:00
|
|
|
$PAGE->set_url($thispageurl->out());
|
MDL-21695 question: replaced help files with new help strings
AMOS BEGIN
HLP question/categoryparent.html,[parentcategory_help,core_question]
HLP question/categories.html,[editcategories_help,core_question]
HLP quiz/export.html,[exportquestions_help,core_question]
HLP quiz/exportcategory.html,[exportcategory_help,core_question]
HLP quiz/exportcategory.html,[exportcategory_help,core_question]
HLP quiz/importcategory.html,[importcategory_help,core_question]
HLP quiz/matchgrades.html,[matchgrades_help,core_question]
HLP quiz/quiz/stoponerror.html,[stoponerror_help,core_question]
HLP qtype_multichoice/multichoiceshuffle.html,[shuffleanswers_help,qtype_multichoice]
HLP quiz/matchshuffle.html,[shuffle_help,qtype_match]
HLP quiz/generalfeedback.html,[generalfeedback_help,mod_quiz]
AMOS END
2010-08-02 21:24:32 +00:00
|
|
|
$PAGE->set_title($strexportquestions);
|
2010-06-02 06:13:27 +00:00
|
|
|
$PAGE->set_heading($COURSE->fullname);
|
2010-05-21 03:15:48 +00:00
|
|
|
echo $OUTPUT->header();
|
2006-02-24 15:17:40 +00:00
|
|
|
|
2010-11-05 06:34:00 +00:00
|
|
|
$export_form = new question_export_form($thispageurl, array('contexts'=>$contexts->having_one_edit_tab_cap('export'), 'defaultcategory'=>$pagevars['cat']));
|
2006-02-24 15:17:40 +00:00
|
|
|
|
|
|
|
|
2010-11-05 06:34:00 +00:00
|
|
|
if ($from_form = $export_form->get_data()) {
|
|
|
|
$thiscontext = $contexts->lowest();
|
|
|
|
if (!is_readable("format/$from_form->format/format.php")) {
|
2008-05-21 07:53:23 +00:00
|
|
|
print_error('unknowformat', '', '', $from_form->format);
|
2007-08-09 21:51:09 +00:00
|
|
|
}
|
2010-11-05 06:34:00 +00:00
|
|
|
$withcategories = 'nocategories';
|
|
|
|
if (!empty($from_form->cattofile)) {
|
|
|
|
$withcategories = 'withcategories';
|
2007-08-09 21:51:09 +00:00
|
|
|
}
|
2010-11-05 06:34:00 +00:00
|
|
|
$withcontexts = 'nocontexts';
|
|
|
|
if (!empty($from_form->contexttofile)) {
|
|
|
|
$withcontexts = 'withcontexts';
|
2006-02-24 15:17:40 +00:00
|
|
|
}
|
|
|
|
|
2010-11-19 11:02:28 +00:00
|
|
|
$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);
|
2006-02-24 15:17:40 +00:00
|
|
|
|
2010-11-05 06:34:00 +00:00
|
|
|
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);
|
2006-02-24 15:17:40 +00:00
|
|
|
|
2010-01-17 10:54:13 +00:00
|
|
|
echo $OUTPUT->continue_button(new moodle_url('edit.php', $thispageurl->params()));
|
2009-08-06 14:19:16 +00:00
|
|
|
echo $OUTPUT->footer();
|
2006-02-24 15:17:40 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:51:09 +00:00
|
|
|
/// Display export form
|
MDL-21695 question: replaced help files with new help strings
AMOS BEGIN
HLP question/categoryparent.html,[parentcategory_help,core_question]
HLP question/categories.html,[editcategories_help,core_question]
HLP quiz/export.html,[exportquestions_help,core_question]
HLP quiz/exportcategory.html,[exportcategory_help,core_question]
HLP quiz/exportcategory.html,[exportcategory_help,core_question]
HLP quiz/importcategory.html,[importcategory_help,core_question]
HLP quiz/matchgrades.html,[matchgrades_help,core_question]
HLP quiz/quiz/stoponerror.html,[stoponerror_help,core_question]
HLP qtype_multichoice/multichoiceshuffle.html,[shuffleanswers_help,qtype_multichoice]
HLP quiz/matchshuffle.html,[shuffle_help,qtype_match]
HLP quiz/generalfeedback.html,[generalfeedback_help,mod_quiz]
AMOS END
2010-08-02 21:24:32 +00:00
|
|
|
echo $OUTPUT->heading_with_help($strexportquestions, 'exportquestions', 'question');
|
2006-02-24 15:17:40 +00:00
|
|
|
|
2007-08-09 21:51:09 +00:00
|
|
|
$export_form->display();
|
|
|
|
|
2009-08-06 14:19:16 +00:00
|
|
|
echo $OUTPUT->footer();
|