See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 403]
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 * Move questions page. 19 * 20 * @package qbank_bulkmove 21 * @copyright 2021 Catalyst IT Australia Pty Ltd 22 * @author Safat Shahin <safatshahin@catalyst-au.net> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require_once(__DIR__ . '/../../../config.php'); 27 require_once (__DIR__ . '/../../editlib.php'); 28 29 global $DB, $OUTPUT, $PAGE, $COURSE; 30 31 $moveselected = optional_param('move', false, PARAM_BOOL); 32 $returnurl = optional_param('returnurl', 0, PARAM_LOCALURL); 33 $cmid = optional_param('cmid', 0, PARAM_INT); 34 $courseid = optional_param('courseid', 0, PARAM_INT); 35 $category = optional_param('category', null, PARAM_SEQUENCE); 36 $confirm = optional_param('confirm', '', PARAM_ALPHANUM); 37 $movequestionselected = optional_param('movequestionsselected', null, PARAM_RAW); 38 39 if ($returnurl) { 40 $returnurl = new moodle_url($returnurl); 41 } 42 43 \core_question\local\bank\helper::require_plugin_enabled('qbank_bulkmove'); 44 45 if ($cmid) { 46 list($module, $cm) = get_module_from_cmid($cmid); 47 require_login($cm->course, false, $cm); 48 $thiscontext = context_module::instance($cmid); 49 } else if ($courseid) { 50 require_login($courseid, false); 51 $thiscontext = context_course::instance($courseid); 52 } else { 53 throw new moodle_exception('missingcourseorcmid', 'question'); 54 } 55 56 $contexts = new core_question\local\bank\question_edit_contexts($thiscontext); 57 $url = new moodle_url('/question/bank/bulkmove/move.php'); 58 59 $PAGE->set_url($url); 60 $streditingquestions = get_string('movequestions', 'qbank_bulkmove'); 61 $PAGE->set_title($streditingquestions); 62 $PAGE->set_heading($COURSE->fullname); 63 $PAGE->activityheader->disable(); 64 $PAGE->set_secondary_active_tab("questionbank"); 65 66 if ($category) { 67 list($tocategoryid, $contextid) = explode(',', $category); 68 if (! $tocategory = $DB->get_record('question_categories', 69 ['id' => $tocategoryid, 'contextid' => $contextid])) { 70 throw new \moodle_exception('cannotfindcate', 'question'); 71 } 72 } 73 74 if ($movequestionselected && $confirm && confirm_sesskey()) { 75 if ($confirm == md5($movequestionselected)) { 76 \qbank_bulkmove\helper::bulk_move_questions($movequestionselected, $tocategory); 77 } 78 redirect(new moodle_url($returnurl, ['category' => "{$tocategoryid},{$contextid}"])); 79 } 80 81 echo $OUTPUT->header(); 82 83 if ($moveselected) { 84 $rawquestions = $_REQUEST; 85 list($questionids, $questionlist) = \qbank_bulkmove\helper::process_question_ids($rawquestions); 86 // No questions were selected. 87 if (!$questionids) { 88 redirect($returnurl); 89 } 90 // Create the urls. 91 $moveparam = [ 92 'movequestionsselected' => $questionlist, 93 'confirm' => md5($questionlist), 94 'sesskey' => sesskey(), 95 'returnurl' => $returnurl, 96 'cmid' => $cmid, 97 'courseid' => $courseid, 98 ]; 99 $moveurl = new \moodle_url($url, $moveparam); 100 101 $addcontexts = $contexts->having_cap('moodle/question:add'); 102 $displaydata = \qbank_bulkmove\helper::get_displaydata($addcontexts, $moveurl, $returnurl); 103 echo $PAGE->get_renderer('qbank_bulkmove')->render_bulk_move_form($displaydata); 104 } 105 106 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body