From cbdf58d98dc985860401e2244884aae47d44ec2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= <luca.boesch@bfh.ch> Date: Thu, 28 Oct 2021 00:24:47 +0200 Subject: [PATCH] Removed codechecker errors, some warnings remaining. # Conflicts: # backup/moodle2/restore_pdfannotator_stepslib.php # forward_form.php # version.php --- action.php | 14 ++-- .../moodle2/restore_pdfannotator_stepslib.php | 28 ++++--- classes/output/comment.php | 40 ++++++---- controller.php | 68 +++++++++++------ db/upgrade.php | 12 ++- forward_form.php | 5 +- lang/en/pdfannotator.php | 2 +- lib.php | 6 +- locallib.php | 12 ++- mod_form.php | 3 +- model/comment.class.php | 19 +++-- model/overviewtable.php | 75 +++++++++++++------ model/statistics.class.php | 58 +++++++++----- renderable.php | 2 +- renderer.php | 3 +- settings.php | 10 ++- version.php | 7 +- 17 files changed, 238 insertions(+), 126 deletions(-) diff --git a/action.php b/action.php index 39ac2a7..f1ea8d0 100644 --- a/action.php +++ b/action.php @@ -151,7 +151,8 @@ if ($action === 'create') { $data['height'] = $annotation['height']; break; case 'drawing': - $studentdrawingsallowed = $DB->get_field('pdfannotator', 'use_studentdrawing', ['id' => $documentid], $strictness = MUST_EXIST); + $studentdrawingsallowed = $DB->get_field('pdfannotator', 'use_studentdrawing', ['id' => $documentid], + $strictness = MUST_EXIST); $alwaysdrawingallowed = has_capability('mod/pdfannotator:usedrawing', $context); if ($studentdrawingsallowed != 1 && !$alwaysdrawingallowed) { echo json_encode(['status' => 'error', 'reason' => get_string('studentdrawingforbidden', 'pdfannotator')]); @@ -174,7 +175,8 @@ if ($action === 'create') { $data['rectangles'] = $annotation['rectangles']; break; case 'textbox': - $studenttextboxesallowed = $DB->get_field('pdfannotator', 'use_studenttextbox', array('id' => $documentid), $strictness = MUST_EXIST); + $studenttextboxesallowed = $DB->get_field('pdfannotator', 'use_studenttextbox', array('id' => $documentid), + $strictness = MUST_EXIST); $alwaystextboxallowed = has_capability('mod/pdfannotator:usetextbox', $context); if ($studenttextboxesallowed != 1 && !$alwaystextboxallowed) { echo json_encode(['status' => 'error', 'reason' => get_string('studenttextboxforbidden', 'pdfannotator')]); @@ -497,7 +499,8 @@ if ($action === 'subscribeQuestion') { $thiscourse = $pdfannotator->course; $cmid = get_coursemodule_from_instance('pdfannotator', $thisannotator, $thiscourse, false, MUST_EXIST)->id; - $urlparams = array('action' => 'overviewanswers', 'id' => $cmid, 'page' => 0, 'itemsperpage' => $itemsperpage, 'answerfilter' => 0); + $urlparams = array('action' => 'overviewanswers', 'id' => $cmid, 'page' => 0, 'itemsperpage' => $itemsperpage, + 'answerfilter' => 0); $url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams); redirect($url->out()); return; @@ -537,13 +540,14 @@ if ($action === 'unsubscribeQuestion') { } if ($subscriptionid) { - echo json_encode(['status' => 'success', 'annotationid' => $annotationid, 'subscriptionid' => $subscriptionid, 'annotatorid' => $annotatorid]); + echo json_encode(['status' => 'success', 'annotationid' => $annotationid, 'subscriptionid' => $subscriptionid, + 'annotatorid' => $annotatorid]); } else { echo json_encode(['status' => 'error']); } } -/* * ****************************************** Mark a question as closed or an answer as correct ****************************************** */ +/* * ****************************************** Mark a question as closed or an answer as correct ******************************* */ if ($action === 'markSolved') { global $DB; diff --git a/backup/moodle2/restore_pdfannotator_stepslib.php b/backup/moodle2/restore_pdfannotator_stepslib.php index e738ca9..607bef6 100644 --- a/backup/moodle2/restore_pdfannotator_stepslib.php +++ b/backup/moodle2/restore_pdfannotator_stepslib.php @@ -43,19 +43,24 @@ class restore_pdfannotator_activity_structure_step extends restore_activity_stru $paths = array(); - $userinfo = $this->get_setting_value('userinfo'); + $userinfo = $this->get_setting_value('userinfo'); // Is 0 //TODO is not used. - $paths[] = new restore_path_element('pdfannotator', '/activity/pdfannotator'); + $paths[] = new restore_path_element('pdfannotator', + '/activity/pdfannotator'); - if($userinfo) { - $paths[] = new restore_path_element('pdfannotator_annotation', '/activity/pdfannotator/annotations/annotation'); + $paths[] = new restore_path_element('pdfannotator_annotation', + '/activity/pdfannotator/annotations/annotation'); - $paths[] = new restore_path_element('pdfannotator_subscription', '/activity/pdfannotator/annotations/annotation/subscriptions/subscription'); - $paths[] = new restore_path_element('pdfannotator_comment', '/activity/pdfannotator/annotations/annotation/comments/comment'); + $paths[] = new restore_path_element('pdfannotator_subscription', + '/activity/pdfannotator/annotations/annotation/subscriptions/subscription'); + $paths[] = new restore_path_element('pdfannotator_comment', + '/activity/pdfannotator/annotations/annotation/comments/comment'); + + $paths[] = new restore_path_element('pdfannotator_vote', + '/activity/pdfannotator/annotations/annotation/comments/comment/votes/vote'); + $paths[] = new restore_path_element('pdfannotator_report', + '/activity/pdfannotator/annotations/annotation/comments/comment/reports/report'); - $paths[] = new restore_path_element('pdfannotator_vote', '/activity/pdfannotator/annotations/annotation/comments/comment/votes/vote'); - $paths[] = new restore_path_element('pdfannotator_report', '/activity/pdfannotator/annotations/annotation/comments/comment/reports/report'); - } // Return the paths wrapped into standard activity structure. return $this->prepare_activity_structure($paths); } @@ -144,8 +149,9 @@ class restore_pdfannotator_activity_structure_step extends restore_activity_stru $data->commentid = $this->get_new_parentid('pdfannotator_comment'); $data->userid = $this->get_mappingid('user', $data->userid); - // $data->timecreated = $this->apply_date_offset($data->timecreated); - $data->pdfannotatorid = $this->get_mappingid('pdfannotator', $data->pdfannotatorid); // Params: 1. Object class as defined in structure, 2. attribute&/column name. + // $data->timecreated = $this->apply_date_offset($data->timecreated); + $data->pdfannotatorid = $this->get_mappingid('pdfannotator', $data->pdfannotatorid); + // Params: 1. Object class as defined in structure, 2. attribute&/column name. $newitemid = $DB->insert_record('pdfannotator_reports', $data); $this->set_mapping('pdfannotator_report', $oldid, $newitemid); diff --git a/classes/output/comment.php b/classes/output/comment.php index b5ba9df..65286e0 100644 --- a/classes/output/comment.php +++ b/classes/output/comment.php @@ -94,7 +94,8 @@ class comment implements \renderable, \templatable { } if (!empty($comment->modifiedby) && ($comment->modifiedby != $comment->userid) && ($comment->userid != 0)) { - $comment->modifiedby = get_string('modifiedby', 'pdfannotator') . ' '. pdfannotator_get_username($comment->modifiedby); + $comment->modifiedby = get_string('modifiedby', 'pdfannotator') . ' '. + pdfannotator_get_username($comment->modifiedby); } else { $comment->modifiedby = null; } @@ -167,9 +168,11 @@ class comment implements \renderable, \templatable { public function addsolvedicon($comment) { if ($comment->solved) { if ($comment->isquestion) { - $comment->solvedicon = ["classes" => "icon fa fa-lock fa-fw solvedquestionicon", "title" => get_string('questionSolved', 'pdfannotator')]; + $comment->solvedicon = ["classes" => "icon fa fa-lock fa-fw solvedquestionicon", + "title" => get_string('questionSolved', 'pdfannotator')]; } else if (!$comment->isdeleted) { - $comment->solvedicon = ["classes" => "icon fa fa-check fa-fw correctanswericon", "title" => get_string('answerSolved', 'pdfannotator')]; + $comment->solvedicon = ["classes" => "icon fa fa-check fa-fw correctanswericon", + "title" => get_string('answerSolved', 'pdfannotator')]; } } } @@ -218,8 +221,9 @@ class comment implements \renderable, \templatable { */ private function addeditbutton($comment, $editanypost) { if (!$comment->isdeleted && !isset($comment->type) && ($comment->owner || $editanypost)) { - $comment->buttons[] = ["classes" => "comment-edit-a", "attributes" => ["name" => "id", "value" => "editButton" . $comment->uuid], - "moodleicon" => ["key" => "i/edit", "component" => "core", "title" => get_string('edit', 'pdfannotator')], + $comment->buttons[] = ["classes" => "comment-edit-a", "attributes" => ["name" => "id", + "value" => "editButton" . $comment->uuid], "moodleicon" => ["key" => "i/edit", "component" => "core", + "title" => get_string('edit', 'pdfannotator')], "text" => get_string('edit', 'pdfannotator')]; } } @@ -235,7 +239,8 @@ class comment implements \renderable, \templatable { $comment->dimmed = 'dimmed_text'; $comment->displayhidden = 1; $comment->buttons[] = ["attributes" => ["name" => "id", "value" => "hideButton" . $comment->uuid], - "moodleicon" => ["key" => "i/hide", "component" => "core", "title" => get_string('removehidden', 'pdfannotator')], + "moodleicon" => ["key" => "i/hide", "component" => "core", + "title" => get_string('removehidden', 'pdfannotator')], "text" => get_string('removehidden', 'pdfannotator')]; } else { $comment->visibility = 'anonymous'; @@ -260,12 +265,14 @@ class comment implements \renderable, \templatable { private function adddeletebutton($comment, $deleteown, $deleteany) { if (!$comment->isdeleted && ($deleteany || ($deleteown && $comment->owner))) { $comment->buttons[] = ["classes" => "comment-delete-a", "text" => get_string('delete', 'pdfannotator'), - "moodleicon" => ["key" => "delete", "component" => "pdfannotator", "title" => get_string('delete', 'pdfannotator')]]; + "moodleicon" => ["key" => "delete", "component" => "pdfannotator", + "title" => get_string('delete', 'pdfannotator')]]; } } private function addsubscribebutton($comment, $subscribe) { - if (!isset($comment->type) && $comment->isquestion && $subscribe && $comment->visibility != 'private') { // Only set for textbox and drawing. + if (!isset($comment->type) && $comment->isquestion && $subscribe && $comment->visibility != 'private') { + // Only set for textbox and drawing. if (!empty($comment->issubscribed)) { $comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell-slash"], "text" => get_string('unsubscribeQuestion', 'pdfannotator')]; @@ -277,24 +284,29 @@ class comment implements \renderable, \templatable { } private function addforwardbutton($comment, $forwardquestions, $cm) { - if (!isset($comment->type) && $comment->isquestion && !$comment->isdeleted && $forwardquestions && $comment->visibility != 'private') { + if (!isset($comment->type) && $comment->isquestion && !$comment->isdeleted && $forwardquestions && + $comment->visibility != 'private') { global $CFG; $urlparams = ['id' => $cm->id, 'action' => 'forwardquestion', 'commentid' => $comment->uuid, 'sesskey' => sesskey()]; $url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams); - $comment->buttons[] = ["classes" => "comment-forward-a", "attributes" => ["name" => "onclick", "value" => "window.location.href = '$url';"], - "faicon" => ["class" => "fa-share"], "text" => get_string('forward', 'pdfannotator')]; + $comment->buttons[] = ["classes" => "comment-forward-a", "attributes" => ["name" => "onclick", + "value" => "window.location.href = '$url';"], "faicon" => ["class" => "fa-share"], + "text" => get_string('forward', 'pdfannotator')]; } } private function addmarksolvedbutton($comment, $solve) { - if ($solve && !$comment->isquestion && !$comment->isdeleted && !isset($comment->type) && $this->questionvisibility != 'private') { + if ($solve && !$comment->isquestion && !$comment->isdeleted && !isset($comment->type) && + $this->questionvisibility != 'private') { if ($comment->solved) { $comment->buttons[] = ["classes" => "comment-solve-a", "text" => get_string('removeCorrect', 'pdfannotator'), - "moodleicon" => ["key" => "i/completion-manual-n", "component" => "core", "title" => get_string('removeCorrect', 'pdfannotator')]]; + "moodleicon" => ["key" => "i/completion-manual-n", "component" => "core", + "title" => get_string('removeCorrect', 'pdfannotator')]]; } else { $comment->buttons[] = ["classes" => "comment-solve-a", "text" => get_string('markCorrect', 'pdfannotator'), - "moodleicon" => ["key" => "i/completion-manual-enabled", "component" => "core", "title" => get_string('markCorrect', 'pdfannotator')]]; + "moodleicon" => ["key" => "i/completion-manual-enabled", "component" => "core", + "title" => get_string('markCorrect', 'pdfannotator')]]; } } } diff --git a/controller.php b/controller.php index 8695ea1..ddb91c1 100644 --- a/controller.php +++ b/controller.php @@ -87,7 +87,8 @@ if ($action === 'forwardquestion') { if (!isset($errorinfo)) { $errorinfo = get_string('error:forwardquestion', 'pdfannotator'); // Display error notification. } - echo "<span id='subscriptionPanel' class='usernotifications'><div class='alert alert-success alert-block fade in' role='alert'>$errorinfo</div></span>"; + echo "<span id='subscriptionPanel' class='usernotifications'>" . + "<div class='alert alert-success alert-block fade in' role='alert'>$errorinfo</div></span>"; if ($fromoverview) { // If user forwarded question from overview go back to overview. $action = 'overviewquestions'; @@ -164,8 +165,10 @@ if ($action === 'overviewquestions') { $thiscourse = $pdfannotator->course; $cmid = get_coursemodule_from_instance('pdfannotator', $thisannotator, $thiscourse, false, MUST_EXIST)->id; - pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, $context); - echo $OUTPUT->heading(get_string('questionstab', 'pdfannotator') . ' ' . $OUTPUT->help_icon('questionstabicon', 'mod_pdfannotator')) . " <span id='pdfannotator-filter'></span>"; + pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, + $context); + echo $OUTPUT->heading(get_string('questionstab', 'pdfannotator') . ' ' . + $OUTPUT->help_icon('questionstabicon', 'mod_pdfannotator')) . " <span id='pdfannotator-filter'></span>"; $questions = pdfannotator_get_questions($thiscourse, $context, $questionfilter); @@ -179,7 +182,8 @@ if ($action === 'overviewquestions') { } echo "<span class='notification'><div class='alert alert-info alert-block fade in' role='alert'>$info</div></span>"; } else { - $urlparams = array('action' => 'overviewquestions', 'id' => $cmid, 'page' => $currentpage, 'itemsperpage' => $itemsperpage, 'questionfilter' => $questionfilter); + $urlparams = array('action' => 'overviewquestions', 'id' => $cmid, 'page' => $currentpage, 'itemsperpage' => $itemsperpage, + 'questionfilter' => $questionfilter); pdfannotator_print_questions($questions, $thiscourse, $urlparams, $currentpage, $itemsperpage, $context); } } @@ -201,7 +205,8 @@ if ($action === 'subscribeQuestion') { if (!empty($subscriptionid)) { $info = get_string('successfullySubscribed', 'pdfannotator'); - echo "<span id='subscriptionPanel' class='usernotifications'><div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; + echo "<span id='subscriptionPanel' class='usernotifications'>" . + "<div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; } $action = 'overviewanswers'; @@ -234,7 +239,8 @@ if ($action === 'unsubscribeQuestion') { } else { $info = get_string('successfullyUnsubscribed', 'pdfannotator', $entrycount); } - echo "<span id='pdfannotator_notificationpanel' class='usernotifications'><div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; + echo "<span id='pdfannotator_notificationpanel' class='usernotifications'>" . + "<div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; $action = 'overviewanswers'; } @@ -258,8 +264,10 @@ if ($action === 'overviewanswers') { $thiscourse = $pdfannotator->course; $cmid = get_coursemodule_from_instance('pdfannotator', $thisannotator, $thiscourse, false, MUST_EXIST)->id; - pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, $context); - echo $OUTPUT->heading(get_string('answerstab', 'pdfannotator') . ' ' . $OUTPUT->help_icon('answerstabicon', 'pdfannotator')) . " <span id='pdfannotator-filter'></span>"; + pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, + $context); + echo $OUTPUT->heading(get_string('answerstab', 'pdfannotator') . ' ' . + $OUTPUT->help_icon('answerstabicon', 'pdfannotator')) . " <span id='pdfannotator-filter'></span>"; $data = pdfannotator_get_answers_for_this_user($thiscourse, $context, $answerfilter); @@ -271,7 +279,8 @@ if ($action === 'overviewanswers') { } echo "<span class='notification'><div class='alert alert-info alert-block fade in' role='alert'>$info</div></span>"; } else { - $urlparams = array('action' => 'overviewanswers', 'id' => $cmid, 'page' => $currentpage, 'itemsperpage' => $itemsperpage, 'answerfilter' => $answerfilter); + $urlparams = array('action' => 'overviewanswers', 'id' => $cmid, 'page' => $currentpage, 'itemsperpage' => $itemsperpage, + 'answerfilter' => $answerfilter); $url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams); pdfannotator_print_answers($data, $thiscourse, $url, $currentpage, $itemsperpage, $cmid, $answerfilter); } @@ -293,8 +302,10 @@ if ($action === 'overviewownposts') { $thiscourse = $pdfannotator->course; $cmid = get_coursemodule_from_instance('pdfannotator', $thisannotator, $thiscourse, false, MUST_EXIST)->id; - pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, $context); - echo $OUTPUT->heading(get_string('ownpoststab', 'pdfannotator') . ' ' . $OUTPUT->help_icon('ownpoststabicon', 'mod_pdfannotator')); + pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, + $context); + echo $OUTPUT->heading(get_string('ownpoststab', 'pdfannotator') . ' ' . + $OUTPUT->help_icon('ownpoststabicon', 'mod_pdfannotator')); $posts = pdfannotator_get_posts_by_this_user($thiscourse, $context); @@ -311,7 +322,7 @@ if ($action === 'overviewownposts') { * This section marks a report as read and then rerenders the overview table of reports * (either unread reports (reportfiler == 0) or all reports (reportfilter == 2)). */ -if ($action === 'markreportasread') { // XXX Rename key and move it into $action === 'overviewreports' +if ($action === 'markreportasread') { // XXX Rename key and move it into $action === 'overviewreports'. require_sesskey(); require_capability('mod/pdfannotator:viewreports', $context); @@ -335,10 +346,12 @@ if ($action === 'markreportasread') { // XXX Rename key and move it into $action default: $info = get_string('successfullymarkedasread', 'pdfannotator'); } - echo "<span id='pdfannotator_notificationpanel' class='usernotifications'><div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; + echo "<span id='pdfannotator_notificationpanel' class='usernotifications'>" . + "<div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; } else { $info = get_string('error:markasread', 'pdfannotator'); - echo "<span id='pdfannotator_notificationpanel' class='usernotifications'><div class='alert alert-error alert-block fade in' role='alert'>$info</div></span>"; + echo "<span id='pdfannotator_notificationpanel' class='usernotifications'>" . + "<div class='alert alert-error alert-block fade in' role='alert'>$info</div></span>"; } $action = 'overviewreports'; // This will do the actual rerendering of the page (see below). @@ -347,7 +360,7 @@ if ($action === 'markreportasread') { // XXX Rename key and move it into $action * This section marks a report as read and then rerenders the overview table of reports * (either unread reports (reportfiler == 0) or all reports (reportfilter == 2)). */ -if ($action === 'markreportasunread') { // XXX Rename key and move it into $action === 'overviewreports' +if ($action === 'markreportasunread') { // XXX Rename key and move it into $action === 'overviewreports'. require_sesskey(); require_capability('mod/pdfannotator:viewreports', $context); @@ -362,19 +375,21 @@ if ($action === 'markreportasunread') { // XXX Rename key and move it into $acti // Give feedback to the user. if ($success) { switch ($reportfilter) { - case 1: // i.e.: Filter is currently set to show unread reports only. + case 1: // I.e.: Filter is currently set to show unread reports only. $info = get_string('successfullymarkedasunreadandnolongerdisplayed', 'pdfannotator'); break; - case 2: // i.e.: Filter is currently set to show all reports in this course. + case 2: // I.e.: Filter is currently set to show all reports in this course. $info = get_string('successfullymarkedasunread', 'pdfannotator'); break; default: $info = get_string('successfullymarkedasunread', 'pdfannotator'); } - echo "<span id='pdfannotator_notificationpanel' class='usernotifications'><div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; + echo "<span id='pdfannotator_notificationpanel' class='usernotifications'>" . + "<div class='alert alert-success alert-block fade in' role='alert'>$info</div></span>"; } else { $info = get_string('error:markasunread', 'pdfannotator'); - echo "<span id='pdfannotator_notificationpanel' class='usernotifications'><div class='alert alert-error alert-block fade in' role='alert'>$info</div></span>"; + echo "<span id='pdfannotator_notificationpanel' class='usernotifications'>" . + "<div class='alert alert-error alert-block fade in' role='alert'>$info</div></span>"; } $action = 'overviewreports'; // This will do the actual rerendering of the page (see below). @@ -397,8 +412,10 @@ if ($action === 'overviewreports') { $thiscourse = $pdfannotator->course; $cmid = get_coursemodule_from_instance('pdfannotator', $thisannotator, $thiscourse, false, MUST_EXIST)->id; - pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, $context); - echo $OUTPUT->heading(get_string('reportstab', 'pdfannotator') . ' ' . $OUTPUT->help_icon('reportstabicon', 'mod_pdfannotator')) . " <span id='pdfannotator-filter'></span>"; + pdfannotator_prepare_overviewpage($id, $myrenderer, $taburl, ['tab' => 'overview', 'action' => $action], $pdfannotator, + $context); + echo $OUTPUT->heading(get_string('reportstab', 'pdfannotator') . ' ' . + $OUTPUT->help_icon('reportstabicon', 'mod_pdfannotator')) . " <span id='pdfannotator-filter'></span>"; $reports = pdfannotator_get_reports($thiscourse, $reportfilter); @@ -416,7 +433,8 @@ if ($action === 'overviewreports') { } echo "<span class='notification'><div class='alert alert-info alert-block fade in' role='alert'>$info</div></span>"; } else { - $urlparams = array('action' => 'overviewreports', 'id' => $cmid, 'page' => $currentpage, 'itemsperpage' => $itemsperpage, 'reportfilter' => $reportfilter); + $urlparams = array('action' => 'overviewreports', 'id' => $cmid, 'page' => $currentpage, 'itemsperpage' => $itemsperpage, + 'reportfilter' => $reportfilter); $url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams); pdfannotator_print_reports($reports, $thiscourse, $url, $currentpage, $itemsperpage, $cmid, $reportfilter); } @@ -501,11 +519,13 @@ if ($action === 'report') { $report->url = $CFG->wwwroot . '/mod/pdfannotator/view.php?id=' . $cm->id . '&action=overviewreports'; $messagetext = new stdClass(); $modulename = format_string($cm->name, true); - $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, get_string('modulename', 'pdfannotator'), $modulename, $report, 'reportadded'); + $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, + get_string('modulename', 'pdfannotator'), $modulename, $report, 'reportadded'); $messagetext->url = $report->url; try { foreach ($recipients as $recipient) { - $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, get_string('modulename', 'pdfannotator'), $modulename, $report, 'reportadded', $recipient->id); + $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, + get_string('modulename', 'pdfannotator'), $modulename, $report, 'reportadded', $recipient->id); $messageid = pdfannotator_notify_manager($recipient, $course, $cm, $name, $messagetext); } // 2. Notify the reporting user that their report has been sent off (display blue toast box at top of page). diff --git a/db/upgrade.php b/db/upgrade.php index 46454ac..1b13b05 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -188,7 +188,8 @@ function xmldb_pdfannotator_upgrade($oldversion) { // Define field use_studentdrawing to be added to pdfannotator. $table = new xmldb_table('pdfannotator'); - $field = new xmldb_field('use_studentdrawing', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'use_studenttextbox'); + $field = new xmldb_field('use_studentdrawing', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', + 'use_studenttextbox'); // Conditionally launch add field use_studentdrawing. if (!$dbman->field_exists($table, $field)) { @@ -342,7 +343,8 @@ function xmldb_pdfannotator_upgrade($oldversion) { // Define key annotationtypeid (foreign) to be added to pdfannotator_annotations. $table = new xmldb_table('pdfannotator_annotations'); - $key = new xmldb_key('annotationtypeid', XMLDB_KEY_FOREIGN, array('annotationtypeid'), 'pdfannotator_annotationtypes', array('id')); + $key = new xmldb_key('annotationtypeid', XMLDB_KEY_FOREIGN, array('annotationtypeid'), 'pdfannotator_annotationtypes', + array('id')); // Launch add key annotationtypeid. $dbman->add_key($table, $key); @@ -579,7 +581,8 @@ function xmldb_pdfannotator_upgrade($oldversion) { // Define field useprivatecomments to be added to pdfannotator. $table = new xmldb_table('pdfannotator'); - $field = new xmldb_field('useprivatecomments', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'use_studentdrawing'); + $field = new xmldb_field('useprivatecomments', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', + 'use_studentdrawing'); // Conditionally launch add field useprivatecomments. if (!$dbman->field_exists($table, $field)) { @@ -588,7 +591,8 @@ function xmldb_pdfannotator_upgrade($oldversion) { // Define field useprotectedcomments to be added to pdfannotator. $table = new xmldb_table('pdfannotator'); - $field = new xmldb_field('useprotectedcomments', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'useprivatecomments'); + $field = new xmldb_field('useprotectedcomments', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', + 'useprivatecomments'); // Conditionally launch add field useprotectedcomments. if (!$dbman->field_exists($table, $field)) { diff --git a/forward_form.php b/forward_form.php index 3983af1..4941bca 100644 --- a/forward_form.php +++ b/forward_form.php @@ -64,7 +64,7 @@ class pdfannotator_forward_form extends moodleform { // Select recipients. $recipients = $this->_customdata['recipients']; - // 'selectgroups' instead of 'select' because the required-rule didn't work properly with a multi-select. + // Use 'selectgroups' instead of 'select' because the required-rule didn't work properly with a multi-select. $select = $mform->addElement('selectgroups', 'recipients', get_string('recipient', 'pdfannotator')); $select->addOptGroup('', $recipients); $select->setMultiple(true); @@ -72,7 +72,8 @@ class pdfannotator_forward_form extends moodleform { $mform->addRule('recipients', get_string('recipientrequired', 'pdfannotator'), 'required', null, 'client'); // Textarea for message to the recipient. - $mform->addElement('textarea', 'message', get_string('messageforwardform', 'pdfannotator'), 'wrap="virtual" rows="5" cols="109"'); + $mform->addElement('textarea', 'message', get_string('messageforwardform', 'pdfannotator'), + wrap="virtual" rows="5" cols="109"'); // Add submit and cancel buttons. $this->add_action_buttons($cancel = true, get_string('send', 'pdfannotator')); diff --git a/lang/en/pdfannotator.php b/lang/en/pdfannotator.php index b510e62..1b5360e 100644 --- a/lang/en/pdfannotator.php +++ b/lang/en/pdfannotator.php @@ -471,4 +471,4 @@ $string['years'] = 'years'; $string['yesButton'] = 'Yes'; $string['zoom'] = 'zoom'; $string['zoomin'] = 'zoom in'; -$string['zoomout'] = 'zoom out'; \ No newline at end of file +$string['zoomout'] = 'zoom out'; diff --git a/lib.php b/lib.php index 4102a31..914b6c8 100644 --- a/lib.php +++ b/lib.php @@ -35,7 +35,8 @@ function pdfannotator_supports($feature) { case FEATURE_BACKUP_MOODLE2: return true; case FEATURE_SHOW_DESCRIPTION: return true; - default: return null; + default: + return null; } } /** @@ -230,7 +231,8 @@ function pdfannotator_get_coursemodule_info($coursemodule) { $context = context_module::instance($coursemodule->id); - if (!$pdfannotator = $DB->get_record('pdfannotator', array('id' => $coursemodule->instance), 'id, name, course, timemodified, timecreated, intro, introformat')) { + if (!$pdfannotator = $DB->get_record('pdfannotator', array('id' => $coursemodule->instance), 'id, name, course, + timemodified, timecreated, intro, introformat')) { return null; } diff --git a/locallib.php b/locallib.php index 184a3ee..199a538 100644 --- a/locallib.php +++ b/locallib.php @@ -221,7 +221,8 @@ function pdfannotator_process_latex_moodle($context, $string) { } $imagedata = file_get_contents($image); $result['image'] = IMAGE_PREFIX . base64_encode($imagedata); - //imageinfo returns an array with the info of the size of the image. In Parameter 1 there is the height, which is the only thing needed here + // Imageinfo returns an array with the info of the size of the image. In Parameter 1 there is the height, which is the only + // thing needed here. $imageinfo = getimagesize($image); $result['imageheight'] = $imageinfo[1]; return $result; @@ -742,7 +743,8 @@ function pdfannotator_get_questions($courseid, $context, $questionfilter) { if ($questionfilter == 1) { $sql = $sql . ' AND NOT c.solved = 0 '; } - $sql = $sql . "GROUP BY a.id, p.name, p.usevotes, cm.id, c.id, a.page, a.pdfannotatorid, c.content, c.userid, c.visibility, c.timecreated, c.isdeleted, c.ishidden, c.isquestion"; + $sql = $sql . "GROUP BY a.id, p.name, p.usevotes, cm.id, c.id, a.page, a.pdfannotatorid, c.content, c.userid, c.visibility," + . "c.timecreated, c.isdeleted, c.ishidden, c.isquestion"; $params = array_merge([$courseid], $inparams); $questions = $DB->get_records_sql($sql, $params); @@ -906,7 +908,8 @@ function pdfannotator_get_answers_for_this_user($courseid, $context, $answerfilt if ($answerfilter == 0) { // Either: get all answers in this annotator. $sql = "SELECT c.id AS answerid, c.content AS answer, c.userid AS userid, c.visibility, " - . "c.timemodified, c.solved AS correct, c.ishidden AS answerhidden, a.id AS annoid, a.page, q.id AS questionid, q.userid AS questionuserid, c.isquestion, c.annotationid, " + . "c.timemodified, c.solved AS correct, c.ishidden AS answerhidden, a.id AS annoid, a.page, q.id AS questionid," + . "q.userid AS questionuserid, c.isquestion, c.annotationid, " . "q.visibility AS questionvisibility, " . "q.content AS answeredquestion, q.isdeleted AS questiondeleted, q.ishidden AS questionhidden, p.id AS annotatorid, " . "p.name AS pdfannotatorname, cm.id AS cmid, s.id AS issubscribed " @@ -920,7 +923,8 @@ function pdfannotator_get_answers_for_this_user($courseid, $context, $answerfilt . "ORDER BY annoid ASC"; } else { // Or: get answers to those questions the user subscribed to. $sql = "SELECT c.id AS answerid, c.content AS answer, c.userid AS userid, c.visibility, " - . "c.timemodified, c.solved AS correct, c.ishidden AS answerhidden, a.id AS annoid, a.page, q.id AS questionid, q.userid AS questionuserid, c.isquestion, c.annotationid, " + . "c.timemodified, c.solved AS correct, c.ishidden AS answerhidden, a.id AS annoid, a.page, q.id AS questionid, " + . "q.userid AS questionuserid, c.isquestion, c.annotationid, " . "q.visibility AS questionvisibility, " . "q.content AS answeredquestion, q.isdeleted AS questiondeleted, q.ishidden AS questionhidden, p.id AS annotatorid, " . "p.name AS pdfannotatorname, cm.id AS cmid " diff --git a/mod_form.php b/mod_form.php index 260f101..5a831b3 100644 --- a/mod_form.php +++ b/mod_form.php @@ -68,7 +68,8 @@ class mod_pdfannotator_mod_form extends moodleform_mod { $mform->addElement('filemanager', 'files', get_string('setting_fileupload', 'pdfannotator'), null, $filemanageroptions); // Params: 1. type of the element, 2. (html) elementname, 3. label. $mform->addHelpButton('files', 'setting_fileupload', 'pdfannotator'); - $mform->addElement('advcheckbox', 'usevotes', get_string('setting_usevotes', 'pdfannotator'), get_string('usevotes', 'pdfannotator'), null, array(0, 1)); + $mform->addElement('advcheckbox', 'usevotes', get_string('setting_usevotes', 'pdfannotator'), + get_string('usevotes', 'pdfannotator'), null, array(0, 1)); $mform->setType('usevotes', PARAM_BOOL); $mform->setDefault('usevotes', $config->usevotes); $mform->addHelpButton('usevotes', 'setting_usevotes', 'pdfannotator'); diff --git a/model/comment.class.php b/model/comment.class.php index 2c40f42..b0e3ddf 100644 --- a/model/comment.class.php +++ b/model/comment.class.php @@ -50,7 +50,7 @@ class pdfannotator_comment { $datarecord->annotationid = $annotationid; $datarecord->userid = $USER->id; $datarecord->content = $content; - $datarecord->timecreated = time(); // Moodle method: DateTime::getTimestamp(); + $datarecord->timecreated = time(); // Moodle method: DateTime::getTimestamp();. $datarecord->timemodified = $datarecord->timecreated; $datarecord->visibility = $visibility; $datarecord->isquestion = $isquestion; @@ -85,12 +85,14 @@ class pdfannotator_comment { $messagetext = new stdClass(); $module = get_string('modulename', 'pdfannotator'); - $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, $module, $modulename, $comment, 'newanswer'); + $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, $module, $modulename, + $comment, 'newanswer'); $messagetext->url = $comment->urltoanswer; $recipients = self::get_subscribed_users($annotationid); foreach ($recipients as $recipient) { if ($recipient != $USER->id) { - $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, $module, $modulename, $comment, 'newanswer', $recipient); + $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, $module, + $modulename, $comment, 'newanswer', $recipient); $messageid = pdfannotator_notify_manager($recipient, $course, $cm, 'newanswer', $messagetext, $anonymous); } } @@ -105,7 +107,8 @@ class pdfannotator_comment { $question->content = $content; $page = $DB->get_field('pdfannotator_annotations', 'page', array('id' => $annotationid), $strictness = MUST_EXIST); - $question->urltoanswer = $CFG->wwwroot . '/mod/pdfannotator/view.php?id=' . $cm->id . '&page=' . $page . '&annoid=' . $annotationid . '&commid=' . $commentuuid; + $question->urltoanswer = $CFG->wwwroot . '/mod/pdfannotator/view.php?id=' . $cm->id . '&page=' . $page . + '&annoid=' . $annotationid . '&commid=' . $commentuuid; $messagetext = new stdClass(); $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, get_string('modulename', 'pdfannotator'), $modulename, $question, 'newquestion'); @@ -153,7 +156,8 @@ class pdfannotator_comment { $comments = $DB->get_records_sql($sql, $a); // Records taken from table 'comments' as an array of objects. $usevotes = pdfannotator_instance::use_votes($documentid); - $annotation = $DB->get_record('pdfannotator_annotations', ['id' => $annotationid], $fields = 'timecreated, timemodified, modifiedby', $strictness = MUST_EXIST); + $annotation = $DB->get_record('pdfannotator_annotations', ['id' => $annotationid], + $fields = 'timecreated, timemodified, modifiedby', $strictness = MUST_EXIST); $result = array(); foreach ($comments as $data) { @@ -285,7 +289,7 @@ class pdfannotator_comment { if ($workingfine != 0) { $tobedeletedaswell[] = $predecessor->id; if ($predecessor->isquestion) { - $hideannotation = 1; // $annotationid; + $hideannotation = 1; // ... $annotationid; } } } else { @@ -298,7 +302,8 @@ class pdfannotator_comment { $success = $DB->update_record('pdfannotator_comments', array("id" => $commentid, "ishidden" => 1), $bulk = false); if ($success == 1) { - return ['status' => 'success', 'hideannotation' => $hideannotation, 'wasanswered' => $wasanswered, 'followups' => $tobedeletedaswell]; + return ['status' => 'success', 'hideannotation' => $hideannotation, 'wasanswered' => $wasanswered, + 'followups' => $tobedeletedaswell]; } else { return ['status' => 'error']; } diff --git a/model/overviewtable.php b/model/overviewtable.php index a3baebb..48c7fd5 100644 --- a/model/overviewtable.php +++ b/model/overviewtable.php @@ -64,7 +64,7 @@ class questionstable extends overviewtable { public function __construct($url, $showdropdown) { parent::__construct($this->id); global $OUTPUT; -// $this->collapsible(true); // Concerns the tables columns. + // $this->collapsible(true); // Concerns the tables columns. $this->define_baseurl($url); $columns = array('col0', 'col1', 'col2', 'col3', 'col4', 'col5'); if ($showdropdown) { @@ -80,12 +80,21 @@ class questionstable extends overviewtable { $this->column_style('col5', 'width', '20%'); // In which annotator is the question located. $this->attributes['id'] = $this->id; - $question = get_string('question', 'pdfannotator'); // $OUTPUT->pix_icon('i/unlock', '') . self::wrap(get_string('question', 'pdfannotator')); - $whoasked = get_string('by', 'pdfannotator') . ' ' . get_string('on', 'pdfannotator'); // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); - $votes = "<i class='icon fa fa-thumbs-up fa-fw' style='float:left'></i>" . ' ' . $OUTPUT->help_icon('voteshelpicon', 'pdfannotator'); // "<i class='icon fa fa-chevron-up fa-lg' style='float:left'></i>" . self::wrap(get_string('votes', 'pdfannotator')) . ' ' . $OUTPUT->help_icon('voteshelpicon', 'pdfannotator'); - $answers = $OUTPUT->pix_icon('t/message', '') . ' ' . $OUTPUT->help_icon('answercounthelpicon', 'pdfannotator');; // $OUTPUT->pix_icon('t/message', '') . ' ' . self::wrap(get_string('answers', 'pdfannotator')); - $lastanswered = get_string('lastanswered', 'pdfannotator'); // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('lastanswered', 'pdfannotator')); - $document = get_string('pdfannotatorcolumn', 'pdfannotator'); // "<i class='icon fa fa-book fa-fw'></i>" . self::wrap(get_string('pdfannotatorcolumn', 'pdfannotator')); + $question = get_string('question', 'pdfannotator'); + // $OUTPUT->pix_icon('i/unlock', '') . self::wrap(get_string('question', 'pdfannotator')); + $whoasked = get_string('by', 'pdfannotator') . ' ' . get_string('on', 'pdfannotator'); + // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . + // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); + $votes = "<i class='icon fa fa-thumbs-up fa-fw' style='float:left'></i>" . ' ' . + $OUTPUT->help_icon('voteshelpicon', 'pdfannotator'); + // "<i class='icon fa fa-chevron-up fa-lg' style='float:left'></i>" . self::wrap(get_string('votes', 'pdfannotator')) . + // ' ' . $OUTPUT->help_icon('voteshelpicon', 'pdfannotator'); + $answers = $OUTPUT->pix_icon('t/message', '') . ' ' . $OUTPUT->help_icon('answercounthelpicon', 'pdfannotator'); + // $OUTPUT->pix_icon('t/message', '') . ' ' . self::wrap(get_string('answers', 'pdfannotator')); + $lastanswered = get_string('lastanswered', 'pdfannotator'); + // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('lastanswered', 'pdfannotator')); + $document = get_string('pdfannotatorcolumn', 'pdfannotator'); + // "<i class='icon fa fa-book fa-fw'></i>" . self::wrap(get_string('pdfannotatorcolumn', 'pdfannotator')); $headers = array($question, $whoasked, $votes, $answers, $lastanswered, $document); if ($showdropdown) { @@ -125,12 +134,19 @@ class answerstable extends overviewtable { $this->column_style('col4', 'width', '10%'); // Annotator in which the question was asked. $this->column_style('col5', 'width', '10%'); // Action dropdown menu. $this->attributes['id'] = $this->id; - $answer = get_string('answer', 'pdfannotator'); // $OUTPUT->pix_icon('t/message', '') . self::wrap(get_string('answer', 'pdfannotator')); - $iscorrect = $OUTPUT->pix_icon('t/check', '') . ' ' . $OUTPUT->help_icon('iscorrecthelpicon', 'pdfannotator'); // . get_string('correct', 'pdfannotator'); - $whoanswered = get_string('by', 'pdfannotator') . ' ' . get_string('on', 'pdfannotator'); // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); - $question = get_string('myquestion', 'pdfannotator'); // $OUTPUT->pix_icon('i/email', '') . self::wrap(get_string('myquestion', 'pdfannotator')); - $document = get_string('pdfannotatorcolumn', 'pdfannotator'); // "<i class='icon fa fa-book fa-fw'></i>" . self::wrap(get_string('pdfannotatorcolumn', 'pdfannotator')); - $actionmenu = get_string('overviewactioncolumn', 'pdfannotator'); // $OUTPUT->pix_icon('i/settings', '') . self::wrap(get_string('overviewactioncolumn', 'pdfannotator')); + $answer = get_string('answer', 'pdfannotator'); + // $OUTPUT->pix_icon('t/message', '') . self::wrap(get_string('answer', 'pdfannotator')); + $iscorrect = $OUTPUT->pix_icon('t/check', '') . ' ' . $OUTPUT->help_icon('iscorrecthelpicon', 'pdfannotator'); + // . get_string('correct', 'pdfannotator'); + $whoanswered = get_string('by', 'pdfannotator') . ' ' . get_string('on', 'pdfannotator'); + // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . + // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); + $question = get_string('myquestion', 'pdfannotator'); + // $OUTPUT->pix_icon('i/email', '') . self::wrap(get_string('myquestion', 'pdfannotator')); + $document = get_string('pdfannotatorcolumn', 'pdfannotator'); + // "<i class='icon fa fa-book fa-fw'></i>" . self::wrap(get_string('pdfannotatorcolumn', 'pdfannotator')); + $actionmenu = get_string('overviewactioncolumn', 'pdfannotator'); + // $OUTPUT->pix_icon('i/settings', '') . self::wrap(get_string('overviewactioncolumn', 'pdfannotator')); $this->define_headers(array($answer, $iscorrect, $whoanswered, $question, $document, $actionmenu)); $this->no_sorting('col1'); $this->no_sorting('col0'); @@ -158,10 +174,16 @@ class userspoststable extends overviewtable { $this->column_style('col2', 'width', '7%'); // Number of votes for this post. $this->column_style('col3', 'width', '15%'); // Annotator in which they posted it. $this->attributes['id'] = $this->id; - $mypost = get_string('mypost', 'pdfannotator'); // $OUTPUT->pix_icon('t/message', '') . self::wrap(get_string('mypost', 'pdfannotator')); - $lastedited = get_string('lastedited', 'pdfannotator'); // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('lastedited', 'pdfannotator')); - $votes = "<i class='icon fa fa-thumbs-up fa-fw' style='float:left'></i>" . ' ' . $OUTPUT->help_icon('voteshelpicontwo', 'pdfannotator');; // "<i class='icon fa fa-chevron-up fa-lg' style='float:left'></i>" . self::wrap(get_string('votes', 'pdfannotator')). ' ' . $OUTPUT->help_icon('voteshelpicon', 'pdfannotator'); - $document = get_string('pdfannotatorcolumn', 'pdfannotator'); // "<i class='icon fa fa-book fa-fw'></i>" . self::wrap(get_string('pdfannotatorcolumn', 'pdfannotator')); + $mypost = get_string('mypost', 'pdfannotator'); + // $OUTPUT->pix_icon('t/message', '') . self::wrap(get_string('mypost', 'pdfannotator')); + $lastedited = get_string('lastedited', 'pdfannotator'); + // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('lastedited', 'pdfannotator')); + $votes = "<i class='icon fa fa-thumbs-up fa-fw' style='float:left'></i>" . ' ' . + $OUTPUT->help_icon('voteshelpicontwo', 'pdfannotator'); + // "<i class='icon fa fa-chevron-up fa-lg' style='float:left'></i>" . self::wrap(get_string('votes', 'pdfannotator')). ' ' . + // $OUTPUT->help_icon('voteshelpicon', 'pdfannotator'); + $document = get_string('pdfannotatorcolumn', 'pdfannotator'); + // "<i class='icon fa fa-book fa-fw'></i>" . self::wrap(get_string('pdfannotatorcolumn', 'pdfannotator')); $this->define_headers(array($mypost, $lastedited, $votes, $document)); $this->no_sorting('col0'); $this->sortable(true, 'col2', SORT_ASC); @@ -187,11 +209,18 @@ class reportstable extends overviewtable { $this->column_style('col3', 'width', '20%'); // Who reported the comment and when. $this->column_style('col4', 'width', '10%'); // Action dropdown menu. $this->attributes['id'] = $this->id; - $report = get_string('report', 'pdfannotator'); // $OUTPUT->pix_icon('i/email', '') . self::wrap(get_string('report', 'pdfannotator')); - $reportedby = get_string('by', 'pdfannotator'). ' '. get_string('on', 'pdfannotator'); // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); - $reportedcomment = get_string('reportedcomment', 'pdfannotator'); // $OUTPUT->pix_icon('i/flagged', '') . self::wrap(get_string('reportedcomment', 'pdfannotator')); - $writtenby = get_string('by', 'pdfannotator') . ' ' . get_string('on', 'pdfannotator'); // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); - $actionmenu = get_string('overviewactioncolumn', 'pdfannotator'); // $OUTPUT->pix_icon('i/settings', '') . self::wrap(get_string('overviewactioncolumn', 'pdfannotator')); + $report = get_string('report', 'pdfannotator'); + // $OUTPUT->pix_icon('i/email', '') . self::wrap(get_string('report', 'pdfannotator')); + $reportedby = get_string('by', 'pdfannotator'). ' '. get_string('on', 'pdfannotator'); + // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . + // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); + $reportedcomment = get_string('reportedcomment', 'pdfannotator'); + // $OUTPUT->pix_icon('i/flagged', '') . self::wrap(get_string('reportedcomment', 'pdfannotator')); + $writtenby = get_string('by', 'pdfannotator') . ' ' . get_string('on', 'pdfannotator'); + // $OUTPUT->pix_icon('i/user', '') . self::wrap(get_string('by', 'pdfannotator')) . ' ' . + // $OUTPUT->pix_icon('e/insert_time', '') . self::wrap(get_string('on', 'pdfannotator')); + $actionmenu = get_string('overviewactioncolumn', 'pdfannotator'); + // $OUTPUT->pix_icon('i/settings', '') . self::wrap(get_string('overviewactioncolumn', 'pdfannotator')); $this->define_headers(array($report, $reportedby, $reportedcomment, $writtenby, $actionmenu)); $this->no_sorting('col0'); $this->no_sorting('col2'); @@ -199,4 +228,4 @@ class reportstable extends overviewtable { $this->sortable(true, 'col3', SORT_ASC); $this->sortable(true, 'col1', SORT_DESC); } -} \ No newline at end of file +} diff --git a/model/statistics.class.php b/model/statistics.class.php index c95015b..49d54a2 100644 --- a/model/statistics.class.php +++ b/model/statistics.class.php @@ -136,19 +136,38 @@ class pdfannotator_statistics { public function get_tabledata() { $ret = []; - $ret[] = array('row' => array(get_string('all_questions', 'pdfannotator'), $this->get_comments_annotator('1'), $this->get_comments_course('1'))); - $ret[] = array('row' => array(get_string('myquestions', 'pdfannotator'), $this->get_comments_annotator('1', true), $this->get_comments_course('1', true))); - $ret[] = array('row' => array(get_string('average_questions', 'pdfannotator').'<a class="btn btn-link p-a-0" role="button" data-container="body" data-toggle="popover" data-placement="right" data-content="'.get_string('average_help', 'pdfannotator').'" data-html="true" tabindex="0" data-trigger="focus"><li class="icon fa fa-question-circle text-info fa-fw" aria-hidden="true" title="'.get_string('entity_helptitle', 'pdfannotator').' '.get_string('average', 'pdfannotator').'"></li></a>' - , round($this->get_comments_average_annotator('1'), 2), round($this->get_comments_average_course('1'), 2))); - $ret[] = array('row' => array(get_string('all_answers', 'pdfannotator'), $this->get_comments_annotator('0'), $this->get_comments_course('0'))); - $ret[] = array('row' => array(get_string('myanswers', 'pdfannotator'), $this->get_comments_annotator('0', true), $this->get_comments_course('0', true))); - $ret[] = array('row' => array(get_string('average_answers', 'pdfannotator').'<a class="btn btn-link p-a-0" role="button" data-container="body" data-toggle="popover" data-placement="right" data-content="'.get_string('average_help', 'pdfannotator').'" data-html="true" tabindex="0" data-trigger="focus"><li class="icon fa fa-question-circle text-info fa-fw" aria-hidden="true" title="'.get_string('entity_helptitle', 'pdfannotator').' '.get_string('average', 'pdfannotator').'"></li></a>' - , round($this->get_comments_average_annotator('0'), 2), round($this->get_comments_average_course('0'), 2))); - $ret[] = array('row' => array(get_string('private_comments', 'pdfannotator'), $this->count_private_comments($this->annotatorid, 0) + $this->count_private_comments($this->annotatorid, 1), $this->count_private_comments_in_course())); - $ret[] = array('row' => array(get_string('protected_comments', 'pdfannotator'), $this->count_protected_comments($this->annotatorid, 1) + $this->count_protected_comments($this->annotatorid, 0), $this->count_protected_comments_in_course())); + $ret[] = array('row' => array(get_string('all_questions', 'pdfannotator'), + $this->get_comments_annotator('1'), $this->get_comments_course('1'))); + $ret[] = array('row' => array(get_string('myquestions', 'pdfannotator'), + $this->get_comments_annotator('1', true), $this->get_comments_course('1', true))); + $ret[] = array('row' => array(get_string('average_questions', 'pdfannotator') . + '<a class="btn btn-link p-a-0" role="button" data-container="body" data-toggle="popover" data-placement="right" ' . + 'data-content="'.get_string('average_help', 'pdfannotator').'" data-html="true" tabindex="0" ' . + 'data-trigger="focus"><li class="icon fa fa-question-circle text-info fa-fw" aria-hidden="true" title="' . + get_string('entity_helptitle', 'pdfannotator') . ' ' . + get_string('average', 'pdfannotator').'"></li></a>' , round($this->get_comments_average_annotator('1'), 2), + round($this->get_comments_average_course('1'), 2))); + $ret[] = array('row' => array(get_string('all_answers', 'pdfannotator'), + $this->get_comments_annotator('0'), $this->get_comments_course('0'))); + $ret[] = array('row' => array(get_string('myanswers', 'pdfannotator'), + $this->get_comments_annotator('0', true), $this->get_comments_course('0', true))); + $ret[] = array('row' => array(get_string('average_answers', 'pdfannotator') . + '<a class="btn btn-link p-a-0" role="button" data-container="body" data-toggle="popover" data-placement="right" ' . + 'data-content="'.get_string('average_help', 'pdfannotator').'" data-html="true" tabindex="0" ' . + 'data-trigger="focus"><li class="icon fa fa-question-circle text-info fa-fw" aria-hidden="true" title="' . + get_string('entity_helptitle', 'pdfannotator') . ' ' . + get_string('average', 'pdfannotator').'"></li></a>', round($this->get_comments_average_annotator('0'), 2), + round($this->get_comments_average_course('0'), 2))); + $ret[] = array('row' => array(get_string('private_comments', 'pdfannotator'), + $this->count_private_comments($this->annotatorid, 0) + $this->count_private_comments($this->annotatorid, 1), + $this->count_private_comments_in_course())); + $ret[] = array('row' => array(get_string('protected_comments', 'pdfannotator'), + $this->count_protected_comments($this->annotatorid, 1) + $this->count_protected_comments($this->annotatorid, 0), + $this->count_protected_comments_in_course())); if ($this->isteacher) { - $ret[] = array('row' => array(get_string('reports', 'pdfannotator'), $this->get_reports_annotator(), $this->get_reports_course())); + $ret[] = array('row' => array(get_string('reports', 'pdfannotator'), $this->get_reports_annotator(), + $this->get_reports_course())); } return $ret; @@ -194,15 +213,16 @@ class pdfannotator_statistics { $myprivate[] = $countmyprivateanswers + $countmyprivatequestions; $myquestions[] = $countmyquestions - $countmyprotectedquestions - $countmyprivatequestions; - $otherquestions[] = $countquestions - $myquestions[$index] - $countprotectedquestions - $countprivatequestions; + $otherquestions[] = $countquestions - $myquestions[$index] - $countprotectedquestions - $countprivatequestions; $myanswers[] = $countmyanswers - $countmyprotectedanswers - $countmyprivateanswers; $otheranswers[] = $countanswers - $myanswers[$index] - $countprotectedanswers - $countprivateanswers; - + $names[] = $pdfannotator->get_name(); } - $ret = array($names, $otherquestions, $myquestions, $otheranswers, $myanswers, $otherprivate, $myprivate, $otherprotectedquestions, $myprotectedquestions, $otherprotectedanswers, $myprotectedanswers); + $ret = array($names, $otherquestions, $myquestions, $otheranswers, $myanswers, $otherprivate, $myprivate, + $otherprotectedquestions, $myprotectedquestions, $otherprotectedanswers, $myprotectedanswers); return $ret; } @@ -226,7 +246,7 @@ class pdfannotator_statistics { } /** - * Count private comments for annotator. + * Count private comments for annotator. */ public function count_private_comments($annotatorid, $isquestion, $userid=false) { global $DB; @@ -241,7 +261,8 @@ class pdfannotator_statistics { $sql = "SELECT COUNT(*) FROM {pdfannotator_comments} answers " . "JOIN {pdfannotator_comments} questions " . "ON answers.annotationid = questions.annotationid " - . "WHERE questions.visibility = 'private' AND answers.visibility = 'public' AND questions.pdfannotatorid = ? AND answers.isdeleted = ? "; + . "WHERE questions.visibility = 'private' AND answers.visibility = 'public' AND questions.pdfannotatorid = ? " + . "AND answers.isdeleted = ? "; $params = [$annotatorid, "0"]; if ($userid) { $sql .= ' AND answers.userid = ? AND questions.userid = ?'; @@ -265,7 +286,8 @@ class pdfannotator_statistics { $sql = "SELECT COUNT(*) FROM {pdfannotator_comments} answers " . "JOIN {pdfannotator_comments} questions " . "ON answers.annotationid = questions.annotationid " - . "WHERE questions.visibility = 'protected' AND answers.visibility = 'public' AND questions.pdfannotatorid = ? AND answers.isdeleted = ? "; + . "WHERE questions.visibility = 'protected' AND answers.visibility = 'public' AND questions.pdfannotatorid = ? " + . "AND answers.isdeleted = ? "; $params = [$annotatorid, "0"]; if ($userid) { $sql .= ' AND answers.userid = ? AND questions.userid = ?'; @@ -274,7 +296,7 @@ class pdfannotator_statistics { $count = $DB->count_records_sql($sql, $params); } return $count; - + } public function count_private_comments_in_course() { diff --git a/renderable.php b/renderable.php index b5cd682..7157b1a 100644 --- a/renderable.php +++ b/renderable.php @@ -62,4 +62,4 @@ class pdfannotator_comment_info implements renderable { return $info; } -} \ No newline at end of file +} diff --git a/renderer.php b/renderer.php index 49db9e2..f5d8c81 100644 --- a/renderer.php +++ b/renderer.php @@ -99,7 +99,8 @@ class mod_pdfannotator_renderer extends plugin_renderer_base { * @param string $nameargs * @return tabobject */ - private function pdfannotator_create_tab(moodle_url $baseurl, $action, $namekey = null, $pdfannotatorname = null, $nameargs = null) { + private function pdfannotator_create_tab(moodle_url $baseurl, $action, $namekey = null, $pdfannotatorname = null, + $nameargs = null) { $taburl = new moodle_url($baseurl, array('action' => $action)); $tabname = get_string($namekey, 'pdfannotator', $nameargs); if ($pdfannotatorname) { diff --git a/settings.php b/settings.php index 5b41d22..d445ca4 100644 --- a/settings.php +++ b/settings.php @@ -30,7 +30,8 @@ if ($ADMIN->fulltree) { get_string('global_setting_useprint', 'pdfannotator'), get_string('global_setting_useprint_desc', 'pdfannotator'), 0)); $settings->add(new admin_setting_configcheckbox('mod_pdfannotator/useprintcomments', - get_string('global_setting_useprint_comments', 'pdfannotator'), get_string('global_setting_useprint_comments_desc', 'pdfannotator'), 0)); + get_string('global_setting_useprint_comments', 'pdfannotator'), + get_string('global_setting_useprint_comments_desc', 'pdfannotator'), 0)); $settings->add(new admin_setting_configcheckbox('mod_pdfannotator/use_studenttextbox', get_string('global_setting_use_studenttextbox', 'pdfannotator'), @@ -48,10 +49,11 @@ if ($ADMIN->fulltree) { get_string('global_setting_use_protected_comments', 'pdfannotator'), get_string('global_setting_use_protected_comments_desc', 'pdfannotator'), 0)); - //Define what API to use for converting latex formulas into png. + // Define what API to use for converting latex formulas into png. $options = array(); $options[LATEX_TO_PNG_MOODLE] = get_string("global_setting_latexusemoodle", "pdfannotator"); $options[LATEX_TO_PNG_GOOGLE_API] = get_string("global_setting_latexusegoogle", "pdfannotator"); - $settings->add(new admin_setting_configselect('mod_pdfannotator/latexapi', get_string('global_setting_latexapisetting', 'pdfannotator'), + $settings->add(new admin_setting_configselect('mod_pdfannotator/latexapi', get_string('global_setting_latexapisetting', + 'pdfannotator'), get_string('global_setting_latexapisetting_desc', 'pdfannotator'), LATEX_TO_PNG_MOODLE, $options)); -} \ No newline at end of file +} diff --git a/version.php b/version.php index 36e086a..3b233a9 100644 --- a/version.php +++ b/version.php @@ -13,7 +13,6 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. - /** * Version information for mod/pdfannotator * @@ -25,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_pdfannotator'; -$plugin->version = 2021092400; -$plugin->release = 'PDF Annotator v1.4 release 7'; +$plugin->version = 2021090100; +$plugin->release = 'PDF Annotator v1.4 release 9'; $plugin->requires = 2021051700; -$plugin->maturity = MATURITY_STABLE; \ No newline at end of file +$plugin->maturity = MATURITY_STABLE; -- GitLab