diff --git a/question/classes/bank/view.php b/question/classes/bank/view.php index e8df555b457..518e36c0687 100644 --- a/question/classes/bank/view.php +++ b/question/classes/bank/view.php @@ -929,7 +929,7 @@ class view { if (preg_match('!^q([0-9]+)$!', $key, $matches)) { $key = $matches[1]; $questionlist .= $key.','; - question_require_capability_on($key, 'edit'); + question_require_capability_on((int)$key, 'edit'); if (questions_in_use(array($key))) { $questionnames .= '* '; $inuse = true; diff --git a/question/engine/tests/helpers.php b/question/engine/tests/helpers.php index 8a89633b879..0614f606779 100644 --- a/question/engine/tests/helpers.php +++ b/question/engine/tests/helpers.php @@ -119,6 +119,7 @@ abstract class question_test_helper { $catcontext = context::instance_by_id($cat->contextid, MUST_EXIST); $contexts = new question_edit_contexts($catcontext); $dataforformconstructor = new stdClass(); + $dataforformconstructor->createdby = $questiondata->createdby; $dataforformconstructor->qtype = $questiondata->qtype; $dataforformconstructor->contextid = $questiondata->contextid = $catcontext->id; $dataforformconstructor->category = $questiondata->category = $cat->id; diff --git a/question/question.php b/question/question.php index acbabcec399..2a02d92b126 100644 --- a/question/question.php +++ b/question/question.php @@ -162,6 +162,7 @@ if (isset($question->categoryobject)) { $question->formoptions = new stdClass(); $categorycontext = context::instance_by_id($category->contextid); +$question->contextid = $category->contextid; $addpermission = has_capability('moodle/question:add', $categorycontext); if ($id) { diff --git a/question/type/calculatedsimple/tests/helper.php b/question/type/calculatedsimple/tests/helper.php index 53cb8e4282d..5218994a2ae 100644 --- a/question/type/calculatedsimple/tests/helper.php +++ b/question/type/calculatedsimple/tests/helper.php @@ -209,9 +209,11 @@ class qtype_calculatedsimple_test_helper extends question_test_helper { } public function get_calculatedsimple_question_data_sumwithvariants() { + global $USER; $q = new stdClass(); $q->name = 'Calculated simple'; + $q->createdby = $USER->id; $q->questiontext = '
This is a simple sum of two variables.
'; $q->questiontextformat = '1'; $q->generalfeedback = 'The answer isĀ {a} + {b}
'; diff --git a/question/type/gapselect/tests/edit_form_test.php b/question/type/gapselect/tests/edit_form_test.php index 97ee86d62ac..7c6dc3850c9 100644 --- a/question/type/gapselect/tests/edit_form_test.php +++ b/question/type/gapselect/tests/edit_form_test.php @@ -43,6 +43,8 @@ class qtype_gapselect_edit_form_base_testable extends qtype_gapselect_edit_form_ $category = question_make_default_categories(array($syscontext)); $fakequestion = new stdClass(); $fakequestion->qtype = 'stack'; + $fakequestion->contextid = $syscontext->id; + $fakequestion->createdby = 2; $fakequestion->category = $category->id; $fakequestion->questiontext = 'Test [[1]] question [[2]]'; $fakequestion->options = new stdClass();