2009-11-04 11:57:52 +00:00
|
|
|
<?php
|
2011-02-22 19:59:12 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2009-02-25 07:14:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a screen where the user can choose a question type, before being
|
|
|
|
* redirected to question.php
|
|
|
|
*
|
2011-02-22 19:59:12 +00:00
|
|
|
* @package moodlecore
|
|
|
|
* @subpackage questionbank
|
|
|
|
* @copyright 2009 Tim Hunt
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
2009-02-25 07:14:03 +00:00
|
|
|
|
2016-02-26 17:47:58 +11:00
|
|
|
require_once(__DIR__ . '/../config.php');
|
|
|
|
require_once(__DIR__ . '/editlib.php');
|
2009-02-25 07:14:03 +00:00
|
|
|
|
|
|
|
// Read URL parameters.
|
|
|
|
$categoryid = required_param('category', PARAM_INT);
|
|
|
|
$cmid = optional_param('cmid', 0, PARAM_INT);
|
|
|
|
$courseid = optional_param('courseid', 0, PARAM_INT);
|
|
|
|
$returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);
|
|
|
|
$appendqnumstring = optional_param('appendqnumstring', '', PARAM_ALPHA);
|
2010-05-06 22:33:21 +00:00
|
|
|
$validationerror = optional_param('validationerror', false, PARAM_BOOL);
|
2009-02-25 07:14:03 +00:00
|
|
|
|
|
|
|
// Place to accumulate hidden params for the form we will print.
|
|
|
|
$hiddenparams = array('category' => $categoryid);
|
|
|
|
|
|
|
|
// Validate params.
|
|
|
|
if (!$category = $DB->get_record('question_categories', array('id' => $categoryid))) {
|
|
|
|
print_error('categorydoesnotexist', 'question', $returnurl);
|
|
|
|
}
|
|
|
|
|
2009-03-17 08:34:56 +00:00
|
|
|
if ($cmid) {
|
2009-02-25 07:14:03 +00:00
|
|
|
list($module, $cm) = get_module_from_cmid($cmid);
|
|
|
|
require_login($cm->course, false, $cm);
|
2012-07-24 16:57:51 +08:00
|
|
|
$thiscontext = context_module::instance($cmid);
|
2009-02-25 07:14:03 +00:00
|
|
|
$hiddenparams['cmid'] = $cmid;
|
|
|
|
} else if ($courseid) {
|
|
|
|
require_login($courseid, false);
|
2012-07-24 16:57:51 +08:00
|
|
|
$thiscontext = context_course::instance($courseid);
|
2009-02-25 07:14:03 +00:00
|
|
|
$module = null;
|
|
|
|
$cm = null;
|
|
|
|
$hiddenparams['courseid'] = $courseid;
|
|
|
|
} else {
|
|
|
|
print_error('missingcourseorcmid', 'question');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check permissions.
|
2012-08-21 14:20:30 +08:00
|
|
|
$categorycontext = context::instance_by_id($category->contextid);
|
2009-02-25 07:14:03 +00:00
|
|
|
require_capability('moodle/question:add', $categorycontext);
|
|
|
|
|
|
|
|
// Ensure other optional params get passed on to question.php.
|
|
|
|
if (!empty($returnurl)) {
|
|
|
|
$hiddenparams['returnurl'] = $returnurl;
|
|
|
|
}
|
|
|
|
if (!empty($appendqnumstring)) {
|
|
|
|
$hiddenparams['appendqnumstring'] = $appendqnumstring;
|
|
|
|
}
|
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$PAGE->set_url('/question/addquestion.php', $hiddenparams);
|
2014-10-02 21:45:15 +01:00
|
|
|
if ($cmid) {
|
|
|
|
$questionbankurl = new moodle_url('/question/edit.php', array('cmid' => $cmid));
|
|
|
|
} else {
|
|
|
|
$questionbankurl = new moodle_url('/question/edit.php', array('courseid' => $courseid));
|
|
|
|
}
|
|
|
|
navigation_node::override_active_url($questionbankurl);
|
2009-10-16 03:22:20 +00:00
|
|
|
|
2009-02-25 07:14:03 +00:00
|
|
|
$chooseqtype = get_string('chooseqtypetoadd', 'question');
|
2010-06-02 06:13:27 +00:00
|
|
|
$PAGE->set_heading($COURSE->fullname);
|
2014-10-02 21:45:15 +01:00
|
|
|
$PAGE->navbar->add($chooseqtype);
|
|
|
|
$PAGE->set_title($chooseqtype);
|
2009-02-25 07:14:03 +00:00
|
|
|
|
|
|
|
// Display a form to choose the question type.
|
2014-10-02 21:45:15 +01:00
|
|
|
echo $OUTPUT->header();
|
2010-05-06 22:33:21 +00:00
|
|
|
echo $OUTPUT->notification(get_string('youmustselectaqtype', 'question'));
|
2009-08-10 05:01:23 +00:00
|
|
|
echo $OUTPUT->box_start('generalbox boxwidthnormal boxaligncenter', 'chooseqtypebox');
|
MDL-43089 quiz: improved interface for building quizzes
This commit is actually the joint work of Mahmoud Kassaei, Colin
Chambers and Tim Hunt from The Open University. We could only use one
persons name for the commit, and this time Colin gets the credit/blame.
The goal of this work was to increase usability, and also clean up
the page enough that it will be possible to add new features in future.
Display of mod/quiz/edit.php is now entirely generated by
mod_quiz\output\edit_renderer. This uses a helper class
mod_quiz\structure to provide details of the structure of the quiz, and
mod_quiz\repaginate to alter that structure. (Acutally, there are still
some modification methods on mod_quiz\structure. Expect that to be
cleaned up in future.)
The new code uses much more ajax, and there are new scripts
mod/quiz/edit_rest.php and mod/quiz/repaginate.php to handle this.
(Again, don't be surprised if those two scripts get merged in future.)
Also questionbank.ajax.php (which may, in future, be made more generic,
and moved into the core question bank code.)
Most of the new JavaScript code has intentionally copied the way things
are done when editing activities on the course page.
As a result of this, mod/quiz/editlib.php is now much shorter than it
was. (In future, expect the remaining code in here to move into
mod/quiz/classes.)
2013-12-05 16:18:24 +00:00
|
|
|
echo print_choose_qtype_to_add_form($hiddenparams, null, false);
|
2009-08-10 05:01:23 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2009-08-06 14:19:16 +00:00
|
|
|
echo $OUTPUT->footer();
|