This commit is contained in:
Andrew Nicols 2022-10-06 09:02:07 +08:00
commit 29e1f713b6
2 changed files with 5 additions and 3 deletions

View File

@ -46,10 +46,13 @@ class backup_qbank_comment_plugin extends \backup_qbank_plugin {
$pluginwrapper->add_child($comments);
$comments->add_child($comment);
// Trying to pass an param (contextid) with an int value seems to have special meaning, so just inline.
// It is an int, so minimal security risk.
$comment->set_source_sql("SELECT c.*
FROM {comments} c
WHERE c.commentarea = 'question'
WHERE c.contextid = " . context_system::instance()->id . "
AND c.component = 'qbank_comment'
AND c.commentarea = 'question'
AND c.itemid = ?", [backup::VAR_PARENTID]);
$comment->annotate_ids('user', 'userid');

View File

@ -152,9 +152,8 @@ class backup_test extends \advanced_testcase {
$question2 = $this->qgen->create_question('shortanswer', null, $this->question2data);
// Add comments to the questions.
$coursecontext = \context_course::instance($this->course->id);
$args = new \stdClass;
$args->context = $coursecontext;
$args->context = \context_system::instance();
$args->course = $this->course;
$args->area = 'question';
$args->itemid = $question1->id;