Select Git revision
tidyquestion.php
-
Chris Sangwin authoredChris Sangwin authored
tidyquestion.php 5.15 KiB
<?php
// This file is part of Stack - http://stack.maths.ed.ac.uk/
//
// Stack 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.
//
// Stack 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 STACK. If not, see <http://www.gnu.org/licenses/>.
/**
* This script lets rename parts of the question, which is not possible using
* the standard editing form.
*
* @copyright 2013 the Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__.'/../../../config.php');
require_once($CFG->libdir . '/questionlib.php');
require_once(__DIR__ . '/locallib.php');
require_once(__DIR__ . '/tidyquestionform.php');
require_once(__DIR__ . '/vle_specific.php');
// Get the parameters from the URL.
$questionid = required_param('questionid', PARAM_INT);
// Load the necessary data.
$questiondata = $DB->get_record('question', array('id' => $questionid), '*', MUST_EXIST);
$question = question_bank::load_question($questionid);
// Process any other URL parameters, and do require_login.
list($context, $notused, $urlparams) = qtype_stack_setup_question_test_page($question);
// Check permissions.
question_require_capability_on($questiondata, 'edit');
// Initialise $PAGE.
$PAGE->set_url('/question/type/stack/tidyquestion.php', $urlparams);
$title = stack_string('tidyquestionx', format_string($question->name));
$PAGE->set_title($title);
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_pagelayout('admin');
require_login();
// The URL back to the preview page.
// TODO, when we drop support for Moodle 3, this link needs to go back to the dashboard, not the preview.
if (stack_determine_moodle_version() < 400) {
$returnurl = question_preview_url($questionid, null, null, null, null, $context);
} else {
$returnurl = qbank_previewquestion\helper::question_preview_url($questionid, null, null, null, null, $context);
}
// Create the question usage we will use.
$quba = question_engine::make_questions_usage_by_activity('qtype_stack', $context);
$quba->set_preferred_behaviour('adaptive');
$slot = $quba->add_question($question, $question->defaultmark);
$quba->start_question($slot);
// Now we are going to display the question with each input box containing the
// name of that input, and each feedback area displaying something like
// "Feedback from PRT {name}". To do this, first we submit the right answer to
// get the question into a state where all feedback will be displayed.
$response = $question->get_correct_response();