From 432550ae9aa37225b675ca39d31f187fb29cf4ff Mon Sep 17 00:00:00 2001
From: Tim Schroeder <t.schroeder@itc.rwth-aachen.de>
Date: Tue, 6 Sep 2022 13:29:02 +0200
Subject: [PATCH] fixed warning when commenting on a nonexistent annotation
---
action.php | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/action.php b/action.php
index 1b41e5f..2401d51 100644
--- a/action.php
+++ b/action.php
@@ -350,21 +350,16 @@ if ($action === 'addComment') {
} else {
// Insert the comment into the mdl_pdfannotator_comments table and get its record id.
$comment = pdfannotator_comment::create($documentid, $annotationid, $extracted_content, $visibility, $isquestion, $cm, $context);
- $commentid = $comment->uuid;
-
+
// If successful, create a comment array and return it as json.
if ($comment) {
$myrenderer = $PAGE->get_renderer('mod_pdfannotator');
$templatable = new comment($comment, $cm, $context);
$data = $templatable->export_for_template($myrenderer);
-
+
echo json_encode($data);
} else {
- if ($commentid == -1) {
- echo json_encode(['status' => '-1']);
- } else {
- echo json_encode(['status' => 'error']);
- }
+ echo json_encode(['status' => '-1']);
}
}
--
GitLab