| Línea 33... |
Línea 33... |
| 33 |
|
33 |
|
| 34 |
use \core\notification;
|
34 |
use \core\notification;
|
| 35 |
use qbank_previewquestion\form\preview_options_form;
|
35 |
use qbank_previewquestion\form\preview_options_form;
|
| 36 |
use qbank_previewquestion\question_preview_options;
|
36 |
use qbank_previewquestion\question_preview_options;
|
| - |
|
37 |
use qbank_previewquestion\helper;
|
| Línea 37... |
Línea 38... |
| 37 |
use qbank_previewquestion\helper;
|
38 |
use core_question\local\bank\version_options;
|
| 38 |
|
39 |
|
| 39 |
/**
|
40 |
/**
|
| 40 |
* The maximum number of variants previewable. If there are more variants than this for a question
|
41 |
* The maximum number of variants previewable. If there are more variants than this for a question
|
| Línea 61... |
Línea 62... |
| 61 |
// This affects things like filter settings, or forced theme or language.
|
62 |
// This affects things like filter settings, or forced theme or language.
|
| 62 |
if ($cmid = optional_param('cmid', 0, PARAM_INT)) {
|
63 |
if ($cmid = optional_param('cmid', 0, PARAM_INT)) {
|
| 63 |
$cm = get_coursemodule_from_id(false, $cmid);
|
64 |
$cm = get_coursemodule_from_id(false, $cmid);
|
| 64 |
require_login($cm->course, false, $cm);
|
65 |
require_login($cm->course, false, $cm);
|
| 65 |
$context = context_module::instance($cmid);
|
66 |
$context = context_module::instance($cmid);
|
| 66 |
|
- |
|
| 67 |
} else if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
|
- |
|
| 68 |
require_login($courseid);
|
- |
|
| 69 |
$context = context_course::instance($courseid);
|
- |
|
| 70 |
|
- |
|
| 71 |
} else {
|
67 |
} else {
|
| 72 |
require_login();
|
68 |
require_login();
|
| 73 |
$category = $DB->get_record('question_categories', ['id' => $question->category], '*', MUST_EXIST);
|
69 |
$category = $DB->get_record('question_categories', ['id' => $question->category], '*', MUST_EXIST);
|
| 74 |
$context = context::instance_by_id($category->contextid);
|
70 |
$context = context::instance_by_id($category->contextid);
|
| 75 |
$PAGE->set_context($context);
|
71 |
$PAGE->set_context($context);
|
| Línea 133... |
Línea 129... |
| 133 |
$transaction->allow_commit();
|
129 |
$transaction->allow_commit();
|
| 134 |
}
|
130 |
}
|
| 135 |
$options->behaviour = $quba->get_preferred_behaviour();
|
131 |
$options->behaviour = $quba->get_preferred_behaviour();
|
| 136 |
$options->maxmark = $quba->get_question_max_mark($slot);
|
132 |
$options->maxmark = $quba->get_question_max_mark($slot);
|
| Línea -... |
Línea 133... |
| - |
|
133 |
|
| - |
|
134 |
// Load the question versions and convert to a simple array for select menu.
|
| 137 |
|
135 |
$versions = version_options::get_version_menu_options($question->id);
|
| 138 |
$versionids = helper::load_versions($question->questionbankentryid);
|
136 |
$versionids = helper::load_versions($question->questionbankentryid);
|
| 139 |
// Create the settings form, and initialise the fields.
|
137 |
// Create the settings form, and initialise the fields.
|
| 140 |
$optionsform = new preview_options_form(helper::question_preview_form_url($question->id, $context, $previewid, $returnurl),
|
138 |
$optionsform = new preview_options_form(helper::question_preview_form_url($question->id, $context, $previewid, $returnurl),
|
| 141 |
[
|
139 |
[
|
| 142 |
'quba' => $quba,
|
140 |
'quba' => $quba,
|
| 143 |
'maxvariant' => $maxvariant,
|
141 |
'maxvariant' => $maxvariant,
|
| 144 |
'versions' => array_combine(array_values($versionids), array_values($versionids)),
|
142 |
'versions' => $versions,
|
| 145 |
'restartversion' => $restartversion,
|
143 |
'restartversion' => $restartversion,
|
| 146 |
]);
|
144 |
]);
|
| Línea 147... |
Línea 145... |
| 147 |
$optionsform->set_data($options);
|
145 |
$optionsform->set_data($options);
|
| Línea 319... |
Línea 317... |
| 319 |
$previewdata['redirect'] = false;
|
317 |
$previewdata['redirect'] = false;
|
| 320 |
if (!is_null($returnurl)) {
|
318 |
if (!is_null($returnurl)) {
|
| 321 |
$previewdata['redirect'] = true;
|
319 |
$previewdata['redirect'] = true;
|
| 322 |
$previewdata['redirecturl'] = $returnurl;
|
320 |
$previewdata['redirecturl'] = $returnurl;
|
| 323 |
}
|
321 |
}
|
| 324 |
$closeurl = new moodle_url('/question/edit.php', ['courseid' => $COURSE->id]);
|
322 |
$closeurl = new moodle_url('/question/edit.php', ['cmid' => $context->instanceid]);
|
| 325 |
echo $PAGE->get_renderer('qbank_previewquestion')->render_preview_page($previewdata);
|
323 |
echo $PAGE->get_renderer('qbank_previewquestion')->render_preview_page($previewdata);
|
| Línea 326... |
Línea 324... |
| 326 |
|
324 |
|
| 327 |
// Log the preview of this question.
|
325 |
// Log the preview of this question.
|
| 328 |
$event = \core\event\question_viewed::create_from_question_instance($question, $context);
|
326 |
$event = \core\event\question_viewed::create_from_question_instance($question, $context);
|