diff --git a/mod/assign/feedback/editpdf/classes/document_services.php b/mod/assign/feedback/editpdf/classes/document_services.php index 4acef8065633b..3117df09663a1 100644 --- a/mod/assign/feedback/editpdf/classes/document_services.php +++ b/mod/assign/feedback/editpdf/classes/document_services.php @@ -380,7 +380,25 @@ public static function get_page_images_for_attempt($assignment, $userid, $attemp // Image files are stale - regenerate them. $files = array(); } else { - return $files; + + // Need to reorder the files following their name. + // because get_directory_files() return a different order than generate_page_images_for_attempt(). + $orderedfiles = array(); + foreach($files as $file) { + // Extract the page number from the file name image_pageXXXX.png. + preg_match('/page([\d]+)\./', $file->get_filename(), $matches); + if (empty($matches) or !is_numeric($matches[1])) { + throw new \coding_exception("'" . $file->get_filename() + . "' file hasn't the expected format filename: image_pageXXXX.png."); + } + $pagenumber = (int)$matches[1]; + + // Save the page in the ordered array. + $orderedfiles[$pagenumber] = $file; + } + ksort($orderedfiles); + + return $orderedfiles; } } return self::generate_page_images_for_attempt($assignment, $userid, $attemptnumber); diff --git a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js index 6c06f8a7d1f3e..6babd9b1b3d16 100644 --- a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js +++ b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js @@ -3127,11 +3127,11 @@ EDITOR.prototype = { this.refresh_button_state(); } + + this.load_all_pages(); } this.dialogue.centerDialogue(); this.dialogue.show(); - - this.load_all_pages(); }, /** diff --git a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js index 6d8957984bfe3..b075022ea2bd6 100644 --- a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js +++ b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js @@ -3,5 +3,5 @@ assignfeedback_editpdf||{},M.assignfeedback_editpdf.annotation=ANNOTATION,ANNOTA .x,t.end.y)]),s=l[t.annotationcolour],s=s.replace("rgb","rgba"),s=s.replace(")",",0.5)"),r=this.editor.graphic.addShape({type:e.Rect,width:i.width,height:16,stroke:!1,fill:{color:s},x:i.x,y:t.start.y}),n.shapes.push(r),n},init_from_edit:function(e){var t=new M.assignfeedback_editpdf.rect;t.bound([e.start,e.end]),this.gradeid=this.editor.get("gradeid"),this.pageno=this.editor.currentpage,this.x=t.x,this.y=e.start.y,this.endx=t.x+t.width,this.endy=e.start.y+16,this.colour=e.annotationcolour,this.page=""}}),M.assignfeedback_editpdf=M.assignfeedback_editpdf||{},M.assignfeedback_editpdf.annotationhighlight=ANNOTATIONHIGHLIGHT,ANNOTATIONSTAMP=function(e){ANNOTATIONSTAMP.superclass.constructor.apply(this,[e])},ANNOTATIONSTAMP.NAME="annotationstamp",ANNOTATIONSTAMP.ATTRS={},e.extend(ANNOTATIONSTAMP,M.assignfeedback_editpdf.annotation,{draw:function(){var t=new M.assignfeedback_editpdf.drawable(this.editor),n=e.one(o.DRAWINGREGION),r,i;return i=this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x,this.y)),r=e.Node.create("
"),r.setStyles({position:"absolute",display:"inline-block",backgroundImage:"url("+this.editor.get_stamp_image_url(this.path)+")",width:this.endx-this.x,height:this.endy-this.y,backgroundSize:"100% 100%",zIndex:50}),n.append(r),r.setX(i.x),r.setY(i.y),r.on("gesturemovestart",this.editor.edit_start,null,this.editor),r.on("gesturemove",this.editor.edit_move,null,this.editor),r.on("gesturemoveend",this.editor.edit_end,null,this.editor),t.nodes.push(r),this.drawable=t,ANNOTATIONSTAMP.superclass.draw.apply(this)},draw_current_edit:function(t){var n=new M.assignfeedback_editpdf.rect,r=new M.assignfeedback_editpdf.drawable(this.editor),i=e.one(o.DRAWINGREGION),s,u;return n.bound([t.start,t.end]),u=this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(n.x,n.y)),s=e.Node.create("
"),s.setStyles({position:"absolute",display:"inline-block",backgroundImage:"url("+this.editor.get_stamp_image_url(t.stamp)+")",width:n.width,height:n.height,backgroundSize:"100% 100%",zIndex:50}),i.append(s),s.setX(u.x),s.setY(u.y),r.nodes.push(s),r},init_from_edit:function(e){var t=new M.assignfeedback_editpdf.rect;t.bound([e.start,e.end]),t.width<40&&(t.width=40),t.height<40&&(t.height=40),this.gradeid=this.editor.get("gradeid"),this.pageno=this.editor.currentpage,this.x=t.x,this.y=t.y,this.endx=t.x+t.width,this.endy=t.y+t.height,this.colour=e.annotationcolour,this.path=e.stamp},move:function(e,t){var n=e-this.x,r=t-this.y;this.x+=n,this.y+=r,this.endx+=n,this.endy+=r,this.drawable&&this.drawable.erase(),this.editor.drawables.push(this.draw())}}),M.assignfeedback_editpdf=M.assignfeedback_editpdf||{},M.assignfeedback_editpdf.annotationstamp=ANNOTATIONSTAMP;var d="Dropdown menu",v;v=function(e){e.draggable=!1,e.centered=!1,e.width="auto",e.lightbox=!1,e.visible=!1,e.zIndex=100,e.footerContent="",v.superclass.constructor.apply(this,[e])},e.extend(v,M.core.dialogue,{initializer:function(t){var n,r,i,s;v.superclass.initializer.call(this,t),s=this.get("boundingBox"),s.addClass("assignfeedback_editpdf_dropdown"),n=this.get("buttonNode"),r=this.bodyNode,i=e.Node.create("

"),i.addClass("accesshide"),i.setHTML(this.get("headerText")),r.prepend(i),r.on("clickoutside",function(e){this.get("visible")&&e.target!==n&&e.target.ancestor()!==n&&(e.preventDefault(),this.hide())},this),n.on("click",function(e){e.preventDefault(),this.show()},this),n.on("key",this.show,"enter,space",this)},show:function(){var t=this.get("buttonNode");result=v.superclass.show.call(this),this.align(t,[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.BL])}},{NAME:d,ATTRS:{headerText:{value:""},buttonNode:{value:null}}}),M.assignfeedback_editpdf=M.assignfeedback_editpdf||{},M.assignfeedback_editpdf.dropdown=v;var m="Colourpicker",g;g=function(e){g.superclass.constructor.apply(this,[e])},e.extend(g,M.assignfeedback_editpdf.dropdown,{initializer:function(t){var n=e.Node.create('