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
 * Page to edit the question bank
19
 *
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
24
 */
25
 
26
use core\event\question_category_viewed;
27
use core_question\output\qbank_action_menu;
28
use core_question\local\bank\view;
29
 
30
require_once(__DIR__ . '/../config.php');
31
require_once($CFG->dirroot . '/question/editlib.php');
32
 
1441 ariadna 33
// Since Moodle 5.0 any request with the courseid parameter is deprecated and will redirect to the banks management page.
34
if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
35
    redirect(new moodle_url('/question/banks.php', ['courseid' => $courseid]));
36
}
37
 
1 efrain 38
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
39
        question_edit_setup('questions', '/question/edit.php');
40
 
41
$actionurl = new moodle_url($thispageurl);
42
if (($lastchanged = optional_param('lastchanged', 0, PARAM_INT)) !== 0) {
43
    $thispageurl->param('lastchanged', $lastchanged);
44
}
45
$PAGE->set_url($thispageurl);
46
 
47
if ($PAGE->course->id == $SITE->id) {
48
    $PAGE->set_primary_active_tab('home');
49
}
50
 
1441 ariadna 51
// Mods that publish questions need a modified navbar breadcrumb here as they are managed differently to other module types.
52
if (plugin_supports('mod', $cm->modname, FEATURE_PUBLISHES_QUESTIONS, false)) {
53
    $PAGE->navbar->ignore_active();
54
    $coursenode = $PAGE->navigation->find($PAGE->course->id, navigation_node::TYPE_COURSE);
55
    $modnode = $PAGE->navigation->find($cm->id, navigation_node::TYPE_ACTIVITY);
56
    $PAGE->navbar->add($coursenode->text, $coursenode->action, $coursenode->type, $coursenode->shorttext, icon: $coursenode->icon);
57
    $PAGE->navbar->add(get_string('questionbank_plural', 'core_question'),
58
        \core_question\local\bank\question_bank_helper::get_url_for_qbank_list($PAGE->course->id)
59
    );
60
    $PAGE->navbar->add($modnode->text, $modnode->action, $modnode->type, $modnode->shorttext, icon: $modnode->icon);
61
}
62
 
1 efrain 63
$questionbank = new view($contexts, $thispageurl, $COURSE, $cm, $pagevars);
64
 
65
$context = $contexts->lowest();
66
$streditingquestions = get_string('editquestions', 'question');
67
$PAGE->set_title($streditingquestions);
68
$PAGE->set_heading($COURSE->fullname);
69
$PAGE->activityheader->disable();
70
 
71
echo $OUTPUT->header();
1441 ariadna 72
if (!\core_question\local\bank\question_bank_helper::has_bank_migration_task_completed_successfully()) {
73
    $defaultactivityname = \core_question\local\bank\question_bank_helper::get_default_question_bank_activity_name();
74
    echo $OUTPUT->notification(
75
        get_string('transfernotfinished', 'mod_' . $defaultactivityname),
76
        \core\output\notification::NOTIFY_WARNING,
77
        false,
78
    );
79
    echo $OUTPUT->footer();
80
    exit();
81
}
1 efrain 82
 
83
// Print horizontal nav if needed.
84
$renderer = $PAGE->get_renderer('core_question', 'bank');
85
 
86
// Render the selection action.
87
$qbankaction = new qbank_action_menu($actionurl);
88
echo $renderer->render($qbankaction);
89
 
90
// Print the question area.
91
$questionbank->display();
92
 
1441 ariadna 93
[$categoryid, $contextid] = explode(',', $pagevars['cat']);
94
$questionbank->init_bulk_actions_js();
95
 
1 efrain 96
// Log the view of this category.
97
$category = new stdClass();
98
$category->id = $categoryid;
99
$catcontext = context::instance_by_id($contextid);
100
$event = question_category_viewed::create_from_question_category_instance($category, $catcontext);
101
$event->trigger();
102
 
103
echo $OUTPUT->footer();