Skip to content

Autopopulate comments fix duplicate comments on edit#193

Open
sumaiyamannan wants to merge 1 commit intoucl-isd:mainfrom
sumaiyamannan:bugduplicatecomments
Open

Autopopulate comments fix duplicate comments on edit#193
sumaiyamannan wants to merge 1 commit intoucl-isd:mainfrom
sumaiyamannan:bugduplicatecomments

Conversation

@sumaiyamannan
Copy link
Contributor

Auto populate comments are duplicating when a previously saved feedback is edited

@sumaiyamannan
Copy link
Contributor Author

Once the tests are rerun, it should fix the checks

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where auto-populated comments were being duplicated when previously saved feedback is edited. The fix modifies the SQL query to exclude final agreed grades and adds a check to skip empty feedback comments.

  • Refactored the database query from get_records to get_records_sql with explicit filtering
  • Added exclusion for final agreed grades using stageidentifier NOT LIKE 'final_agreed_1'
  • Added validation to skip empty feedback comments in the loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants