Skip to content
Browse files

Merge branch 'MDL-34862_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
2 parents 5d44dbd + 1907f7e commit 4dd7c5cafd214eda4a04cda6ac4c8e7444014a10 @stronk7 stronk7 committed Aug 15, 2012
Showing with 8 additions and 10 deletions.
  1. +2 −2 question/engine/questionusage.php
  2. +6 −8 question/preview.php
View
4 question/engine/questionusage.php
@@ -63,7 +63,7 @@ class question_usage_by_activity {
*/
protected $preferredbehaviour = null;
- /** @var object the context this usage belongs to. */
+ /** @var context the context this usage belongs to. */
protected $context;
/** @var string plugin name of the plugin this usage belongs to. */
@@ -104,7 +104,7 @@ public function get_preferred_behaviour() {
return $this->preferredbehaviour;
}
- /** @return object the context this usage belongs to. */
+ /** @return context the context this usage belongs to. */
public function get_owning_context() {
return $this->context;
}
View
14 question/preview.php
@@ -75,14 +75,10 @@
$PAGE->set_url(question_preview_url($id, $options->behaviour, $options->maxmark,
$options, $options->variant, $context));
-// Get and validate exitsing preview, or start a new one.
+// Get and validate existing preview, or start a new one.
$previewid = optional_param('previewid', 0, PARAM_INT);
if ($previewid) {
- if (!isset($SESSION->question_previews[$previewid])) {
- print_error('notyourpreview', 'question');
- }
-
try {
$quba = question_engine::load_questions_usage_by_activity($previewid);
@@ -94,6 +90,10 @@
$options->maxmark, $options, $options->variant, $context), null, $e);
}
+ if ($quba->get_owning_context()->instanceid != $USER->id) {
+ print_error('notyourpreview', 'question');
+ }
+
$slot = $quba->get_first_question_number();
$usedquestion = $quba->get_question($slot);
if ($usedquestion->id != $question->id) {
@@ -104,7 +104,7 @@
} else {
$quba = question_engine::make_questions_usage_by_activity(
- 'core_question_preview', $context);
+ 'core_question_preview', context_user::instance($USER->id));
$quba->set_preferred_behaviour($options->behaviour);
$slot = $quba->add_question($question, $options->maxmark);
@@ -119,8 +119,6 @@
$transaction = $DB->start_delegated_transaction();
question_engine::save_questions_usage_by_activity($quba);
$transaction->allow_commit();
-
- $SESSION->question_previews[$quba->get_id()] = true;
}
$options->behaviour = $quba->get_preferred_behaviour();
$options->maxmark = $quba->get_question_max_mark($slot);

0 comments on commit 4dd7c5c

Please sign in to comment.
Something went wrong with that request. Please try again.