Skip to content

Commit 9809f81

Browse files
authored
Support for Moodle 5
support Moodle 5
2 parents bc190a3 + 9f5fe3d commit 9809f81

22 files changed

+10864
-7512
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 2025070803 v1.5.9
2+
* fix images not being displayed in comments
3+
* remove explicit mathjax calls for rendering
4+
* download comment as CSV feature
5+
* mathjax3 and php84 changes
6+
* Incorrect display of checkbox under editor for Moodle 5
7+
* Annotation separation: Public Private and All comments
8+
19
## 2025032500 v1.5.8
210
* Hotfix: correct further trailing junk after parameter
311
* Versioning error fix

action.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,20 +614,24 @@
614614
$count = 0;
615615
foreach ($conversations as $conversation) {
616616
$post = new stdClass();
617+
$post->rawAnsweredquestion = $conversation->answeredquestion;
617618
$post->answeredquestion = pdfannotator_handle_latex($context, $conversation->answeredquestion);
618619
$post->answeredquestion = pdfannotator_extract_images($post->answeredquestion, $conversation->id, $context);
619620
$post->page = $conversation->page;
620621
$post->annotationtypeid = $conversation->annotationtypeid;
621622
$post->author = $conversation->author;
623+
$post->id = $conversation->id;
622624
$post->timemodified = $conversation->timemodified;
623625
$post->answers = [];
624626

625627
$answercount = 0;
626628
foreach ($conversation->answers as $ca) {
627629
$answer = new stdClass();
630+
$answer->rawAnswer = $ca->answer;
628631
$answer->answer = pdfannotator_handle_latex($context, $ca->answer);
629632
$answer->answer = pdfannotator_extract_images($answer->answer, $ca->id, $context);
630633
$answer->author = $ca->author;
634+
$answer->id = $ca->id;
631635
$answer->timemodified = $ca->timemodified;
632636
$post->answers[$answercount] = $answer;
633637
$answercount++;

classes/output/comment.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ private function addcssclasses($comment, $owner) {
126126
$comment->wrapperClass = 'chat-message comment-list-item';
127127
if ($comment->isquestion) {
128128
$comment->wrapperClass .= ' questioncomment';
129+
if($comment->visibility == 'private' || $comment->visibility == 'protected') {
130+
$comment->wrapperClass .= ' questions-private';
131+
}
129132
} else if ($comment->solved) {
130133
$comment->wrapperClass .= ' correct';
131134
}

classes/output/index.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636

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

39-
class index implements \renderable, \templatable { // Class should be placed elsewhere.
39+
class index implements \renderable, \templatable {
40+
// Class should be placed elsewhere.
4041

4142
private $usestudenttextbox;
4243
private $usestudentdrawing;
@@ -81,6 +82,8 @@ public function export_for_template(\renderer_base $output) {
8182
$data->printlink = $this->printurl;
8283
$data->pixprintdoc = $OUTPUT->image_url('download', 'mod_pdfannotator');
8384
$data->pixprintcomments = $OUTPUT->image_url('print_comments', 'mod_pdfannotator');
85+
$data->pixexportpdf = $OUTPUT->image_url('export_pdf', 'mod_pdfannotator');
86+
$data->pixexportcsv = $OUTPUT->image_url('export_csv', 'mod_pdfannotator');
8487

8588
return $data;
8689
}

controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@
465465
$stringman = get_string_manager();
466466
$strings = $stringman->load_component_strings('pdfannotator', 'en'); // Method gets the strings of the language files.
467467
$PAGE->requires->strings_for_js(array_keys($strings), 'pdfannotator'); // Method to use the language-strings in javascript.
468-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00002"));
468+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00008"));
469469
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/statistic.js?ver=0004"));
470470
$myrenderer = $PAGE->get_renderer('mod_pdfannotator');
471471
$capabilities = new stdClass();

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Ahmad Obeid
2121
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2222
*/
23-
require_once('../../config.php');
23+
//require_once('../../config.php');
2424
require_once('locallib.php');
2525

2626
$id = required_param('id', PARAM_INT); // Course ID.

lang/en/pdfannotator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
$string['comment'] = 'Comment';
6767
$string['commentDeleted'] = 'Comment has been deleted';
6868
$string['comments'] = 'Comments';
69+
// Annotation separation.
70+
$string['comments_icon_private'] = 'This comment is private';
71+
$string['comments_icon_public'] = 'This comment is public';
72+
$string['comments_text_all'] = 'Show all comments';
73+
$string['comments_text_private'] = 'Only show private comments (orange)';
74+
$string['comments_text_public'] = 'Only show public comments (blue)';
6975
$string['configmaxbytes'] = 'Maximum file size';
7076
$string['correct'] = 'correct';
7177
$string['count'] = 'count';
@@ -138,7 +144,10 @@
138144
$string['error:voteComment'] = 'An error has occurred while saving the vote.';
139145
$string['error'] = 'Error!';
140146
$string['eventreport_added'] = 'A comment was reported';
141-
147+
$string['export_comments_csv'] = 'Export as CSV';
148+
$string['export_comments_csv_tooltip'] = 'Download comments as CSV file';
149+
$string['export_comments_pdf'] = 'Export as PDF';
150+
$string['export_comments_pdf_tooltip'] = 'Download comments as PDF file';
142151
$string['filenotfound'] = 'File not found, sorry.';
143152
$string['forward'] = 'Forward';
144153
$string['forwardedquestionhtml'] = '{$a->sender} forwarded the following question to you: <br /> <br />

lib.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ function pdfannotator_pluginfile($course, $cm, $context, $filearea, $args, $forc
426426
array_shift($args);
427427
$relativepath = implode('/', $args);
428428
$fullpath = rtrim("/$context->id/mod_pdfannotator/$filearea/$commentid/$relativepath", '/');
429-
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) || $file->is_directory()) {
429+
$file = $fs->get_file_by_hash(sha1($fullpath));
430+
if (!$file || $file->is_directory()) {
430431
// Annotations from other documents might have another contextid.
431432
$pdfid = $DB->get_record('pdfannotator_comments', ['id' => $commentid], 'pdfannotatorid');
432433
if ($pdfid) {

locallib.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
6666
// Load and execute the javascript files.
6767
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
6868
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
69-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00039"));
70-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00006"));
69+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00043"));
70+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00008"));
7171

7272
// Pass parameters from PHP to JavaScript.
7373

@@ -328,7 +328,7 @@ function pdfannotator_data_preprocessing($context, $textarea, $draftitemid = 0)
328328
* Same function as core, however we need to add files into the existing draft area!
329329
* Copied from hsuforum.
330330
*/
331-
function pdfannotator_file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null) {
331+
function pdfannotator_file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, ?array $options=null, ?string $text=null) {
332332
global $CFG, $USER, $CFG, $DB;
333333

334334
$options = (array)$options;
@@ -869,7 +869,7 @@ function pdfannotator_set_mainfile($data) {
869869
}
870870
}
871871

872-
function pdfannotator_render_listitem_actions(array $actions = null) {
872+
function pdfannotator_render_listitem_actions(?array $actions = null) {
873873
$menu = new action_menu();
874874
$menu->attributes['class'] .= ' course-item-actions item-actions';
875875
$hasitems = false;
@@ -984,8 +984,8 @@ function pdfannotator_prepare_overviewpage($cmid, $myrenderer, $taburl, $action,
984984
$strings = $stringman->load_component_strings('pdfannotator', 'en'); // Method gets the strings of the language files.
985985
$PAGE->requires->strings_for_js(array_keys($strings), 'pdfannotator'); // Method to use the language-strings in javascript.
986986
// 1.3 Add the javascript file that determines the dynamic behaviour of the page.
987-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00002"));
988-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/overview.js?ver=00002"));
987+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00008"));
988+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/overview.js?ver=00004"));
989989

990990
// 1.4 Check user capabilities to view the different categories.
991991
// The argument 'false' disregards administrator's magical 'doanything' power.

pix/comments_all.svg

Lines changed: 23 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)