From f19413199ae70719f52d65531d70df3b3eb70c2c Mon Sep 17 00:00:00 2001
From: Friederike Schwager <schwager@cil.rwth-aachen.de>
Date: Thu, 18 Apr 2019 14:05:15 +0200
Subject: [PATCH] add feature forward questions
---
classes/output/comment.php | 318 ++++++++++++++++++++------------
classes/output/questionmenu.php | 11 +-
controller.php | 92 ++++++++-
db/access.php | 21 +++
db/messages.php | 9 +
forward_form.php | 83 +++++++++
lang/de/pdfannotator.php | 34 +++-
lang/en/pdfannotator.php | 34 +++-
locallib.php | 73 +++++++-
model/comment.class.php | 22 +--
model/overviewtable.php | 21 ++-
shared/index.js | 2 +-
templates/comment.mustache | 2 +-
version.php | 4 +-
14 files changed, 559 insertions(+), 167 deletions(-)
create mode 100644 forward_form.php
diff --git a/classes/output/comment.php b/classes/output/comment.php
index 7bd67ec..860baab 100644
--- a/classes/output/comment.php
+++ b/classes/output/comment.php
@@ -1,4 +1,5 @@
<?php
+
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -36,7 +37,19 @@ class comment implements \renderable, \templatable {
if (!is_array($data)) {
$data = [$data];
}
+
+ $report = has_capability('mod/pdfannotator:report', $context);
+ $closequestion = has_capability('mod/pdfannotator:closequestion', $context);
+ $closeanyquestion = has_capability('mod/pdfannotator:closeanyquestion', $context);
$editanypost = has_capability('mod/pdfannotator:editanypost', $context);
+ $seehiddencomments = has_capability('mod/pdfannotator:seehiddencomments', $context);
+ $hidecomments = has_capability('mod/pdfannotator:hidecomments', $context);
+ $deleteany = has_capability('mod/pdfannotator:deleteany', $context);
+ $deleteown = has_capability('mod/pdfannotator:deleteown', $context);
+ $subscribe = has_capability('mod/pdfannotator:subscribe', $context);
+ $forwardquestions = has_capability('mod/pdfannotator:forwardquestions', $context);
+ $solve = has_capability('mod/pdfannotator:markcorrectanswer', $context);
+
foreach ($data as $comment) {
$comment->buttons = [];
@@ -46,92 +59,27 @@ class comment implements \renderable, \templatable {
$comment->solved = boolval($comment->solved);
$owner = ($comment->userid == $USER->id);
+ $comment->owner = ($comment->userid == $USER->id);
- $comment->wrapperClass = 'chat-message comment-list-item';
- if ($comment->isquestion) {
- $comment->wrapperClass .= ' questioncomment';
- } else if ($comment->solved) {
- $comment->wrapperClass .= ' correct';
- }
- if ($owner) {
- $comment->wrapperClass .= ' owner';
- }
- if ($comment->usevotes) {
- $comment->wrapperClass .= ' usevotes';
- if (!$comment->isdeleted) {
- if ($owner) {
- $comment->voteBtn = get_string('likeOwnComment', 'pdfannotator');
- } else if ($comment->isvoted) {
- if ($comment->isquestion) {
- $comment->voteBtn = get_string('likeQuestionForbidden', 'pdfannotator');
- } else {
- $comment->voteBtn = get_string('likeAnswerForbidden', 'pdfannotator');
- }
- } else {
- if ($comment->isquestion) {
- $comment->voteBtn = get_string('likeQuestion', 'pdfannotator');
- } else {
- $comment->voteBtn = get_string('likeAnswer', 'pdfannotator');
- }
- }
- }
-
- if (!$comment->votes) {
- $comment->votes = "0";
- }
- if ($comment->isquestion) {
- $comment->voteTitle = $comment->votes . " " . get_string('likeCountQuestion', 'pdfannotator');
- } else {
- $comment->voteTitle = $comment->votes . " " . get_string('likeCountAnswer', 'pdfannotator');
- }
- }
+ $this->addcssclasses($comment, $owner);
- if (!empty($comment->ishidden)) {
- if (has_capability('mod/pdfannotator:seehiddencomments', $context)) {
- $comment->content = $comment->content;
- $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')],
- "text" => get_string('removehidden', 'pdfannotator')];
- } else {
- $comment->visibility = 'anonymous';
- $comment->content = '<em>' . get_string('hiddenComment', 'pdfannotator') . '</em>';
- }
+ $this->setvotes($comment);
- } else {
- if (has_capability('mod/pdfannotator:hidecomments', $context)) {
- $comment->buttons[] = ["attributes" => ["name" => "id", "value" => "hideButton" . $comment->uuid],
- "moodleicon" => ["key" => "i/show", "component" => "core", "title" => get_string('markhidden', 'pdfannotator')],
- "text" => get_string('markhidden', 'pdfannotator')];
- }
- }
+ $this->addreportbutton($comment, $report, $cm);
+ $this->addcloseopenbutton($comment, $closequestion, $closeanyquestion);
+ $this->addeditbutton($comment, $editanypost);
+ $this->addhidebutton($comment, $seehiddencomments, $hidecomments);
+ $this->adddeletebutton($comment, $deleteown, $deleteany);
+ $this->addsubscribebutton($comment, $subscribe);
+ $this->addforwardbutton($comment, $forwardquestions, $cm);
+ $this->addmarksolvedbutton($comment, $solve);
+
+ $this->addsolvedicon($comment);
if ($comment->isdeleted || isset($comment->type)) {
$comment->content = '<em>' . $comment->content . '</em>';
}
- if (!$comment->isdeleted) {
- $deleteany = has_capability('mod/pdfannotator:deleteany', $context);
- $deleteown = has_capability('mod/pdfannotator:deleteown', $context);
- $report = has_capability('mod/pdfannotator:report', $context);
- if ($deleteany || ($deleteown && $owner)) { // Delete.
- $comment->buttons[] = ["classes" => "comment-delete-a", "text" => get_string('delete', 'pdfannotator'),
- "moodleicon" => ["key" => "delete", "component" => "pdfannotator", "title" => get_string('delete', 'pdfannotator')]];
- }
- // Report (textbox/drawing can't be reported because of a missing commentid).
- if ($report && !$owner && !isset($comment->type) ) {
- $comment->report = true;
- $comment->cm = json_encode($cm); // Course module object.
- $comment->cmid = $cm->id;
- }
- if (!isset($comment->type) && ($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')],
- "text" => get_string('edit', 'pdfannotator')];
- }
- }
-
if (!empty($comment->modifiedby) && ($comment->modifiedby != $comment->userid) && ($comment->userid != 0)) {
$comment->modifiedby = get_string('modifiedby', 'pdfannotator') . pdfannotator_get_username($comment->modifiedby);
} else {
@@ -142,45 +90,6 @@ class comment implements \renderable, \templatable {
$comment->dropdown = true;
}
- if (!isset($comment->type) && $comment->isquestion) { // 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')];
- } else {
- $comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell"],
- "text" => get_string('subscribeQuestion', 'pdfannotator')];
- }
- // Open/Close.
- $closequestion = has_capability('mod/pdfannotator:closequestion', $context);
- $closeanyquestion = has_capability('mod/pdfannotator:closeanyquestion', $context);
- if (($owner && $closequestion) || $closeanyquestion) {
- if ($comment->solved) {
- $comment->buttons[] = ["classes" => "comment-solve-a", "faicon" => ["class" => "fa-unlock"],
- "text" => get_string('markUnsolved', 'pdfannotator')];
- } else {
- $comment->buttons[] = ["classes" => "comment-solve-a", "faicon" => ["class" => "fa-lock"],
- "text" => get_string('markSolved', 'pdfannotator')];
- }
- }
- }
-
- $solve = has_capability('mod/pdfannotator:markcorrectanswer', $context);
- if ($solve && !$comment->isquestion && !$comment->isdeleted && !isset($comment->type)) {
- 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')]];
- } 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')]];
- }
- }
- if ($comment->solved) {
- if ($comment->isquestion) {
- $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')];
- }
- }
$this->comments[] = $comment;
}
return;
@@ -198,4 +107,179 @@ class comment implements \renderable, \templatable {
return $data;
}
+ private function addcssclasses($comment, $owner) {
+ $comment->wrapperClass = 'chat-message comment-list-item';
+ if ($comment->isquestion) {
+ $comment->wrapperClass .= ' questioncomment';
+ } else if ($comment->solved) {
+ $comment->wrapperClass .= ' correct';
+ }
+ if ($owner) {
+ $comment->wrapperClass .= ' owner';
+ }
+ if ($comment->usevotes) {
+ $comment->wrapperClass .= ' usevotes';
+ }
+ }
+
+ public function setvotes($comment) {
+ if ($comment->usevotes && !$comment->isdeleted) {
+ if ($comment->owner) {
+ $comment->voteBtn = get_string('likeOwnComment', 'pdfannotator');
+ } else if ($comment->isvoted && $comment->isquestion) {
+ $comment->voteBtn = get_string('likeQuestionForbidden', 'pdfannotator');
+ } else if ($comment->isvoted && !$comment->isquestion) {
+ $comment->voteBtn = get_string('likeAnswerForbidden', 'pdfannotator');
+ } else if (!$comment->isvoted && $comment->isquestion) {
+ $comment->voteBtn = get_string('likeQuestion', 'pdfannotator');
+ } else if (!$comment->isvoted && !$comment->isquestion) {
+ $comment->voteBtn = get_string('likeAnswer', 'pdfannotator');
+ }
+
+ if (!$comment->votes) {
+ $comment->votes = "0";
+ }
+ if ($comment->isquestion) {
+ $comment->voteTitle = $comment->votes . " " . get_string('likeCountQuestion', 'pdfannotator');
+ } else {
+ $comment->voteTitle = $comment->votes . " " . get_string('likeCountAnswer', 'pdfannotator');
+ }
+ }
+ }
+
+ /**
+ * Add check icon if comment is marked as correct.
+ * @param type $comment
+ */
+ 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')];
+ } else if (!$comment->isdeleted) {
+ $comment->solvedicon = ["classes" => "icon fa fa-check fa-fw correctanswericon", "title" => get_string('answerSolved', 'pdfannotator')];
+ }
+ }
+ }
+
+ /**
+ * Report comment if user is not the owner.
+ * @param type $comment
+ * @param type $owner
+ * @param type $report
+ */
+ private function addreportbutton($comment, $report, $cm) {
+ if (!$comment->isdeleted && $report && !$comment->owner && !isset($comment->type)) {
+ $comment->report = true;
+ $comment->cm = json_encode($cm); // Course module object.
+ $comment->cmid = $cm->id;
+ }
+ }
+
+ /**
+ * Open/close question if user is owner of the question or manager.
+ * @param type $comment
+ * @param type $owner
+ * @param type $closequestion
+ * @param type $closeanyquestion
+ */
+ private function addcloseopenbutton($comment, $closequestion, $closeanyquestion) {
+
+ if (!isset($comment->type) && $comment->isquestion // Only set for textbox and drawing.
+ && (($comment->owner && $closequestion) || $closeanyquestion)) {
+
+ if ($comment->solved) {
+ $comment->buttons[] = ["classes" => "comment-solve-a", "faicon" => ["class" => "fa-unlock"],
+ "text" => get_string('markUnsolved', 'pdfannotator')];
+ } else {
+ $comment->buttons[] = ["classes" => "comment-solve-a", "faicon" => ["class" => "fa-lock"],
+ "text" => get_string('markSolved', 'pdfannotator')];
+ }
+ }
+ }
+
+ /**
+ * Button for editing comment if user is owner of the comment or manager.
+ * @param type $comment
+ * @param type $owner
+ * @param type $editanypost
+ */
+ 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')],
+ "text" => get_string('edit', 'pdfannotator')];
+ }
+ }
+
+ private function addhidebutton($comment, $seehiddencomments, $hidecomments) {
+ if (!empty($comment->ishidden) && !isset($comment->type)) {
+ if ($seehiddencomments) {
+ $comment->content = $comment->content;
+ $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')],
+ "text" => get_string('removehidden', 'pdfannotator')];
+ } else {
+ $comment->visibility = 'anonymous';
+ $comment->content = '<em>' . get_string('hiddenComment', 'pdfannotator') . '</em>';
+ }
+ } else if (!isset($comment->type)) {
+ if ($hidecomments) {
+ $comment->buttons[] = ["attributes" => ["name" => "id", "value" => "hideButton" . $comment->uuid],
+ "moodleicon" => ["key" => "i/show", "component" => "core", "title" => get_string('markhidden', 'pdfannotator')],
+ "text" => get_string('markhidden', 'pdfannotator')];
+ }
+ }
+ }
+
+ /**
+ * Delete comment if user is owner of the comment or manager.
+ * @param type $comment
+ * @param type $owner
+ * @param type $deleteown
+ * @param type $deleteany
+ */
+ 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')]];
+ }
+ }
+
+ private function addsubscribebutton($comment, $subscribe) {
+ if (!isset($comment->type) && $comment->isquestion && $subscribe) { // 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')];
+ } else {
+ $comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell"],
+ "text" => get_string('subscribeQuestion', 'pdfannotator')];
+ }
+ }
+ }
+
+ private function addforwardbutton($comment, $forwardquestions, $cm) {
+ if (!isset($comment->type) && $comment->isquestion && !$comment->isdeleted && $forwardquestions) {
+ global $CFG;
+ $urlparams = ['id' => $cm->id, 'action' => 'forwardquestion', 'commentid' => $comment->uuid];
+ $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')];
+ }
+ }
+
+ private function addmarksolvedbutton($comment, $solve) {
+ if ($solve && !$comment->isquestion && !$comment->isdeleted && !isset($comment->type)) {
+ 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')]];
+ } 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')]];
+ }
+ }
+ }
+
}
diff --git a/classes/output/questionmenu.php b/classes/output/questionmenu.php
index 6969172..c68c0b1 100644
--- a/classes/output/questionmenu.php
+++ b/classes/output/questionmenu.php
@@ -15,7 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Dropdown menu in questionstable on overview tab.
+ * The purpose of this script is to collect the output data for the statistic template and
+ * make it available to the renderer. The data is collected via the statistic model and then processed.
+ * Therefore, class statistic can be seen as a view controller.
*
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README.md)
@@ -31,12 +33,6 @@ class questionmenu implements \renderable, \templatable {
private $label;
private $buttonclass;
- /**
- * Constructor of renderable for dropdown menu in questionstable.
- *
- * @param int $commentid Id of the question
- * @param array $urlparams Parameters for the link
- */
public function __construct($commentid, $urlparams) {
global $CFG;
@@ -48,7 +44,6 @@ class questionmenu implements \renderable, \templatable {
$urlparams['action'] = 'forwardquestion';
$urlparams['fromoverview'] = '1';
$urlparams['commentid'] = $commentid;
- $urlparams['sesskey'] = sesskey();
$url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams);
$this->url = $url;
diff --git a/controller.php b/controller.php
index 71b6c4d..32c5b18 100644
--- a/controller.php
+++ b/controller.php
@@ -34,6 +34,96 @@ if ($action === 'overview') {
// Go to question-overview by default.
$action = 'overviewquestions';
}
+
+if ($action === 'forwardquestion') {
+ require_capability('mod/pdfannotator:forwardquestions', $context);
+ require_once($CFG->dirroot . '/mod/pdfannotator/forward_form.php');
+ global $USER;
+
+ $commentid = required_param('commentid', PARAM_INT);
+ $cminfo = pdfannotator_instance::get_cm_info($cm->course);
+ // Make sure user is allowed to see cm with the question. (Might happen if user changes commentid in url).
+ list($insql, $inparams) = $DB->get_in_or_equal(array_keys($cminfo));
+ $sql = "SELECT c.*, a.page, cm.id AS cmid "
+ . "FROM {pdfannotator_comments} c "
+ . "JOIN {pdfannotator_annotations} a ON c.annotationid = a.id "
+ . "JOIN {pdfannotator} p ON a.pdfannotatorid = p.id "
+ . "JOIN {course_modules} cm ON p.id = cm.instance "
+ . "WHERE c.isdeleted = 0 AND c.id = ? AND cm.id $insql";
+ $params = array_merge([$commentid], $inparams);
+ $comments = $DB->get_records_sql($sql, $params);
+ $error = false;
+ if (!$comments) {
+ $error = true;
+ } else {
+ $comment = $comments[$commentid];
+ if (!$error && $comment->ishidden && !has_capability('mod/pdfannotator:seehiddencomments', $context)) {
+ $error = true;
+ }
+ }
+
+ if ($error) { // An error occured e.g. comment doesn't exist.
+ $info = 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'>$info</div></span>";
+ $action = 'overviewquestions'; // And go back to overview.
+ } else {
+
+ $possiblerecipients = get_enrolled_users($context, 'mod/pdfannotator:getforwardedquestions');
+ $recipientslist = [];
+ foreach ($possiblerecipients as $recipient) {
+ $recipientslist[$recipient->id] = $recipient->firstname . ' ' . $recipient->lastname;
+ }
+
+ $data = new stdClass();
+ $data->course = $cm->course;
+ $data->pdfannotatorid = $cm->instance;
+ $data->pdfname = $cm->name;
+ $data->commentid = $commentid;
+ $data->id = $cm->id; // Course module id.
+ $data->action = 'forwardquestion';
+
+ // Initialise mform and pass on $data-object to it.
+ $mform = new pdfannotator_forward_form(null, ['comment' => $comment, 'recipients' => $recipientslist]);
+ $mform->set_data($data);
+
+ if ($mform->is_cancelled()) { // Form was cancelled.
+ // Go back to overview or document.
+ $fromoverview = optional_param('fromoverview', 0, PARAM_INT);
+ if ($fromoverview) {
+ $action = 'overviewquestions';
+ } else {
+ $action = 'view';
+ }
+ } else if ($data = $mform->get_data()) { // Process validated data. $mform->get_data() returns data posted in form.
+ $url = (new moodle_url('/mod/pdfannotator/view.php', array('id' => $comment->cmid,
+ 'page' => $comment->page, 'annoid' => $comment->annotationid, 'commid' => $comment->id)))->out();
+
+ $params = new stdClass();
+ $params->sender = $USER->firstname . ' ' . $USER->lastname;
+ $params->questioncontent = $comment->content;
+ $params->message = $data->message;
+ $params->urltoquestion = $url;
+
+ if (isset($data->recipients)) {
+ send_forward_message($data->recipients, $params, $course, $cm, $context);
+ }
+ $fromoverview = optional_param('fromoverview', 0, PARAM_INT);
+ if ($fromoverview) {
+ // If user forwarded question from overview go back to overview.
+ $action = 'overviewquestions';
+ } else {
+ // Else go to document.
+ $action = 'view';
+ }
+
+ } else { // Executed if the form is submitted but the data doesn't validate and the form should be redisplayed
+ // or on the first display of the form.
+ $PAGE->set_title("forward_form");
+ echo $OUTPUT->heading(get_string('titleforwardform', 'pdfannotator'));
+ $mform->display(); // Display form.
+ }
+ }
+}
/*
* This section prints a subpage of overview called 'unsolved questions'.
*/
@@ -69,7 +159,7 @@ 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);
- pdfannotator_print_questions($questions, $thiscourse, $urlparams, $currentpage, $itemsperpage);
+ pdfannotator_print_questions($questions, $thiscourse, $urlparams, $currentpage, $itemsperpage, $context);
}
}
/*
diff --git a/db/access.php b/db/access.php
index f9ae946..dd4e0a0 100644
--- a/db/access.php
+++ b/db/access.php
@@ -236,6 +236,27 @@ $capabilities = array(
),
),
+ 'mod/pdfannotator:forwardquestions' => array ( // Forward a question (to an other teacher/manager).
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW
+ ),
+ ),
+
+ 'mod/pdfannotator:getforwardedquestions' => array ( // Receive forwarded questions.
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW
+ ),
+ ),
+
+
// Get a notification about new questions.
'mod/pdfannotator:recievenewquestionnotifications' => array (
'captype' => 'read',
diff --git a/db/messages.php b/db/messages.php
index 70b5f95..939326c 100644
--- a/db/messages.php
+++ b/db/messages.php
@@ -44,6 +44,15 @@ $messageproviders = array (
// Notify teacher about a newly reported comment.
'newreport' => array (
'capability' => 'mod/pdfannotator:viewreports' // Teacher capability.
+ ),
+
+ // Notify when receiving a forwarded question.
+ 'forwardedquestion' => array (
+ 'capability' => 'mod/pdfannotator:getforwardedquestions',
+ 'defaults' => array(
+ 'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
+ 'email' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
+ )
)
);
\ No newline at end of file
diff --git a/forward_form.php b/forward_form.php
new file mode 100644
index 0000000..adf592c
--- /dev/null
+++ b/forward_form.php
@@ -0,0 +1,83 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * @package mod_pdfannotator
+ * @copyright 2018 RWTH Aachen (see README.md)
+ * @author Anna Heynkes
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ *
+ */
+defined('MOODLE_INTERNAL') || die();
+
+require_once($CFG->libdir . '/formslib.php');
+
+/**
+ * Description of reportform
+ *
+ * @author Admin
+ */
+class pdfannotator_forward_form extends moodleform {
+
+ public function definition() {
+ global $CFG;
+
+ $mform = $this->_form; // Don't forget the underscore!
+ // Pass contextual parameters to the form (via set_data() in controller.php)
+ // Course module id.
+ $mform->addElement('hidden', 'id');
+ $mform->setType('id', PARAM_INT);
+ // Course id.
+ $mform->addElement('hidden', 'course');
+ $mform->setType('course', PARAM_INT);
+ // Pdf id.
+ $mform->addElement('hidden', 'pdfannotatorid');
+ $mform->setType('pdfannotatorid', PARAM_INT);
+ // Pdfname.
+ $mform->addElement('hidden', 'pdfname');
+ $mform->setType('pdfname', PARAM_TEXT);
+ // Comment id.
+ $mform->addElement('hidden', 'commentid');
+ $mform->setType('commentid', PARAM_INT);
+ // Action = 'forwardquestion'.
+ $mform->addElement('hidden', 'action');
+ $mform->setType('action', PARAM_ALPHA);
+
+ // Display question.
+ $comment = $this->_customdata['comment'];
+ $mform->addElement('static', 'description', get_string('question', 'pdfannotator'), $comment->content);
+
+ // Select recipients.
+ $recipients = $this->_customdata['recipients'];
+
+ // '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);
+ $mform->addHelpButton('recipients', 'recipient', 'pdfannotator');
+ $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"');
+
+ // Add submit and cancel buttons.
+ $this->add_action_buttons($cancel = true, get_string('send', 'pdfannotator'));
+ }
+
+ public function display() {
+ $this->_form->display();
+ }
+
+}
diff --git a/lang/de/pdfannotator.php b/lang/de/pdfannotator.php
index a57a8c7..cff9673 100644
--- a/lang/de/pdfannotator.php
+++ b/lang/de/pdfannotator.php
@@ -46,10 +46,11 @@ $string['pdfannotator:usetextbox'] = 'Textbox verwenden (auch wenn es in den Ein
$string['pdfannotator:usedrawing'] = 'Drawing verwenden (auch wenn es in den Einstellungen des Annotators nicht erlaubt wurde)';
$string['pdfannotator:printdocument'] = 'Dokument herunterladen';
$string['pdfannotator:printcomments'] = 'Kommentare herunterladen';
-
+$string['pdfannotator:forwardquestions'] = 'Fragen weiterleiten';
+$string['pdfannotator:getforwardedquestions'] = 'Weitergeleitete Fragen erhalten';
$string['pdfannotator:hidecomments'] = 'Kommentare für Teilnehmer/innen verbergen';
$string['pdfannotator:seehiddencomments'] = 'Verborgene Kommentare sehen';
-
+
$string['pdfannotator:viewreports'] = 'Kommentar-Meldungen sehen (Übersichtsseite)';
$string['pdfannotator:viewanswers'] = 'Antworten auf abonnierte Fragen sehen (Übersichtsseite)';
$string['pdfannotator:viewquestions'] = 'Offene Fragen sehen (Übersichtsseite)';
@@ -137,13 +138,24 @@ $string['comments'] = 'Kommentare';
$string['author'] = 'Verfasser';
$string['guestscantdoanything'] = 'Gäste können hier nichts tun.';
+$string['forward'] = 'Weiterleiten';
+$string['titleforwardform'] = 'Frage weiterleiten';
+$string['messageforwardform'] = 'Ihre Nachricht an den/die Empfänger';
+$string['recipientrequired'] = 'Bitte wählen sie einen oder mehrere Empfänger aus';
+$string['recipientforwardform'] = 'Weiterleiten an';
+$string['recipient'] = 'Empfänger';
+$string['recipient_help'] = 'Um mehrere Personen auszuwählen, "Strg" gedrückt halten.';
+$string['send'] = 'Senden';
+
// When displaying your message types in a user's messaging preferences it will use a string from your component's language file called "messageprovider:messagename".
$string['messageprovider:newanswer'] = 'Mitteilung bei neuer Antwort auf eine abonnierte Frage';
$string['messageprovider:newreport'] = 'Mitteilung, wenn ein Kommentar gemeldet wurde';
$string['messageprovider:newquestion'] = 'Mitteilung, wenn eine neue Frage gestellt wurde';
+$string['messageprovider:forwardedquestion'] = 'Mitteilung, wenn eine Frage weitergeleitet an Sie wurde';
$string['notificationsubject:newreport'] = 'Neue Meldung eines Kommentars in {$a}';
$string['notificationsubject:newanswer'] = 'Neue Antwort auf von Ihnen abonnierte Frage in {$a}';
$string['notificationsubject:newquestion'] = 'Neue Frage in {$a}';
+$string['notificationsubject:forwardedquestion'] = 'Weitergeleitete Frage in {$a}';
$string['reportwassentoff'] = 'Ihre Meldung wurde erfolgreich versandt.';
$string['myquestion'] = 'Frage'; // 'zugehörige Frage' / 'Frage' / 'Abonnement'
@@ -258,6 +270,7 @@ $string['error:show'] = 'Beim Einblenden des Elements ist ein Fehler aufgetreten
$string['error:putinrecyclebin'] = 'Das Element konnte nicht in den Papierkorb verschoben werden.';
$string['error:markasread'] = 'Das Element konnte nicht als gelesen markiert werden.';
$string['error:markasunread'] = 'Das Element konnte nicht als ungelesen markiert werden.';
+$string['error:forwardquestion'] = 'Beim Weiterleiten der Frage ist ein Fehler aufgetreten.';
$string['document'] = 'Dokument';
@@ -316,6 +329,23 @@ $string['newquestiontext'] = 'Es wurde eine neue Frage von {$a->answeruser} eing
Die Frage ist verfügbar unter: {$a->urltoanswer}';
+$string['forwardedquestionhtml'] = '{$a->sender} hat folgende Frage an sie weitergeleitet: <br /> <br />'
+ . '"{$a->questioncontent}" <br /> <br />'
+ . 'mit folgender Nachricht: <br /> <br />'
+ . '"{$a->message}" <br /> <br />'
+ . 'Die Frage ist <a href="{$a->urltoquestion}">hier</a> einzusehen.';
+
+$string['forwardedquestiontext'] = '{$a->sender} hat folgende Frage an sie weitergeleitet:
+
+ "{$a->questioncontent}"
+
+ mit folgender Nachricht:
+
+ "{$a->message}"
+
+ Die Frage ist verfügbar unter: {$a->urltoquestion}';
+
+
$string['unsubscribe_notification'] = 'Um keine Benachrichtigung mehr zu erhalten, klicken Sie bitte <a href="{$a}">hier</a>.';
$string['gotocomment'] = 'zum Kommentar';
diff --git a/lang/en/pdfannotator.php b/lang/en/pdfannotator.php
index b18bf3f..185b797 100644
--- a/lang/en/pdfannotator.php
+++ b/lang/en/pdfannotator.php
@@ -46,7 +46,8 @@ $string['pdfannotator:usetextbox'] = 'Use textbox (even if the option is disable
$string['pdfannotator:usedrawing'] = 'Use drawing (even if the option is disabled for a PDF-Annotator)';
$string['pdfannotator:printdocument'] = 'Download the document';
$string['pdfannotator:printcomments'] = 'Download the comments';
-
+$string['pdfannotator:forwardquestions'] = 'Forward questions';
+$string['pdfannotator:getforwardedquestions'] = 'Receive forwarded questions';
$string['pdfannotator:hidecomments'] = 'Hide comments for participants';
$string['pdfannotator:seehiddencomments'] = 'See hidden comments';
@@ -148,6 +149,16 @@ $string['correct'] = 'correct';
$string['comments'] = 'Comments';
$string['author'] = 'Author';
$string['guestscantdoanything'] = 'Guests can\'t do anything here.';
+
+$string['forward'] = 'Forward';
+$string['titleforwardform'] = 'Forward question';
+$string['messageforwardform'] = 'Your message to the recipient/s';
+$string['recipientrequired'] = 'Please select recipient/s';
+$string['recipientforwardform'] = 'Forward to';
+$string['recipient'] = 'Recipient/s';
+$string['recipient_help'] = 'To select several persons, hold down "Ctrl"';
+$string['send'] = 'Send';
+
$string['newanswersavailable'] = 'Recently answered';
$string['newquestions'] = 'Recently asked';
$string['read'] = 'Read';
@@ -216,14 +227,16 @@ $string['newstitle'] = 'Just asked';
$string['messageprovider:newanswer'] = 'When a question you subscribed to was answered';
$string['messageprovider:newreport'] = 'When a comment was reported';
$string['messageprovider:newquestion'] = 'When a new question was asked';
+$string['messageprovider:forwardedquestion'] = 'When a question was forwarded to you';
$string['notificationsubject:newreport'] = 'A comment was reported in {$a}';
$string['notificationsubject:newanswer'] = 'New answer to subscribed question in {$a}';
$string['notificationsubject:newquestion'] = 'New question in {$a}';
+$string['notificationsubject:forwardedquestion'] = 'Forwarded question in {$a}';
$string['reportwassentoff'] = 'The comment has been reported.';
$string['myquestion'] = 'Question';
$string['mypost'] = 'My post';
-$string['question'] = 'question';
+$string['question'] = 'Question';
$string['askedby'] = 'By / on';
$string['answeredby'] = 'By / on';
$string['by'] = 'by';
@@ -337,6 +350,7 @@ $string['error:show'] = 'An error has occured while showing the element.';
$string['error:putinrecyclebin'] = 'The item could not be placed in the recycle bin.';
$string['error:markasread'] = 'The item could not be marked as read.';
$string['error:markasunread'] = 'The item could not be marked as unread.';
+$string['error:forwardquestion'] = 'An error has occured while forwarding the question.';
$string['document'] = 'Document';
@@ -382,6 +396,22 @@ $string['newquestiontext'] = 'A new Questions was added by {$a->answeruser} with
The question is available under: {$a->urltoanswer}';
+$string['forwardedquestionhtml'] = '{$a->sender} forwarded the following question to you: <br /> <br />'
+ . '"{$a->questioncontent}" <br /> <br />'
+ . 'with the message: <br /> <br />'
+ . '"{$a->message}" <br /> <br />'
+ . 'The question is available <a href="{$a->urltoquestion}">here</a>.';
+
+$string['forwardedquestiontext'] = '{$a->sender} hat folgende Frage an sie weitergeleitet:
+
+ "{$a->questioncontent}"
+
+ mit folgender Nachricht:
+
+ "{$a->message}"
+
+ Die Frage ist verfügbar unter: {$a->urltoquestion}';
+
$string['unsubscribe_notification'] = 'To unsubscribe from notification, please click <a href="{$a}">here</a>.';
$string['gotocomment'] = 'Open the comment.';
diff --git a/locallib.php b/locallib.php
index 967a3ff..da431cd 100644
--- a/locallib.php
+++ b/locallib.php
@@ -231,9 +231,22 @@ function pdfannotator_process_latex($string) {
}
}
+function send_forward_message($recipients, $messageparams, $course, $cm, $context) {
+ $name = 'forwardedquestion';
+ $text = new stdClass();
+ $module = get_string('modulename', 'pdfannotator');
+ $text->text = pdfannotator_format_notification_message_text($course, $cm, $context, $module, $cm->name, $messageparams, $name);
+ $text->html = pdfannotator_format_notification_message_html($course, $cm, $context, $module, $cm->name, $messageparams, $name);
+ $text->url = $messageparams->urltoquestion;
+
+ foreach ($recipients as $recipient) {
+ pdfannotator_notify_manager($recipient, $course, $cm, $name, $text);
+ }
+}
+
function pdfannotator_notify_manager($recipient, $course, $cm, $name, $messagetext, $anonymous = false) {
- global $USER, $CFG;
+ global $USER;
$userfrom = $USER;
if ($anonymous) {
$userfrom = clone($USER);
@@ -1290,11 +1303,12 @@ function pdfannotator_get_first_key_in_array($array) {
* @param Moodle url object $url
* @param int $currentpage
*/
-function pdfannotator_print_questions($questions, $thiscourse, $urlparams, $currentpage, $itemsperpage) {
+function pdfannotator_print_questions($questions, $thiscourse, $urlparams, $currentpage, $itemsperpage, $context) {
global $CFG, $OUTPUT;
require_once("$CFG->dirroot/mod/pdfannotator/model/overviewtable.php");
+ $showdropdown = has_capability('mod/pdfannotator:forwardquestions', $context);
$questioncount = count($questions);
$usepagination = !($itemsperpage == -1 || $itemsperpage >= $questioncount);
$offset = $currentpage * $itemsperpage;
@@ -1306,7 +1320,7 @@ function pdfannotator_print_questions($questions, $thiscourse, $urlparams, $curr
$url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams);
// Define flexible table.
- $table = new questionstable($url);
+ $table = new questionstable($url, $showdropdown);
$table->setup();
// $table->pageable(false);
@@ -1320,7 +1334,7 @@ function pdfannotator_print_questions($questions, $thiscourse, $urlparams, $curr
// Add data to the table and print the requested table (page).
if (pdfannotator_is_phone() || $itemsperpage == -1 || $itemsperpage >= $questioncount) { // No pagination.
foreach ($questions as $question) {
- pdfannotator_questionstable_add_row($thiscourse, $table, $question);
+ pdfannotator_questionstable_add_row($thiscourse, $table, $question, $urlparams, $showdropdown);
}
} else {
$table->pagesize($itemsperpage, $questioncount);
@@ -1329,7 +1343,7 @@ function pdfannotator_print_questions($questions, $thiscourse, $urlparams, $curr
if ($itemsperpage === 0) {
break;
}
- pdfannotator_questionstable_add_row($thiscourse, $table, $question);
+ pdfannotator_questionstable_add_row($thiscourse, $table, $question, $urlparams, $showdropdown);
$itemsperpage--;
}
}
@@ -1477,8 +1491,9 @@ function pdfannotator_print_reports($reports, $thiscourse, $url, $currentpage, $
* @param questionstable $table
* @param object $question
*/
-function pdfannotator_questionstable_add_row($thiscourse, $table, $question) {
- global $CFG;
+function pdfannotator_questionstable_add_row($thiscourse, $table, $question, $urlparams, $showdropdown) {
+
+ global $CFG, $PAGE;
if ($question->visibility != 'public') {
$author = get_string('anonymous', 'pdfannotator');
} else {
@@ -1502,7 +1517,16 @@ function pdfannotator_questionstable_add_row($thiscourse, $table, $question) {
}
$content = "<a href=$question->link class='more'>$question->content</a>";
$pdfannotatorname = $question->pdfannotatorname;
- $table->add_data(array($content, $author . '<br>' . $time, $question->votes, $question->answercount, $lastanswered, $pdfannotatorname), $classname);
+
+ $data = array($content, $author . '<br>' . $time, $question->votes, $question->answercount, $lastanswered, $pdfannotatorname);
+
+ if ($showdropdown) {
+ require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/questionmenu.php');
+ $myrenderer = $PAGE->get_renderer('mod_pdfannotator');
+ $dropdown = $myrenderer->render_dropdownmenu(new questionmenu($question->commentid, $urlparams));
+ $data[] = $dropdown;
+ }
+ $table->add_data($data, $classname);
}
/**
* This function adds a row of data to the overview table that displays
@@ -1610,7 +1634,38 @@ function pdfannotator_reportstable_add_row($thiscourse, $table, $report, $cmid,
// Add a new row to the reports table.
$table->add_data(array($report->report, $reportedby . '<br>' . $reporttime, $reportedcommmentlink, $writtenby . '<br>' . $commenttime, $dropdown), $classname);
}
-
+/**
+ * This function receives data from our feedback form and sends it to the
+ * developers via email.
+ *
+ * @global type $USER
+ * @param type $formdata
+ */
+function pdfannotator_send_feedbackmail ($formdata, $url) {
+
+ global $USER;
+
+ $subject = 'Feedback zum PDF-Annotation-Tool aus Aachen';
+ $messagetext = $formdata->feedback;
+ $from = $USER->firstname . ' ' . $USER->lastname . '<' . $USER->email . '>';
+ $headers = "From: $from\r\n";
+ $headers .= "Content-type: text/html\r\n";
+ $to = 'obeid@cil.rwth-aachen.de, schwager@cil.rwth-aachen.de, heynkes@cil.rwth-aachen.de';
+ $html = <<<EOF
+ <html>
+ <head>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
+ </head>
+ <body dir='auto'>
+ <div dir='ltr'>$messagetext</div>
+ <br><br>
+ Gesendet von $url
+ </body>
+ </html>
+EOF;
+
+ mail($to, $subject, $html, $headers);
+}
/**
* Function takes a moodle timestamp, calculates how much time has since elapsed
* and returns this information as a string (e.g.: '3 days ago').
diff --git a/model/comment.class.php b/model/comment.class.php
index e3d5fbf..077f453 100644
--- a/model/comment.class.php
+++ b/model/comment.class.php
@@ -260,13 +260,6 @@ class pdfannotator_comment {
$tobedeletedaswell = [];
$hideannotation = 0;
-// $success = $DB->update_record('pdfannotator_comments', array("id" => $commentid, "ishidden" => 1), $bulk = false);
-
-// if ($wasanswered) { // If the comment was answered, mark it as deleted for a special display.
-// $params = array("id" => $commentid, "isdeleted" => 1);
-// $success = $DB->update_record('pdfannotator_comments', $params, $bulk = false);
-// } else { // If not, just delete it.
-// //
if (!$wasanswered) {
// But first: Check if the predecessor was already marked as deleted, too and if so, delete it completely.
$sql = "SELECT id, isdeleted, isquestion from {pdfannotator_comments} "
@@ -280,8 +273,7 @@ class pdfannotator_comment {
if ($workingfine != 0) {
$tobedeletedaswell[] = $predecessor->id;
if ($predecessor->isquestion) {
-// pdfannotator_annotation::delete($annotationid, $cmid, true);
- $hideannotation = 1; //$annotationid;
+ $hideannotation = 1; // $annotationid;
}
}
} else {
@@ -289,22 +281,12 @@ class pdfannotator_comment {
}
}
- // If the comment is a question and has no answers, delete the annotion.
-// if ($comment->isquestion) {
-// pdfannotator_annotation::delete($annotationid, $cmid, true);
-// $deleteannotation = $annotationid;
-// }
-
-// $success = $DB->delete_records('pdfannotator_comments', array("id" => $commentid));
}
$success = $DB->update_record('pdfannotator_comments', array("id" => $commentid, "ishidden" => 1), $bulk = false);
- // Delete votes to the comment.
-// $DB->delete_records('pdfannotator_votes', array("commentid" => $commentid));
-
if ($success == 1) {
- return ['status' => 'success', 'hideannotation' => $hideannotation, 'wasanswered' => $wasanswered, 'followups' => $tobedeletedaswell]; //, 'deleteannotation' => $deleteannotation];
+ return ['status' => 'success', 'hideannotation' => $hideannotation, 'wasanswered' => $wasanswered, 'followups' => $tobedeletedaswell]; // , 'deleteannotation' => $deleteannotation];
} else {
return ['status' => 'error'];
}
diff --git a/model/overviewtable.php b/model/overviewtable.php
index c0e1114..0ea65d1 100644
--- a/model/overviewtable.php
+++ b/model/overviewtable.php
@@ -61,26 +61,39 @@ class questionstable extends overviewtable {
private $id = 'mod-pdfannotator-questions';
- public function __construct($url) {
+ public function __construct($url, $showdropdown) {
parent::__construct($this->id);
global $OUTPUT;
// $this->collapsible(true); // Concerns the tables columns.
$this->define_baseurl($url);
- $this->define_columns(array('col0', 'col1', 'col2', 'col3', 'col4', 'col5'));
+ $columns = array('col0', 'col1', 'col2', 'col3', 'col4', 'col5');
+ if ($showdropdown) {
+ $columns[] = 'col6';
+ }
+ $this->define_columns($columns);
$this->column_style('col0', 'width', '30% !important'); // Question.
$this->column_style('col1', 'width', '19%'); // Who asked the question when.
$this->column_style('col2', 'width', '6%'); // How many people voted for the question.
$this->column_style('col3', 'width', '6%'); // How many answers were given to it.
$this->column_style('col4', 'width', '19%'); // When was the last answer given.
$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'));
+ $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'));
- $this->define_headers(array($question, $whoasked, $votes, $answers, $lastanswered, $document));
+
+ $headers = array($question, $whoasked, $votes, $answers, $lastanswered, $document);
+ if ($showdropdown) {
+ $this->column_style('col6', 'width', '5%'); // Action dropdown menu.
+ $actionmenu = get_string('overviewactioncolumn', 'pdfannotator');
+ $headers[] = $actionmenu;
+ }
+
+ $this->define_headers($headers);
$this->no_sorting('col0');
$this->sortable(true, 'col4', SORT_ASC);
$this->sortable(true, 'col5', SORT_ASC);
diff --git a/shared/index.js b/shared/index.js
index 59e3469..0b96cd0 100644
--- a/shared/index.js
+++ b/shared/index.js
@@ -1534,7 +1534,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
createSubscriptionHandler(comment);
createHideHandler(comment);
createDeleteHandler(comment);
- createSolvedHandler(comment);
+ createSolvedHandler(comment);
let pattern = $('#searchPattern').val();
if(pattern !== '' && comment.content.search(new RegExp(pattern, "i")) !== -1){
$('#comment_'+comment.uuid).addClass('mark');
diff --git a/templates/comment.mustache b/templates/comment.mustache
index 965b39d..c6042fd 100644
--- a/templates/comment.mustache
+++ b/templates/comment.mustache
@@ -34,7 +34,7 @@
</span>
{{/ report }}
{{#buttons}}
- <button class="dropdown-item {{classes}}" type=button {{#attributes}} {{name}}="{{value}}"{{/attributes}}>
+ <button class="dropdown-item {{classes}}" type=button {{#attributes}} {{name}}="{{&value}}"{{/attributes}}>
{{#moodleicon}} {{#pix}} {{key}},{{component}},{{title}} {{/pix}} {{/moodleicon}}
{{#faicon}} <i class=" icon fa {{class}} fa-fw"></i> {{/faicon}}
<span class="menu-action-text">
diff --git a/version.php b/version.php
index ea4b5e7..dd28d00 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'mod_pdfannotator'; // Full name of the plugin (used for diagnostics).
-$plugin->version = 2019042900; // The current module version (Date: YYYYMMDDXX).
-$plugin->release = 'PDF Annotator v1.2 release 1';
+$plugin->version = 2019042500; // The current module version (Date: YYYYMMDDXX).
+$plugin->release = 'PDF Annotator v1.1 release 1';
$plugin->requires = 2016112900; // Requires this Moodle version.
$plugin->cron = 0; // Period for cron to check this module (secs).
--
GitLab