Upload PDF Feedback (built-in) - Quicklist Comments Sort UploadPDF

Upload PDF Feedback (built-in) - Quicklist Comments Sort UploadPDF

by Andrew C -
Number of replies: 2

Hi Everyone,

Lecturers have asked if the built-in (not the plugin) Annotate/Upload PDF quicklist comments can be sorted by alphabetical order inside the Moodle assignments area under Annotate PDF.

I've made a few general changes (such as setting the comment boxes and font size to fit in default Word margins) but am struggling here since JavaScript is not one of my strong points.

I've looked in file moodle-assignfeedback_editpdf-editor-min.js


At section:

;this.load=function(){var t=n,r;r={method:"get",context:this,sync:false,data:{sesskey:M.cfg.sesskey,action:"loadquicklist",userid:this.editor.get("userid"),attemptnumber:this.editor.get("attemptnumber"),assignmentid:this.editor.get("assignmentid")},on:{success:function(t,n){var r;try{r=e.JSON.parse(n.responseText);if(r.error){return new M.core.ajaxException(r)}else{e.each(r,function(e){var t=new M.assignfeedback_editpdf.quickcomment(e.id,e.rawtext,e.width,e.colour); quickcomment.sort(function(a,b){return b - a;});this.comments.push(t)},this)}}catch(i){return new M.core.exception(i)}},failure:function(e,t){return M.core.exception(t.responseText)}}};e.io(t,r)}};

and tried the following:

M.assignfeedback_editpdf.quickcomment.sort() to check to see if it was an array. No luck - it's an object.

"Object doesn't support property or method 'sort'"

Swapped e.id and e.rawtext. e.id is displayed indicating second property (text) is selected.


Any ideas?

Thanks,

Andrew (Moodle 2.6)

Average of ratings: -
In reply to Andrew C

Re: Upload PDF Feedback (built-in) - Quicklist Comments Sort UploadPDF

by Andrew C -

Looking at my code - I can see that I left a botched attempt in there.


;this.load=function(){var t=n,r;r={method:"get",context:this,sync:false,data:{sesskey:M.cfg.sesskey,action:"loadquicklist",userid:this.editor.get("userid"),attemptnumber:this.editor.get("attemptnumber"),assignmentid:this.editor.get("assignmentid")},on:{success:function(t,n){var r;try{r=e.JSON.parse(n.responseText);if(r.error){return new M.core.ajaxException(r)}else{e.each(r,function(e){var t=new M.assignfeedback_editpdf.quickcomment(e.id,e.rawtext,e.width,e.colour);;this.comments.push(t)},this)}}catch(i){return new M.core.exception(i)}},failure:function(e,t){return M.core.exception(t.responseText)}}};e.io(t,r)}};

In reply to Andrew C

Re: Upload PDF Feedback (built-in) - Quicklist Comments Sort UploadPDF

by Andrew C -

Hi Everyone,

Davo helpfully mentioned that I've been looking in the wrong place (I've been looking in the JavaScript) and suggested I look inside the PHP.

After a quick look around, I found the PHP in the www\mod\assign\feedback\editpdf\classes

under comments_quick_list.php

and found the solution by adding in the following PHP:

usort($records, function($a, $b) {return strcasecmp($a->rawtext, $b->rawtext);});

after line 45

to make the Quicklist display in alphabetical order instead of creation date.

Thanks for the information Davo. I'm a lot better with PHP than JavaScript wink

Andrew