Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/export.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 require_once(dirname(__FILE__) . '/../config.php');
00028 require_once($CFG->dirroot . '/question/editlib.php');
00029 require_once($CFG->dirroot . '/question/export_form.php');
00030 require_once($CFG->dirroot . '/question/format.php');
00031 
00032 list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
00033         question_edit_setup('export', '/question/export.php');
00034 
00035 // get display strings
00036 $strexportquestions = get_string('exportquestions', 'question');
00037 
00038 list($catid, $catcontext) = explode(',', $pagevars['cat']);
00039 $category = $DB->get_record('question_categories', array("id" => $catid, 'contextid' => $catcontext), '*', MUST_EXIST);
00040 
00042 $PAGE->set_url($thispageurl);
00043 $PAGE->set_title($strexportquestions);
00044 $PAGE->set_heading($COURSE->fullname);
00045 echo $OUTPUT->header();
00046 
00047 $export_form = new question_export_form($thispageurl, array('contexts'=>$contexts->having_one_edit_tab_cap('export'), 'defaultcategory'=>$pagevars['cat']));
00048 
00049 
00050 if ($from_form = $export_form->get_data()) {
00051     $thiscontext = $contexts->lowest();
00052     if (!is_readable("format/$from_form->format/format.php")) {
00053         print_error('unknowformat', '', '', $from_form->format);
00054     }
00055     $withcategories = 'nocategories';
00056     if (!empty($from_form->cattofile)) {
00057         $withcategories = 'withcategories';
00058     }
00059     $withcontexts = 'nocontexts';
00060     if (!empty($from_form->contexttofile)) {
00061         $withcontexts = 'withcontexts';
00062     }
00063 
00064     $classname = 'qformat_' . $from_form->format;
00065     $qformat = new $classname();
00066     $filename = question_default_export_filename($COURSE, $category) .
00067             $qformat->export_file_extension();
00068     $export_url = question_make_export_url($thiscontext->id, $category->id,
00069             $from_form->format, $withcategories, $withcontexts, $filename);
00070 
00071     echo $OUTPUT->box_start();
00072     echo get_string('yourfileshoulddownload', 'question', $export_url->out());
00073     echo $OUTPUT->box_end();
00074 
00075     $PAGE->requires->js_function_call('document.location.replace', array($export_url->out()), false, 1);
00076 
00077     echo $OUTPUT->continue_button(new moodle_url('edit.php', $thispageurl->params()));
00078     echo $OUTPUT->footer();
00079     exit;
00080 }
00081 
00083 echo $OUTPUT->heading_with_help($strexportquestions, 'exportquestions', 'question');
00084 
00085 $export_form->display();
00086 
00087 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations