Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

services:
postgres:
image: postgres:13
image: postgres:14
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
Expand All @@ -31,6 +31,25 @@ jobs:
fail-fast: false
matrix:
include:
- php: 8.4
moodle-branch: MOODLE_500_STABLE
database: pgsql
- php: 8.4
moodle-branch: MOODLE_500_STABLE
database: mariadb
- php: 8.3
moodle-branch: MOODLE_500_STABLE
database: pgsql
- php: 8.3
moodle-branch: MOODLE_500_STABLE
database: mariadb
- php: 8.2
moodle-branch: MOODLE_500_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_500_STABLE
database: mariadb

- php: 8.3
moodle-branch: MOODLE_405_STABLE
database: pgsql
Expand All @@ -42,13 +61,13 @@ jobs:
database: pgsql
- php: 8.2
moodle-branch: MOODLE_405_STABLE
database: mariadb
database: mariadb
- php: 8.1
moodle-branch: MOODLE_405_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_405_STABLE
database: mariadb
database: mariadb

- php: 8.3
moodle-branch: MOODLE_404_STABLE
Expand All @@ -61,13 +80,13 @@ jobs:
database: pgsql
- php: 8.2
moodle-branch: MOODLE_404_STABLE
database: mariadb
database: mariadb
- php: 8.1
moodle-branch: MOODLE_404_STABLE
database: pgsql
- php: 8.1
moodle-branch: MOODLE_404_STABLE
database: mariadb
database: mariadb

- php: 8.2
moodle-branch: MOODLE_403_STABLE
Expand Down Expand Up @@ -170,11 +189,11 @@ jobs:

- name: Moodle Code Checker
if: ${{ !cancelled() }}
run: moodle-plugin-ci codechecker --max-warnings 0 ./plugin || true
run: moodle-plugin-ci codechecker --max-warnings 0 ./plugin

- name: Moodle PHPDoc Checker
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpdoc --max-warnings 0 ./plugin || true
run: moodle-plugin-ci phpdoc --max-warnings 0 ./plugin

- name: Validating
if: ${{ !cancelled() }}
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 2025070803 v1.5.9
* Improve version file for 4.4+
* fix images not being displayed in comments
* remove explicit mathjax calls for rendering
* download comment as CSV feature
* mathjax3 and php84 changes
* Incorrect display of checkbox under editor for Moodle 5
* Annotation separation: Public Private and All comments

## 2025032500 v1.5.8
Expand Down
34 changes: 17 additions & 17 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
$documentid = required_param('documentId', PARAM_PATH);
$action = required_param('action', PARAM_ALPHA); // ...'$action' determines what is to be done; see below.

$pdfannotator = $DB->get_record('pdfannotator', array('id' => $documentid), '*', MUST_EXIST);
$pdfannotator = $DB->get_record('pdfannotator', ['id' => $documentid], '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('pdfannotator', $documentid, $pdfannotator->course, false, MUST_EXIST);
$context = context_module::instance($cm->id);

Expand All @@ -62,13 +62,13 @@

$page = optional_param('page_Number', 1, PARAM_INT); // Default page number is 1.

$annotations = array();
$annotations = [];

$records = $DB->get_records('pdfannotator_annotations', array('pdfannotatorid' => $documentid, 'page' => $page));
$records = $DB->get_records('pdfannotator_annotations', ['pdfannotatorid' => $documentid, 'page' => $page]);

foreach ($records as $record) {

$comment = $DB->get_record('pdfannotator_comments', array('annotationid' => $record->id, 'isquestion' => 1));
$comment = $DB->get_record('pdfannotator_comments', ['annotationid' => $record->id, 'isquestion' => 1]);
if ($comment && !pdfannotator_can_see_comment($comment, $context)) {
continue;
}
Expand All @@ -89,7 +89,7 @@
$annotations[] = $entry;
}

$data = array('documentId' => $documentid, 'pageNumber' => $page, 'annotations' => $annotations);
$data = ['documentId' => $documentid, 'pageNumber' => $page, 'annotations' => $annotations];
echo json_encode($data);
}

Expand All @@ -101,7 +101,7 @@
$annotationid = required_param('annotationId', PARAM_INT);
$page = optional_param('page_Number', 1, PARAM_INT);

$record = $DB->get_record('pdfannotator_annotations', array('id' => $annotationid), '*', MUST_EXIST);
$record = $DB->get_record('pdfannotator_annotations', ['id' => $annotationid], '*', MUST_EXIST);

$annotation = json_decode($record->data);
// Add general annotation data.
Expand All @@ -113,7 +113,7 @@
$annotation->class = "Annotation";
$annotation->page = $record->page;
$annotation->uuid = $record->id;
$data = array('documentId' => $documentid, 'annotation' => $annotation);
$data = ['documentId' => $documentid, 'annotation' => $annotation];
echo json_encode($data);
return;
}
Expand Down Expand Up @@ -175,7 +175,7 @@
$data['rectangles'] = $annotation['rectangles'];
break;
case 'textbox':
$studenttextboxesallowed = $DB->get_field('pdfannotator', 'use_studenttextbox', array('id' => $documentid),
$studenttextboxesallowed = $DB->get_field('pdfannotator', 'use_studenttextbox', ['id' => $documentid],
$strictness = MUST_EXIST);
$alwaystextboxallowed = has_capability('mod/pdfannotator:usetextbox', $context);
if ($studenttextboxesallowed != 1 && !$alwaystextboxallowed) {
Expand All @@ -194,8 +194,8 @@
$insertiondata = json_encode($data);

// 1.4 Insert a new record into mdl_pdfannotator_annotations.
$newannotationid = $DB->insert_record($table, array("pdfannotatorid" => $documentid, "page" => $pageid, "userid" => $USER->id,
"annotationtypeid" => $typeid, "data" => $insertiondata, "timecreated" => time()), true, false);
$newannotationid = $DB->insert_record($table, ["pdfannotatorid" => $documentid, "page" => $pageid, "userid" => $USER->id,
"annotationtypeid" => $typeid, "data" => $insertiondata, "timecreated" => time()], true, false);
// 2. If the insertion was successful...
if (isset($newannotationid) && $newannotationid !== false && $newannotationid > 0) {
// 2.1 set additional data to send back to the client.
Expand Down Expand Up @@ -313,8 +313,8 @@
echo json_encode($questions);
} else if ($pageid == -1) {
$questions = pdfannotator_comment::get_all_questions($documentid, $context);
$pdfannotatorname = $DB->get_field('pdfannotator', 'name', array('id' => $documentid), $strictness = MUST_EXIST);
$result = array('questions' => $questions, 'pdfannotatorname' => $pdfannotatorname);
$pdfannotatorname = $DB->get_field('pdfannotator', 'name', ['id' => $documentid], $strictness = MUST_EXIST);
$result = ['questions' => $questions, 'pdfannotatorname' => $pdfannotatorname];
echo json_encode($result);
} else {
$questions = pdfannotator_comment::get_questions($documentid, $pageid, $context);
Expand Down Expand Up @@ -482,8 +482,8 @@
$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 = ['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;
Expand Down Expand Up @@ -516,7 +516,7 @@
$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);
$urlparams = ['action' => 'overviewanswers', 'id' => $cmid, 'page' => 0, 'itemsperpage' => $itemsperpage];
$url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams);
redirect($url->out());
return;
Expand Down Expand Up @@ -558,7 +558,7 @@
$reportid = required_param('reportid', PARAM_INT);
$openannotator = required_param('openannotator', PARAM_INT);

if ($DB->update_record('pdfannotator_reports', array("id" => $reportid, "seen" => 1), $bulk = false)) {
if ($DB->update_record('pdfannotator_reports', ["id" => $reportid, "seen" => 1], $bulk = false)) {
echo json_encode(['status' => 'success', 'reportid' => $reportid]);
} else {
echo json_encode(['status' => 'error']);
Expand All @@ -576,7 +576,7 @@
$reportid = required_param('reportid', PARAM_INT);
$openannotator = required_param('openannotator', PARAM_INT);

if ($DB->update_record('pdfannotator_reports', array("id" => $reportid, "seen" => 0), $bulk = false)) {
if ($DB->update_record('pdfannotator_reports', ["id" => $reportid, "seen" => 0], $bulk = false)) {
echo json_encode(['status' => 'success', 'reportid' => $reportid]);
} else {
echo json_encode(['status' => 'error']);
Expand Down
35 changes: 17 additions & 18 deletions backup/moodle2/backup_pdfannotator_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* @author Anna Heynkes
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;

/**
* Define the complete pdfannotator structure for backup, with file and id annotations
Expand All @@ -53,28 +52,28 @@ protected function define_structure() {
$userinfo = $this->get_setting_value('userinfo');

// 2. Define each element separately.
$pdfannotator = new backup_nested_element('pdfannotator', array('id'), array(
$pdfannotator = new backup_nested_element('pdfannotator', ['id'], [
'name', 'intro', 'introformat', 'usevotes', 'useprint', 'useprintcomments', 'use_studenttextbox', 'use_studentdrawing',
'useprivatecomments', 'useprotectedcomments', 'timecreated', 'timemodified'));
'useprivatecomments', 'useprotectedcomments', 'timecreated', 'timemodified']);

$annotations = new backup_nested_element('annotations');
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid',
'data', 'timecreated', 'timemodified', 'modifiedby'));
$annotation = new backup_nested_element('annotation', ['id'], ['page', 'userid', 'annotationtypeid',
'data', 'timecreated', 'timemodified', 'modifiedby']);

$subscriptions = new backup_nested_element('subscriptions');
$subscription = new backup_nested_element('subscription', array('id'), array('userid'));
$subscription = new backup_nested_element('subscription', ['id'], ['userid']);

$comments = new backup_nested_element('comments');
$c = array('pdfannotatorid', 'userid', 'content', 'timecreated', 'timemodified', 'modifiedby', 'visibility',
'isquestion', 'isdeleted', 'ishidden', 'solved');
$comment = new backup_nested_element('comment', array('id'), $c);
$c = ['pdfannotatorid', 'userid', 'content', 'timecreated', 'timemodified', 'modifiedby', 'visibility',
'isquestion', 'isdeleted', 'ishidden', 'solved'];
$comment = new backup_nested_element('comment', ['id'], $c);

$votes = new backup_nested_element('votes');
$vote = new backup_nested_element('vote', array('id'), array('userid', 'annotationid'));
$vote = new backup_nested_element('vote', ['id'], ['userid', 'annotationid']);

$reports = new backup_nested_element('reports');
$report = new backup_nested_element('report', array('id'), array('courseid', 'pdfannotatorid', 'message',
'userid', 'timecreated', 'seen'));
$report = new backup_nested_element('report', ['id'], ['courseid', 'pdfannotatorid', 'message',
'userid', 'timecreated', 'seen']);

// 3. Build the tree (mind the right order!)
$pdfannotator->add_child($annotations);
Expand All @@ -94,27 +93,27 @@ protected function define_structure() {

// 4. Define db sources
// backup::VAR_ACTIVITYID is the 'course module id'.
$pdfannotator->set_source_table('pdfannotator', array('id' => backup::VAR_ACTIVITYID));
$pdfannotator->set_source_table('pdfannotator', ['id' => backup::VAR_ACTIVITYID]);

if ($userinfo) {
// Add all annotations specific to this annotator instance.
$annotation->set_source_sql('SELECT a.* FROM {pdfannotator_annotations} a '
. 'JOIN {pdfannotator_comments} c ON a.id = c.annotationid '
. "WHERE a.pdfannotatorid = ? AND c.isquestion = 1 AND "
. "(c.visibility = 'public' OR c.visibility = 'anonymous') ",
array('pdfannotatorid' => backup::VAR_PARENTID));
['pdfannotatorid' => backup::VAR_PARENTID]);

// Add any subscriptions to this annotation.
$subscription->set_source_table('pdfannotator_subscriptions', array('annotationid' => backup::VAR_PARENTID));
$subscription->set_source_table('pdfannotator_subscriptions', ['annotationid' => backup::VAR_PARENTID]);

// Add any comments of this annotation.
$comment->set_source_table('pdfannotator_comments', array('annotationid' => backup::VAR_PARENTID));
$comment->set_source_table('pdfannotator_comments', ['annotationid' => backup::VAR_PARENTID]);

// Add any votes for this comment.
$vote->set_source_table('pdfannotator_votes', array('commentid' => backup::VAR_PARENTID));
$vote->set_source_table('pdfannotator_votes', ['commentid' => backup::VAR_PARENTID]);

// Add any reports of this comment.
$report->set_source_table('pdfannotator_reports', array('commentid' => backup::VAR_PARENTID));
$report->set_source_table('pdfannotator_reports', ['commentid' => backup::VAR_PARENTID]);
}

// 5. Define id annotations (some attributes are foreign keys).
Expand Down
10 changes: 5 additions & 5 deletions backup/moodle2/restore_pdfannotator_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ protected function define_my_steps() {
* processed by the link decoder.
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('pdfannotator', array('intro'), 'pdfannotator');
$contents[] = new restore_decode_content('pdfannotator', ['intro'], 'pdfannotator');

return $contents;
}
Expand All @@ -70,7 +70,7 @@ public static function define_decode_contents() {
* to the activity to be executed by the link decoder
*/
public static function define_decode_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_decode_rule('PDFANNOTATORVIEWBYID', '/mod/pdfannotator/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('PDFANNOTATORINDEX', '/mod/pdfannotator/index.php?id=$1', 'course');
Expand All @@ -86,7 +86,7 @@ public static function define_decode_rules() {
* of {@see restore_log_rule} objects
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('pdfannotator', 'add', 'view.php?id={course_module}', '{pdfannotator}');
$rules[] = new restore_log_rule('pdfannotator', 'update', 'view.php?id={course_module}', '{pdfannotator}');
Expand All @@ -106,7 +106,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('pdfannotator', 'view all', 'index.php?id={course}', null);

Expand Down
5 changes: 1 addition & 4 deletions backup/moodle2/restore_pdfannotator_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Define all the restore steps that will be used by the restore_pdfannotator_activity_task
*/
Expand All @@ -46,7 +44,7 @@ class restore_pdfannotator_activity_structure_step extends restore_activity_stru
*/
protected function define_structure() {

$paths = array();
$paths = [];

$userinfo = $this->get_setting_value('userinfo');

Expand Down Expand Up @@ -185,7 +183,6 @@ protected function process_pdfannotator_report($data) {
$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.

Expand Down
2 changes: 0 additions & 2 deletions classes/event/course_module_instance_list_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

namespace mod_pdfannotator\event;

defined('MOODLE_INTERNAL') || die();

/**
* The mod_pdfannotator instance list viewed event class.
*
Expand Down
4 changes: 1 addition & 3 deletions classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

namespace mod_pdfannotator\event;

defined('MOODLE_INTERNAL') || die();

/**
* The mod_pdfannotator instance list viewed event class.
*
Expand All @@ -43,6 +41,6 @@ protected function init() {
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
return array('db' => 'pdfannotator', 'restore' => 'pdfannotator');
return ['db' => 'pdfannotator', 'restore' => 'pdfannotator'];
}
}
Loading
Loading