Skip to content

Commit

Permalink
MDL-61364 question: adjust code and fix phpunit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Mar 27, 2018
1 parent e7329cd commit 2cf7bde
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion question/classes/bank/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ public function process_actions_needing_ui() {
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;
Expand Down
1 change: 1 addition & 0 deletions question/engine/tests/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public static function get_question_editing_form($cat, $questiondata) {
$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;
Expand Down
1 change: 1 addition & 0 deletions question/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
$question->formoptions = new stdClass();

$categorycontext = context::instance_by_id($category->contextid);
$question->contextid = $category->contextid;
$addpermission = has_capability('moodle/question:add', $categorycontext);

if ($id) {
Expand Down
2 changes: 2 additions & 0 deletions question/type/calculatedsimple/tests/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ public function get_calculatedsimple_question_form_data_sumwithvariants() {
}

public function get_calculatedsimple_question_data_sumwithvariants() {
global $USER;
$q = new stdClass();

$q->name = 'Calculated simple';
$q->createdby = $USER->id;
$q->questiontext = '<p>This is a simple sum of two variables.</p>';
$q->questiontextformat = '1';
$q->generalfeedback = '<p>The answer is  {a} + {b}</p>';
Expand Down
2 changes: 2 additions & 0 deletions question/type/gapselect/tests/edit_form_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public function __construct() {
$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();
Expand Down

0 comments on commit 2cf7bde

Please sign in to comment.