Merge branch 'MDL-73354-master' of git://github.com/abgreeve/moodle
[moodle.git] / question / edit.php
blobb70fbf6f450c47202775df8ae3c886a80d023237
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.
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/>.
17 /**
18 * Page to edit the question bank
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
27 require_once(__DIR__ . '/../config.php');
28 require_once($CFG->dirroot . '/question/editlib.php');
30 list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
31 question_edit_setup('questions', '/question/edit.php');
33 $url = new moodle_url($thispageurl);
34 if (($lastchanged = optional_param('lastchanged', 0, PARAM_INT)) !== 0) {
35 $url->param('lastchanged', $lastchanged);
37 $PAGE->set_url($url);
39 if ($PAGE->course->id == $SITE->id) {
40 $PAGE->set_primary_active_tab('home');
43 $questionbank = new core_question\local\bank\view($contexts, $thispageurl, $COURSE, $cm);
45 $context = $contexts->lowest();
46 $streditingquestions = get_string('editquestions', 'question');
47 $PAGE->set_title($streditingquestions);
48 $PAGE->set_heading($COURSE->fullname);
49 $PAGE->activityheader->disable();
51 // Print horizontal nav if needed.
52 $renderer = $PAGE->get_renderer('core_question', 'bank');
54 echo $OUTPUT->header();
55 // Render the selection action.
56 $qbankaction = new \core_question\output\qbank_actionbar($url);
57 echo $renderer->qbank_action_menu($qbankaction);
59 // Print the question area.
60 $questionbank->display($pagevars, 'questions');
62 // Log the view of this category.
63 list($categoryid, $contextid) = explode(',', $pagevars['cat']);
64 $category = new stdClass();
65 $category->id = $categoryid;
66 $catcontext = \context::instance_by_id($contextid);
67 $event = \core\event\question_category_viewed::create_from_question_category_instance($category, $catcontext);
68 $event->trigger();
70 echo $OUTPUT->footer();