Skip to content

Commit 839b65e

Browse files
committed
Autopopulate comments fix duplicate comments on edit
1 parent 520880b commit 839b65e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

classes/traits/autoagreement_functions.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@ trait autoagreement_functions {
3333
*/
3434
public function feedback_comments() {
3535
global $DB;
36-
37-
$feedbacks = $DB->get_records('coursework_feedbacks', [
36+
$sql = "SELECT * FROM {coursework_feedbacks}
37+
WHERE submissionid = :submissionid AND isfinalgrade = :isfinalgrade
38+
AND stageidentifier NOT LIKE :stageidentifier";
39+
$feedbacks = $DB->get_records_sql($sql, [
3840
'submissionid' => $this->get_allocatable()->get_submission($this->get_coursework())->id(),
3941
'isfinalgrade' => 0,
42+
'stageidentifier' => 'final_agreed_1'
4043
]);
4144
$feedbackcomment = '';
4245
$count = 1;
4346

4447
foreach ($feedbacks as $feedback) {
48+
if (empty($feedback->feedbackcomment)) {
49+
continue;
50+
}
4551
// Put all initial feedbacks together for the comment field.
4652
$feedbackcomment .= get_string('markercomments', 'mod_coursework', $count);
4753
$feedbackcomment .= $feedback->feedbackcomment;

0 commit comments

Comments
 (0)