Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
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
 
17
/**
18
 * Shows a screen where the user can choose a question type, before being redirected to question.php
19
 *
20
 * @package    qbank_editquestion
21
 * @copyright  2009 Tim Hunt
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require_once(__DIR__ . '/../../../config.php');
26
require_once(__DIR__ . '/../../editlib.php');
27
 
28
use qbank_editquestion\editquestion_helper;
29
 
30
// Read URL parameters.
31
$categoryid = required_param('category', PARAM_INT);
1441 ariadna 32
$cmid = required_param('cmid', PARAM_INT);
1 efrain 33
$returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);
34
$appendqnumstring = optional_param('appendqnumstring', '', PARAM_ALPHA);
35
$validationerror = optional_param('validationerror', false, PARAM_BOOL);
36
 
37
\core_question\local\bank\helper::require_plugin_enabled('qbank_editquestion');
38
 
39
// Place to accumulate hidden params for the form we will print.
40
$hiddenparams = array('category' => $categoryid);
41
 
42
// Validate params.
43
if (!$category = $DB->get_record('question_categories', array('id' => $categoryid))) {
44
    throw new moodle_exception('categorydoesnotexist', 'question', $returnurl);
45
}
46
 
1441 ariadna 47
list($module, $cm) = get_module_from_cmid($cmid);
48
require_login($cm->course, false, $cm);
49
$thiscontext = context_module::instance($cmid);
50
$hiddenparams['cmid'] = $cmid;
1 efrain 51
 
52
// Check permissions.
53
$categorycontext = context::instance_by_id($category->contextid);
54
require_capability('moodle/question:add', $categorycontext);
55
 
56
// Ensure other optional params get passed on to question.php.
57
if (!empty($returnurl)) {
58
    $hiddenparams['returnurl'] = $returnurl;
59
}
60
if (!empty($appendqnumstring)) {
61
    $hiddenparams['appendqnumstring'] = $appendqnumstring;
62
}
63
 
64
$PAGE->set_url('/question/bank/editquestion/addquestion.php', $hiddenparams);
1441 ariadna 65
 
66
$questionbankurl = new moodle_url('/question/edit.php', ['cmid' => $cmid]);
67
 
1 efrain 68
navigation_node::override_active_url($questionbankurl);
69
 
70
$chooseqtype = get_string('chooseqtypetoadd', 'question');
71
$PAGE->set_heading($COURSE->fullname);
72
$PAGE->navbar->add($chooseqtype);
73
$PAGE->set_title($chooseqtype);
74
 
75
// Display a form to choose the question type.
76
echo $OUTPUT->header();
77
echo $OUTPUT->notification(get_string('youmustselectaqtype', 'question'));
78
echo $OUTPUT->box_start('generalbox boxwidthnormal boxaligncenter', 'chooseqtypebox');
79
echo editquestion_helper::print_choose_qtype_to_add_form($hiddenparams, null, false);
80
echo $OUTPUT->box_end();
81
echo $OUTPUT->footer();