Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions classes/traits/autoagreement_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ trait autoagreement_functions {
*/
public function feedback_comments() {
global $DB;

$feedbacks = $DB->get_records('coursework_feedbacks', [
$sql = "SELECT * FROM {coursework_feedbacks}
WHERE submissionid = :submissionid AND isfinalgrade = :isfinalgrade
AND stageidentifier NOT LIKE :stageidentifier";
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using NOT LIKE with a plain string 'final_agreed_1' is problematic. The LIKE operator is intended for pattern matching with wildcards (% or ). If the intent is exact matching, use != :stageidentifier or <> :stageidentifier instead. If pattern matching is intended, clarify what pattern should be excluded (e.g., 'final_agreed%').

Suggested change
AND stageidentifier NOT LIKE :stageidentifier";
AND stageidentifier <> :stageidentifier";

Copilot uses AI. Check for mistakes.
$feedbacks = $DB->get_records_sql($sql, [
'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(),
'isfinalgrade' => 0,
'stageidentifier' => 'final_agreed_1',
]);
$feedbackcomment = '';
$count = 1;

foreach ($feedbacks as $feedback) {
if (empty($feedback->feedbackcomment)) {
continue;
}
// Put all initial feedbacks together for the comment field.
$feedbackcomment .= get_string('markercomments', 'mod_coursework', $count);
$feedbackcomment .= $feedback->feedbackcomment;
Expand Down