Autopopulate comments fix duplicate comments on edit#193
Autopopulate comments fix duplicate comments on edit#193sumaiyamannan wants to merge 1 commit intoucl-isd:mainfrom
Conversation
7ad8d68 to
839b65e
Compare
839b65e to
b785d5a
Compare
|
Once the tests are rerun, it should fix the checks |
There was a problem hiding this comment.
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_recordstoget_records_sqlwith 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"; |
There was a problem hiding this comment.
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%').
| AND stageidentifier NOT LIKE :stageidentifier"; | |
| AND stageidentifier <> :stageidentifier"; |
Auto populate comments are duplicating when a previously saved feedback is edited