diff --git a/mod/assign/feedback/editpdf/ajax.php b/mod/assign/feedback/editpdf/ajax.php
index 538d9204187..fa1e21db5f1 100644
--- a/mod/assign/feedback/editpdf/ajax.php
+++ b/mod/assign/feedback/editpdf/ajax.php
@@ -70,6 +70,7 @@ if ($action === 'pollconversions') {
'filecount' => 0,
'pagecount' => 0,
'pageready' => 0,
+ 'partial' => false,
'pages' => [],
];
@@ -77,10 +78,13 @@ if ($action === 'pollconversions') {
$response->status = $combineddocument->get_status();
$response->filecount = $combineddocument->get_document_count();
- if ($response->status === combined_document::STATUS_READY) {
+ $readystatuslist = [combined_document::STATUS_READY, combined_document::STATUS_READY_PARTIAL];
+ $completestatuslist = [combined_document::STATUS_COMPLETE, combined_document::STATUS_FAILED];
+
+ if (in_array($response->status, $readystatuslist)) {
$combineddocument = document_services::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
$response->pagecount = $combineddocument->get_page_count();
- } else if ($response->status === combined_document::STATUS_COMPLETE || $response->status === combined_document::STATUS_FAILED) {
+ } else if (in_array($response->status, $completestatuslist)) {
$pages = document_services::get_page_images_for_attempt($assignment,
$userid,
$attemptnumber,
@@ -95,6 +99,7 @@ if ($action === 'pollconversions') {
if ($readonly) {
$filearea = document_services::PAGE_IMAGE_READONLY_FILEAREA;
}
+ $response->partial = $combineddocument->is_partial_conversion();
foreach ($pages as $id => $pagefile) {
$index = count($response->pages);
diff --git a/mod/assign/feedback/editpdf/classes/combined_document.php b/mod/assign/feedback/editpdf/classes/combined_document.php
index c0d813c350b..d757599f191 100644
--- a/mod/assign/feedback/editpdf/classes/combined_document.php
+++ b/mod/assign/feedback/editpdf/classes/combined_document.php
@@ -44,6 +44,11 @@ class combined_document {
*/
const STATUS_READY = 1;
+ /**
+ * Status value representing all documents are ready to be combined as are supported.
+ */
+ const STATUS_READY_PARTIAL = 3;
+
/**
* Status value representing a successful conversion.
*/
@@ -100,6 +105,7 @@ class combined_document {
}
$pending = false;
+ $partial = false;
foreach ($this->sourcefiles as $file) {
// The combined file has not yet been generated.
// Check the status of each source file.
@@ -110,12 +116,20 @@ class combined_document {
case \core_files\conversion::STATUS_PENDING:
$pending = true;
break;
+
+ // There are 4 status flags, so the only remaining one is complete which is fine.
+ case \core_files\conversion::STATUS_FAILED:
+ $partial = true;
+ break;
}
}
}
if ($pending) {
return self::STATUS_PENDING_INPUT;
} else {
+ if ($partial) {
+ return self::STATUS_READY_PARTIAL;
+ }
return self::STATUS_READY;
}
}
@@ -131,6 +145,20 @@ class combined_document {
return $this;
}
+ /**
+ * Return true of the combined file contained only some of the submission files.
+ *
+ * @return boolean
+ */
+ public function is_partial_conversion() {
+ $combinedfile = $this->get_combined_file();
+ if (empty($combinedfile)) {
+ return false;
+ }
+ $filearea = $combinedfile->get_filearea();
+ return $filearea == document_services::PARTIAL_PDF_FILEAREA;
+ }
+
/**
* Retrieve the completed combined file.
*
@@ -210,11 +238,12 @@ class combined_document {
global $CFG;
$currentstatus = $this->get_status();
+ $readystatuslist = [self::STATUS_READY, self::STATUS_READY_PARTIAL];
if ($currentstatus === self::STATUS_FAILED) {
$this->store_empty_document($contextid, $itemid);
return $this;
- } else if ($currentstatus !== self::STATUS_READY) {
+ } else if (!in_array($currentstatus, $readystatuslist)) {
// The document is either:
// * already combined; or
// * pending input being fully converted; or
@@ -273,7 +302,7 @@ class combined_document {
}
// Store the newly created file as a stored_file.
- $this->store_combined_file($tmpfile, $contextid, $itemid);
+ $this->store_combined_file($tmpfile, $contextid, $itemid, ($currentstatus == self::STATUS_READY_PARTIAL));
// Note the verified page count.
$this->pagecount = $verifypagecount;
@@ -298,11 +327,12 @@ class combined_document {
* @param string $tmpfile The path to the file on disk to be stored.
* @param int $contextid The contextid for the file to be stored under
* @param int $itemid The itemid for the file to be stored under
+ * @param boolean $partial The combined pdf contains only some of the source files.
* @return $this
*/
- protected function store_combined_file($tmpfile, $contextid, $itemid) {
+ protected function store_combined_file($tmpfile, $contextid, $itemid, $partial = false) {
// Store the file.
- $record = $this->get_stored_file_record($contextid, $itemid);
+ $record = $this->get_stored_file_record($contextid, $itemid, $partial);
$fs = get_file_storage();
// Delete existing files first.
@@ -352,12 +382,14 @@ class combined_document {
return $this->pagecount;
}
- if ($this->get_status() === self::STATUS_FAILED) {
+ $status = $this->get_status();
+
+ if ($status === self::STATUS_FAILED) {
// The empty document will be returned.
return 1;
}
- if ($this->get_status() !== self::STATUS_COMPLETE) {
+ if ($status !== self::STATUS_COMPLETE) {
// No pages yet.
return 0;
}
@@ -394,13 +426,18 @@ class combined_document {
*
* @param int $contextid The contextid for the file to be stored under
* @param int $itemid The itemid for the file to be stored under
+ * @param boolean $partial The combined file contains only some of the source files.
* @return stdClass
*/
- protected function get_stored_file_record($contextid, $itemid) {
+ protected function get_stored_file_record($contextid, $itemid, $partial = false) {
+ $filearea = document_services::COMBINED_PDF_FILEAREA;
+ if ($partial) {
+ $filearea = document_services::PARTIAL_PDF_FILEAREA;
+ }
return (object) [
'contextid' => $contextid,
'component' => 'assignfeedback_editpdf',
- 'filearea' => document_services::COMBINED_PDF_FILEAREA,
+ 'filearea' => $filearea,
'itemid' => $itemid,
'filepath' => '/',
'filename' => document_services::COMBINED_PDF_FILENAME,
diff --git a/mod/assign/feedback/editpdf/classes/document_services.php b/mod/assign/feedback/editpdf/classes/document_services.php
index 384ccdd2bdd..45b4083f18f 100644
--- a/mod/assign/feedback/editpdf/classes/document_services.php
+++ b/mod/assign/feedback/editpdf/classes/document_services.php
@@ -42,6 +42,8 @@ class document_services {
const FINAL_PDF_FILEAREA = 'download';
/** File area for combined pdf */
const COMBINED_PDF_FILEAREA = 'combined';
+ /** File area for partial combined pdf */
+ const PARTIAL_PDF_FILEAREA = 'partial';
/** File area for importing html */
const IMPORT_HTML_FILEAREA = 'importhtml';
/** File area for page images */
@@ -261,15 +263,23 @@ EOD;
$submission = $assignment->get_user_submission($userid, false, $attemptnumber);
}
+
$contextid = $assignment->get_context()->id;
$component = 'assignfeedback_editpdf';
$filearea = self::COMBINED_PDF_FILEAREA;
+ $partialfilearea = self::PARTIAL_PDF_FILEAREA;
$itemid = $grade->id;
$filepath = '/';
$filename = self::COMBINED_PDF_FILENAME;
$fs = get_file_storage();
- $combinedpdf = $fs->get_file($contextid, $component, $filearea, $itemid, $filepath, $filename);
+ $partialpdf = $fs->get_file($contextid, $component, $partialfilearea, $itemid, $filepath, $filename);
+ if (!empty($partialpdf)) {
+ $combinedpdf = $partialpdf;
+ } else {
+ $combinedpdf = $fs->get_file($contextid, $component, $filearea, $itemid, $filepath, $filename);
+ }
+
if ($combinedpdf && $submission) {
if ($combinedpdf->get_timemodified() < $submission->timemodified) {
// The submission has been updated since the PDF was generated.
@@ -381,6 +391,7 @@ EOD;
$tmpdir = \make_temp_directory('assignfeedback_editpdf/pageimages/' . self::hash($assignment, $userid, $attemptnumber));
$combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
+
$document->get_combined_file()->copy_content_to($combined); // Copy the file.
$pdf = new pdf();
diff --git a/mod/assign/feedback/editpdf/classes/renderer.php b/mod/assign/feedback/editpdf/classes/renderer.php
index 882fdc4d727..2d5ae5a4ce2 100644
--- a/mod/assign/feedback/editpdf/classes/renderer.php
+++ b/mod/assign/feedback/editpdf/classes/renderer.php
@@ -268,7 +268,8 @@ class assignfeedback_editpdf_renderer extends plugin_renderer_base {
'stamp',
'stamppicker',
'cannotopenpdf',
- 'pagenumber'
+ 'pagenumber',
+ 'partialwarning'
), 'assignfeedback_editpdf');
return $html;
diff --git a/mod/assign/feedback/editpdf/classes/task/convert_submissions.php b/mod/assign/feedback/editpdf/classes/task/convert_submissions.php
index 68295fd840e..be6b0a14146 100644
--- a/mod/assign/feedback/editpdf/classes/task/convert_submissions.php
+++ b/mod/assign/feedback/editpdf/classes/task/convert_submissions.php
@@ -102,10 +102,9 @@ class convert_submissions extends scheduled_task {
foreach ($users as $userid) {
try {
$combineddocument = document_services::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
- $status = $combineddocument->get_status();
-
switch ($combineddocument->get_status()) {
case combined_document::STATUS_READY:
+ case combined_document::STATUS_READY_PARTIAL:
case combined_document::STATUS_PENDING_INPUT:
// The document has not been converted yet or is somehow still ready.
continue 2;
diff --git a/mod/assign/feedback/editpdf/lang/en/assignfeedback_editpdf.php b/mod/assign/feedback/editpdf/lang/en/assignfeedback_editpdf.php
index 0dbffbacd65..a8f7c0ee520 100644
--- a/mod/assign/feedback/editpdf/lang/en/assignfeedback_editpdf.php
+++ b/mod/assign/feedback/editpdf/lang/en/assignfeedback_editpdf.php
@@ -72,6 +72,7 @@ $string['output'] = 'Output:';
$string['pagenumber'] = 'Page {$a}';
$string['pagexofy'] = 'Page {$a->page} of {$a->total}';
$string['pen'] = 'Pen';
+$string['partialwarning'] = 'Some of the submission files must be downloaded.';
$string['pluginname'] = 'Annotate PDF';
$string['privacy:metadata:colourpurpose'] = 'Colour of the comment or annotation';
$string['privacy:metadata:conversionpurpose'] = 'Files are converted to PDFs to allow for annotations.';
diff --git a/mod/assign/feedback/editpdf/styles.css b/mod/assign/feedback/editpdf/styles.css
index 844c9436eac..bae19d98a19 100644
--- a/mod/assign/feedback/editpdf/styles.css
+++ b/mod/assign/feedback/editpdf/styles.css
@@ -67,7 +67,7 @@
display: none;
position: absolute;
left: 20px;
- top: 60px;
+ top: 120px;
}
.yui3-colourpicker-hidden,
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 bea07f58bb8..e09ac6c9ead 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
@@ -3829,6 +3829,21 @@ EDITOR.prototype = {
});
},
+ /**
+ * Display an error in a small part of the page (don't block everything).
+ *
+ * @param string The error text.
+ * @protected
+ * @method warning
+ */
+ warning: function(message) {
+ var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
+
+ var warningelement = Y.Node.create('
');
+ warningelement.setHTML(message);
+ drawingregion.prepend(warningelement);
+ },
+
/**
* The info about all pages in the pdf has been returned.
*
@@ -3837,7 +3852,8 @@ EDITOR.prototype = {
* @method prepare_pages_for_display
*/
prepare_pages_for_display: function(data) {
- var i, j, comment, error;
+ var i, j, comment, error, annotation, readonly;
+
if (!data.pagecount) {
if (this.dialogue) {
this.dialogue.hide();
@@ -3863,11 +3879,17 @@ EDITOR.prototype = {
comment.rawtext);
}
for (j = 0; j < this.pages[i].annotations.length; j++) {
- data = this.pages[i].annotations[j];
- this.pages[i].annotations[j] = this.create_annotation(data.type, data);
+ annotation = this.pages[i].annotations[j];
+ this.pages[i].annotations[j] = this.create_annotation(annotation.type, annotation);
}
}
+ readonly = this.get('readonly');
+ if (!readonly && data.partial) {
+ // Warn about non converted files, but only for teachers.
+ this.warning(M.util.get_string('partialwarning', 'assignfeedback_editpdf'));
+ }
+
// Update the ui.
if (this.quicklist) {
this.quicklist.load();
@@ -4817,6 +4839,7 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
"querystring-stringify-simple",
"moodle-core-notification-dialog",
"moodle-core-notification-alert",
+ "moodle-core-notification-warning",
"moodle-core-notification-exception",
"moodle-core-notification-ajaxexception"
]
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 bb0f77debe2..2a72d8f964c 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
@@ -4,6 +4,6 @@ M.assignfeedback_editpdf.drawable(this.editor),r,i,s;return i=new M.assignfeedba
,this),n.delegate("key",this.callback_handler,"down:13","button",this),this.set("headerText",M.util.get_string("stamppicker","assignfeedback_editpdf")),this.set("bodyContent",n),O.superclass.initializer.call(this,t)},callback_handler:function(t){t.preventDefault();var n=this.get("callback"),r=this.get("context"),i;this.hide(),i=e.bind(n,r,t),i()}},{NAME:A,ATTRS:{stamps:{value:[]},callback:{value:null},context:{value:null}}}),M.assignfeedback_editpdf=M.assignfeedback_editpdf||{},M.assignfeedback_editpdf.stamppicker=O;var _="Commentmenu",D;D=function(e){D.superclass.constructor.apply(this,[e])},e.extend(D,M.assignfeedback_editpdf.dropdown,{initializer:function(t){var n,r,i,s;s=this.get("comment"),n=e.Node.create(''),r=e.Node.create(''+M.util.get_string("addtoquicklist","assignfeedback_editpdf")+""),r.on("click",s.add_to_quicklist,s),r.on("key",s.add_to_quicklist,"enter,space",s),n.append(r),r=e.Node.create(''+M.util.get_string("deletecomment","assignfeedback_editpdf")+""),r.on("click",function(e){e.preventDefault(),this.menu.hide(),this.remove()},s),r.on("key",function(){s.menu.hide(),s.remove()},"enter,space",s),n.append(r),r=e.Node.create("
"),n.append(r),this.set("headerText",M.util.get_string("commentcontextmenu","assignfeedback_editpdf")),i=e.Node.create(""),i.append(n),this.set("bodyContent",i),D.superclass.initializer.call(this,t)},show:function(){var t=this.get("boundingBox").one("ul");t.all(".quicklist_comment").remove(!0);var n=this.get("comment");n.deleteme=!1,e.each(n.editor.quicklist.comments,function(r){var i=e.Node.create(''),s=e.Node.create(''+r.rawtext+""),o=e.Node.create('");i.append(s),i.append(o),t.append(i),i.on("click",n.set_from_quick_comment,n,r),i.on("key",n.set_from_quick_comment,"space,enter",n,r),o.on("click",n.remove_from_quicklist,n,r),o.on("key",n.remove_from_quicklist,"space,enter",n,r)},this),D.superclass.show.call(this)}},{NAME:_,ATTRS:{comment:{value:null}}}),M.assignfeedback_editpdf=M.assignfeedback_editpdf||{},M.assignfeedback_editpdf.commentmenu=D;var P="commentsearch",H;H=function(e){e.draggable=!1,e.centered=!0,e.width="400px",e.visible=!1,e.headerContent=M.util.get_string("searchcomments","assignfeedback_editpdf"),e.footerContent="",H.superclass.constructor.apply(this,[e])},e.extend(H,M.core.dialogue,{initializer:function(t){var n,r,i,s,o,u;u=this.get("boundingBox"),u.addClass("assignfeedback_editpdf_commentsearch"),n=this.get("editor"),r=e.Node.create(""),i=M.util.get_string("filter","assignfeedback_editpdf"),s=e.Node.create(''),r.append(s),o=e.Node.create(''),r.append(o),s.on("keyup",this.filter_search_comments,this),o.delegate("click",this.focus_on_comment,"a",this),o.delegate("key",this.focus_on_comment,"enter,space","a",this),this.set("bodyContent",r),H.superclass.initializer.call(this,t)},filter_search_comments:function(){var t,n,r,i;i=this.get("id"),t=e.one("#"+i+s.SEARCHFILTER),n=e.one("#"+i+s.SEARCHCOMMENTSLIST),r=t.get("value"),n.all("li").each(function(e){e.get("text").indexOf(r)!==-1?e.show():e.hide()})},focus_on_comment:function(e){e.preventDefault();var t=e.target.ancestor("li"),n=t.getData("comment"),r=this.get("editor");this.hide(),n.pageno=n.clean().pageno,n.pageno!==r.currentpage&&(r.currentpage=n.pageno,r.change_page()),n.node=n.drawable.nodes[0].one("textarea"),n.node.ancestor("div").removeClass("commentcollapsed"),n.node.focus()},show:function(){var t=this.get("boundingBox").one("ul"),n=this.get("editor");t.all("li").remove(!0),e.each(n.pages,function(n){e.each(n.comments,function(n){var r=e.Node.create(''+n.rawtext+"
");t.append(r),r.setData("comment",n)},this)},this),this.centerDialogue(),H.superclass.show.call(this)}},{NAME:P,ATTRS:{editor:{value:null}}}),e.Base.modifyAttrs(H,{modal:{getter:function(){return!0}}}),M.assignfeedback_editpdf=M.assignfeedback_editpdf||{},M.assignfeedback_editpdf.commentsearch=H;var B=function(t,n,r,i,o,u,l,c){this.editor=t,this.gradeid=n||0,this.x=parseInt(i,10)||0,this.y=parseInt(o,10)||0,this.width=parseInt(u,10)||0,this.rawtext=c||"",this.pageno=r||0,this.colour=l||"yellow",this.drawable=!1,this.deleteme=!1,this.menulink=null,this.menu=null,this.clean=function(){return{gradeid:this.gradeid,x:parseInt(this.x,10),y:parseInt(this.y,10),width:parseInt(this.width,10),rawtext:this.rawtext,pageno:parseInt(this.pageno,10),colour:this.colour}},this.draw=function(n){var r=new M.assignfeedback_editpdf.drawable(this.editor),i,o=this.editor.get_dialogue_element(s.DRAWINGREGION),u,l,c,h,p,d;return i=e.Node.create(""),u=e.Node.create(''),l=e.Node.create(""),c=e.Node.create(''),h=e.Node.create('
'),this.menulink=h,u.append(l),l.append(i),u.append(c),u.setAttribute("tabindex","-1"),l.setAttribute("tabindex","0"),i.setAttribute("tabindex","-1"),h.setAttribute("tabindex","0"),this.editor.get("readonly")?i.setAttribute("readonly","readonly"):u.append(h),this.width<100&&(this.width=100),p=this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x,this.y)),i.setStyles({width:this.width+"px",backgroundColor:f[this.colour],color:a}),o.append(u),u.setStyle
("position","absolute"),u.setX(p.x),u.setY(p.y),r.store_position(u,p.x,p.y),r.nodes.push(u),i.set("value",this.rawtext),d=i.get("scrollHeight"),i.setStyles({height:d+"px",overflow:"hidden"}),c.setStyle("color",f[this.colour]),this.attach_events(i,h),n?i.focus():t.collapsecomments&&u.addClass("commentcollapsed"),this.drawable=r,r},this.delete_comment_later=function(){this.deleteme&&this.remove()},this.attach_events=function(n,r){var i=n.ancestor("div"),s=n.ancestor("label"),o=s.next("svg");n.collapse=function(r){n.collapse.delay=e.later(r,n,function(){t.collapsecomments&&i.addClass("commentcollapsed")})},n.expand=function(){n.getData("dragging")!==!0&&(n.collapse.delay&&n.collapse.delay.cancel(),i.removeClass("commentcollapsed"))},i.on("mouseenter",function(){(t.currentedit.tool==="comment"||t.currentedit.tool==="select"||this.editor.get("readonly"))&&n.expand()},this),i.on("click|tap",function(){n.expand(),n.focus()},this),n.on("keyup",function(e){e.keyCode===9&&e.shiftKey&&r.getAttribute("tabindex")==="0"&&r.focus(),r.setAttribute("tabindex","0")},this),r.on("keydown",function(e){e.keyCode===9&&e.shiftKey&&r.setAttribute("tabindex","-1")},this),s.on("focus",function(){n.active=!0,n.collapse.delay&&n.collapse.delay.cancel(),n.setAttribute("tabindex","0"),n.expand(),n.focus(),s.setAttribute("tabindex","-1")},this),r.on("focus",function(){n.active=!0,n.collapse.delay&&n.collapse.delay.cancel(),this.deleteme=!1,s.setAttribute("tabindex","0")},this),n.on("blur",function(){n.setAttribute("tabindex","-1")},this),s.on("blur",function(){s.setAttribute("tabindex","0")},this),i.on("mouseleave",function(){t.collapsecomments&&n.active!==!0&&n.collapse(400)},this),i.on("blur",function(){n.active=!1,n.collapse(800)},this),this.editor.get("readonly")||(n.on("blur",function(){this.rawtext=n.get("value"),this.width=parseInt(n.getStyle("width"),10),this.rawtext.replace(/^\s+|\s+$/g,"")===""&&(this.deleteme=!0,e.later(400,this,this.delete_comment_later)),this.editor.save_current_page(),this.editor.editingcomment=!1},this),r.setData("comment",this),n.on("keyup",function(){n.setStyle("height","auto");var e=n.get("scrollHeight"),t=parseInt(n.getStyle("height"),10);e===t+8&&(e-=8),n.setStyle("height",e+"px")}),n.on("gesturemovestart",function(e){t.currentedit.tool==="select"&&(e.preventDefault(),t.collapsecomments?(n.setData("offsetx",8),n.setData("offsety",8)):(n.setData("offsetx",e.clientX-i.getX()),n.setData("offsety",e.clientY-i.getY())))}),n.on("gesturemove",function(e){if(t.currentedit.tool==="select"){var r=e.clientX-n.getData("offsetx"),s=e.clientY-n.getData("offsety"),o,u,a;n.getData("dragging")!==!0&&(n.collapse(0),n.setData("dragging",!0)),o=this.editor.get_canvas_coordinates(new M.assignfeedback_editpdf.point(r,s)),a=this.editor.get_canvas_bounds(!0),a.x=0,a.y=0,a.width-=24,a.height-=24,o.clip(a),this.x=o.x,this.y=o.y,u=this.editor.get_window_coordinates(o),i.setX(u.x),i.setY(u.y),this.drawable.store_position(i,u.x,u.y)}},null,this),n.on("gesturemoveend",function(){t.currentedit.tool==="select"&&(n.getData("dragging")===!0&&n.setData("dragging",!1),this.editor.save_current_page())},null,this),o.on("gesturemovestart",function(e){t.currentedit.tool==="select"&&(e.preventDefault(),n.setData("offsetx",e.clientX-i.getX()),n.setData("offsety",e.clientY-i.getY()),n.expand())}),o.on("gesturemove",function(e){if(t.currentedit.tool==="select"){var r=e.clientX-n.getData("offsetx"),s=e.clientY-n.getData("offsety"),o,u,a;n.getData("dragging")!==!0&&(n.collapse(100),n.setData("dragging",!0)),o=this.editor.get_canvas_coordinates(new M.assignfeedback_editpdf.point(r,s)),a=this.editor.get_canvas_bounds(!0),a.x=0,a.y=0,a.width-=24,a.height-=24,o.clip(a),this.x=o.x,this.y=o.y,u=this.editor.get_window_coordinates(o),i.setX(u.x),i.setY(u.y),this.drawable.store_position(i,u.x,u.y)}},null,this),o.on("gesturemoveend",function(){t.currentedit.tool==="select"&&(n.getData("dragging")===!0&&n.setData("dragging",!1),this.editor.save_current_page())},null,this),this.menu=new M.assignfeedback_editpdf.commentmenu({buttonNode:this.menulink,comment:this}))},this.remove=function(){var e=0,t;t=this.editor.pages[this.editor.currentpage].comments;for(e=0;e=0&&this.comments.splice(e,1)},failure:function(e,t){return M.core.exception(t.responseText)}}},e.io(r,i)},this.load=function(){var t=n,r;r={method:"get",context:this,sync:!1,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);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),this.comments.sort(function(e,t){return e.rawtext.localeCompare(t.rawtext)})}catch(i){return new M.core.exception(i)}},failure:function(e,t){return M.core.exception(t.responseText)}}},e.io(t,r)}};M.assignfeedback_editpdf=M.assignfeedback_editpdf||{},M.assignfeedback_editpdf.quickcommentlist=F;var I=function(){I.superclass.constructor.apply(this,arguments)};I.prototype={dialogue:null,panel:null,pagecount:0,currentpage:0,pages:[],documentstatus:0,loadingicon:null,pageimage:null,graphic:null,currentedit:new M.assignfeedback_editpdf.edit,currentdrawable:!1,drawables:[],currentcomment:null,currentannotation:null,lastannotation:null,lastannotationtool:"pen",quicklist:null,searchcommentswindow:null,currentstamp:null,stamps:[],editingcomment:!1,collapsecomments:!0,initializer:function(){var t;t=e.one("#"+this.get("linkid")),t&&(t.on("click",this.link_handler,this),t.on("key",this.link_handler,"down:13",this),require(["mod_assign/grading_review_panel"],function(n){var r=new n,i=r.getReviewPanel("assignfeedback_editpdf");i&&(i=e.one(i),i.empty(),t.ancestor(".fitem").hide(),this.open_in_panel(i)),this.currentedit.start=!1,this.currentedit.end=!1,this.get("readonly")||(this.quicklist=new M.assignfeedback_editpdf.quickcommentlist(this))}.bind(this)))},refresh_button_state:function(){var e,t,n,r,i,o;e=this.get_dialogue_element(s.COMMENTCOLOURBUTTON),n=M.util.image_url("background_colour_"+this.currentedit.commentcolour,"assignfeedback_editpdf"),e.one("img").setAttribute("src",n),this.currentedit.commentcolour==="clear"?e.one("img").setStyle("borderStyle","dashed"):e.one("img").setStyle("borderStyle","solid"),e=this.get_dialogue_element(s.ANNOTATIONCOLOURBUTTON),n=M.util.image_url("colour_"+this.currentedit.annotationcolour,"assignfeedback_editpdf"),e.one("img").setAttribute("src",n),t=this.get_dialogue_element(h[this.currentedit.tool]),t.addClass("assignfeedback_editpdf_selectedbutton"),t.setAttribute("aria-pressed","true"),r=this.get_dialogue_element(s.DRAWINGREGION),r.setAttribute("data-currenttool",this.currentedit.tool),e=this.get_dialogue_element(s.STAMPSBUTTON),i=this.get_stamp_image_url(this.currentedit.stamp),e.one("img").setAttrs({src:i,height:"16",width:"16"}),o=this.get_dialogue_element(s.DRAWINGCANVAS);switch(this.currentedit.tool){case"drag":o.setStyle("cursor","move");break;case"highlight":o.setStyle("cursor","text");break;case"select":o.setStyle("cursor","default");break;case"stamp":o.setStyle("cursor","url("+i+"), crosshair");break;default:o.setStyle("cursor","crosshair")}},get_canvas_bounds:function(){var e=this.get_dialogue_element(s.DRAWINGCANVAS),t=e.getXY(),n=t[0],r=t[1],i=parseInt(e.getStyle("width"),10),o=parseInt(e.getStyle("height"),10);return new M.assignfeedback_editpdf.rect(n,r,i,o)},get_canvas_coordinates:function(e){var t=this.get_canvas_bounds(),n=new M.assignfeedback_editpdf.point(e.x-t.x,e.y-t.y);return t.x=t.y=0,n.clip(t),n},get_window_coordinates:function(e){var t=this.get_canvas_bounds(),n=new M.assignfeedback_editpdf.point(e.x+t.x,e.y+t.y);return n},open_in_panel:function(t){var n,r;this.panel=t,t.append(this.get("body")),t.addClass(i.DIALOGUE),this.loadingicon=this.get_dialogue_element(s.LOADINGICON),n=this.get_dialogue_element(s.DRAWINGCANVAS),this.graphic=new e.Graphic({render:n}),r=this.get_dialogue_element(s.DRAWINGREGION),r.on("scroll",this.move_canvas,this),this.get("readonly")||(n.on("gesturemovestart",this.edit_start,null,this),n.on("gesturemove",this.edit_move,null,this),n.on("gesturemoveend",this.edit_end,null,this),this.refresh_button_state()),this.start_generation()},link_handler:function(t){var n,r,o=!0;t.preventDefault(),this.dialogue||(this.dialogue=new M.core.dialogue({headerContent:this.get("header"),bodyContent:this.get("body"),footerContent:this.get("footer"),modal:!0,width:"840px",visible:!1,draggable:!0}),this.dialogue.get("boundingBox").addClass(i.DIALOGUE),this.loadingicon=this.get_dialogue_element(s.LOADINGICON),n=this.get_dialogue_element(s.DRAWINGCANVAS),this.graphic=new e.Graphic({render:n}),r=this.get_dialogue_element(s.DRAWINGREGION),r.on("scroll",this.move_canvas,this),this.get("readonly")||(n.on("gesturemovestart",this.edit_start,null,this),n.on("gesturemove",this.edit_move,null,this),n.on("gesturemoveend",this.edit_end,null,this),this.refresh_button_state()),this.start_generation(),n.on("windowresize",this.resize,this),o=!1),this.dialogue.centerDialogue(),this.dialogue.show(),this.dialogue.dd.on("drag:end",this.redraw,this),o&&this.resize()},start_generation:function(){
-this.poll_document_conversion_status()},poll_document_conversion_status:function(){if(this.get("destroyed"))return;e.io(n,{method:"get",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"pollconversions",userid:this.get("userid"),attemptnumber:this.get("attemptnumber"),assignmentid:this.get("assignmentid"),readonly:this.get("readonly")?1:0},on:{success:function(t,n){var r=this.handle_response_data(n),i=!1;if(r){this.documentstatus=r.status;if(r.status===0)i=!0;else if(r.status===1)i=!0;else if(r.status===2||r.status===-1)this.pagecount=r.pagecount,r.pageready==r.pagecount?this.prepare_pages_for_display(r):(this.update_page_load_progress(),this.start_document_to_image_conversion());i&&e.later(1e3,this,this.poll_document_conversion_status)}},failure:function(e,t){return new M.core.exception(t.responseText)}}})},start_document_to_image_conversion:function(){if(this.get("destroyed"))return;e.io(n,{method:"get",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"pollconversions",userid:this.get("userid"),attemptnumber:this.get("attemptnumber"),assignmentid:this.get("assignmentid"),readonly:this.get("readonly")?1:0},on:{success:function(e,t){var n=this.handle_response_data(t);n&&(this.documentstatus=n.status,n.status===2&&this.prepare_pages_for_display(n))},failure:function(e,t){return new M.core.exception(t.responseText)}}})},prepare_pages_for_display:function(e){var t,n,r,i;if(!e.pagecount){this.dialogue&&this.dialogue.hide(),i=new M.core.alert({message:M.util.get_string("cannotopenpdf","assignfeedback_editpdf")}),i.show();return}this.pages=e.pages;for(t=0;t0&&(r=e)},this),r},setup_toolbar:function(){var t,n,r,i,o,u,a,c,p;i=this.get_dialogue_element(s.SEARCHCOMMENTSBUTTON),i.on("click",this.open_search_comments,this),i.on("key",this.open_search_comments,"down:13",this),o=this.get_dialogue_element(s.EXPCOLCOMMENTSBUTTON),o.on("click",this.expandCollapseComments,this),o.on("key",this.expandCollapseComments,"down:13",this);if(this.get("readonly"))return;this.disable_touch_scroll(),e.each(h,function(e,n){t=this.get_dialogue_element(e),t.on("click",this.handle_tool_button,this,n),t.on("key",this.handle_tool_button,"down:13",this,n),t.setAttribute("aria-pressed","false")},this),n=this.get_dialogue_element(s.COMMENTCOLOURBUTTON),c=new M.assignfeedback_editpdf.colourpicker({buttonNode:n,colours:f,iconprefix:"background_colour_",callback:function(e){var t=e.target.getAttribute("data-colour");t||(t=e.target.ancestor().getAttribute("data-colour")),this.currentedit.commentcolour=t,this.handle_tool_button(e,"comment")},context:this}),r=this.get_dialogue_element(s.ANNOTATIONCOLOURBUTTON),c=new M.assignfeedback_editpdf.colourpicker({buttonNode:r,iconprefix:"colour_",colours:l,callback:function(e){var t=e.target.getAttribute("data-colour");t||(t=e.target.ancestor().getAttribute("data-colour")),this.currentedit.annotationcolour=t,this.lastannotationtool?this.handle_tool_button(e,this.lastannotationtool):this.handle_tool_button(e,"pen")},context:this}),a=this.get("stampfiles"),a.length<=0?this.get_dialogue_element(h.stamp).ancestor().hide():(p=a[0].substr(a[0].lastIndexOf("/")+1),this.currentedit.stamp=p,u=this.get_dialogue_element(s.STAMPSBUTTON),c=new M.assignfeedback_editpdf.stamppicker({buttonNode:u,stamps:a,callback:function(e){var t=e.target.getAttribute("data-stamp"),n;t||(t=e.target.ancestor().getAttribute("data-stamp")),n=t.substr(t.lastIndexOf("/")),this.currentedit.stamp=n,this.handle_tool_button(e,"stamp")},context:this}),this.refresh_button_state())},handle_tool_button:function(e,t){var n;e.preventDefault(),n=this.get_dialogue_element(h[this.currentedit.tool]),n.removeClass("assignfeedback_editpdf_selectedbutton"),n.setAttribute("aria-pressed","false"),this.currentedit.tool=t,t!=="comment"&&t!=="select"&&t!=="drag"&&t!=="stamp"&&(this.lastannotationtool=t),this.refresh_button_state()},stringify_current_page
-:function(){var t=[],n=[],r,i=0;for(i=0;it.width||o.y<0||o.y>t.height)return;this.currentedit.tool==="pen"&&this.currentedit.path.push(o),this.currentedit.tool==="select"?this.currentannotation&&this.currentedit&&this.currentannotation.move(this.currentedit.annotationstart.x+o.x-this.currentedit.start.x,this.currentedit.annotationstart.y+o.y-this.currentedit.start.y):this.currentedit.tool==="drag"?(u=o.x-this.currentedit.start.x,a=o.y-this.currentedit.start.y,r.getDOMNode().scrollLeft-=u,r.getDOMNode().scrollTop-=a):this.currentedit.start&&(this.currentedit.end=o,this.redraw_current_edit())},edit_end:function(){var e,t,n;e=(new Date).getTime()-this.currentedit.start;if(e0)this.drawables.pop().erase();for(e=0;e0?n.removeAttribute("disabled"):n.setAttribute("disabled","true"),this.currentpage"),i.setAttribute("value",n),r={page:n+1,total:this.pages.length},i.setHTML(M.util.get_string("pagexofy","assignfeedback_editpdf",r)),t.append(i);t.removeAttribute("disabled"),t.on("change",function(){this.currentpage=t.get("value"),this.change_page()},this),o=this.get_dialogue_element(s.PREVIOUSBUTTON),u=this.get_dialogue_element(s.NEXTBUTTON),o.on("click",this.previous_page,this),o.on("key",this.previous_page,"down:13",this),u.on("click",this.next_page,this),u.on("key",this.next_page,"down:13",this)},previous_page:function(e){e.preventDefault(),this.currentpage--,this.currentpage<0&&(this.currentpage=0),this.change_page()},next_page:function(e){e.preventDefault(),this.currentpage++,this.currentpage>=this.pages.length&&(this.currentpage=this.pages.length-1),this.change_page()},move_canvas:function(){var e,t,n,r;e=this.get_dialogue_element(s.DRAWINGREGION),t=parseInt(e.get("scrollLeft"),10),n=parseInt(e.get("scrollTop"),10);for(r=0;r');r.setHTML(t),n.prepend(r)},prepare_pages_for_display:function(e){var t,n,r,i,s,o;if(!e.pagecount){this.dialogue&&this.dialogue.hide(),i=new M.core.alert({message:M.util.get_string("cannotopenpdf","assignfeedback_editpdf")}),i.show();return}this.pages=e.pages;for(t=0;t0&&(r=e)},this),r},setup_toolbar:function(){var t,n,r,i,o,u,a,c,p;i=this.get_dialogue_element(s.SEARCHCOMMENTSBUTTON),i.on("click",this.open_search_comments,this),i.on("key",this.open_search_comments,"down:13",this),o=this.get_dialogue_element(s.EXPCOLCOMMENTSBUTTON),o.on("click",this.expandCollapseComments,this),o.on("key",this.expandCollapseComments,"down:13",this);if(this.get("readonly"))return;this.disable_touch_scroll(),e.each(h,function(e,n){t=this.get_dialogue_element(e),t.on("click",this.handle_tool_button,this,n),t.on("key",this.handle_tool_button,"down:13",this,n),t.setAttribute("aria-pressed","false")},this),n=this.get_dialogue_element(s.COMMENTCOLOURBUTTON),c=new M.assignfeedback_editpdf.colourpicker({buttonNode:n,colours:f,iconprefix:"background_colour_",callback:function(e){var t=e.target.getAttribute("data-colour");t||(t=e.target.ancestor().getAttribute("data-colour")),this.currentedit.commentcolour=t,this.handle_tool_button(e,"comment")},context:this}),r=this.get_dialogue_element(s.ANNOTATIONCOLOURBUTTON),c=new M.assignfeedback_editpdf.colourpicker({buttonNode:r,iconprefix:"colour_",colours:l,callback:function(e){var t=e.target.getAttribute("data-colour");t||(t=e.target.ancestor().getAttribute("data-colour")),this.currentedit.annotationcolour=t,this.lastannotationtool?this.handle_tool_button(e,this.lastannotationtool):this.handle_tool_button(e,"pen")},context:this}),a=this.get("stampfiles"),a.length<=0?this.get_dialogue_element(h.stamp).ancestor().hide():(p=a[0].substr(a[0].lastIndexOf("/")+1),this.currentedit.stamp=p,u=this.get_dialogue_element(s.STAMPSBUTTON),c=new M.assignfeedback_editpdf.stamppicker({buttonNode:u,stamps:a,callback:function(e){var t=e.target.getAttribute("data-stamp"),n;t||(t=e.target.ancestor().getAttribute("data-stamp")),n=t.substr(t.lastIndexOf("/")),this.currentedit.stamp=n,this.handle_tool_button(e,"stamp")},context:this}),this.refresh_button_state())},handle_tool_button:function(e,t){var n;e.preventDefault(),n=this.get_dialogue_element
+(h[this.currentedit.tool]),n.removeClass("assignfeedback_editpdf_selectedbutton"),n.setAttribute("aria-pressed","false"),this.currentedit.tool=t,t!=="comment"&&t!=="select"&&t!=="drag"&&t!=="stamp"&&(this.lastannotationtool=t),this.refresh_button_state()},stringify_current_page:function(){var t=[],n=[],r,i=0;for(i=0;it.width||o.y<0||o.y>t.height)return;this.currentedit.tool==="pen"&&this.currentedit.path.push(o),this.currentedit.tool==="select"?this.currentannotation&&this.currentedit&&this.currentannotation.move(this.currentedit.annotationstart.x+o.x-this.currentedit.start.x,this.currentedit.annotationstart.y+o.y-this.currentedit.start.y):this.currentedit.tool==="drag"?(u=o.x-this.currentedit.start.x,a=o.y-this.currentedit.start.y,r.getDOMNode().scrollLeft-=u,r.getDOMNode().scrollTop-=a):this.currentedit.start&&(this.currentedit.end=o,this.redraw_current_edit())},edit_end:function(){var e,t,n;e=(new Date).getTime()-this.currentedit.start;if(e0)this.drawables.pop().erase();for(e=0;e0?n.removeAttribute("disabled"):n.setAttribute("disabled","true"),this.currentpage"),i.setAttribute("value",n),r={page:n+1,total:this.pages.length},i.setHTML(M.util.get_string("pagexofy","assignfeedback_editpdf",r)),t.append(i);t.removeAttribute("disabled"),t.on("change",function(){this.currentpage=t.get("value"),this.change_page()},this),o=this.get_dialogue_element(s.PREVIOUSBUTTON),u=this.get_dialogue_element(s.NEXTBUTTON),o.on("click",this.previous_page,this),o.on("key",this.previous_page,"down:13",this),u.on("click",this.next_page,this),u.on("key",this.next_page,"down:13",this)},previous_page:function(e){e.preventDefault(),this.currentpage--,this.currentpage<0&&(this.currentpage=0),this.change_page()},next_page:function(e){e.preventDefault(),this.currentpage++,this.currentpage>=this.pages.length&&(this.currentpage=this.pages.length-1),this.change_page()},move_canvas:function(){var e,t,n,r;e=this.get_dialogue_element(s.DRAWINGREGION),t=parseInt(e.get("scrollLeft"),10),n=parseInt(e.get("scrollTop"),10);for(r=0;r');
+ warningelement.setHTML(message);
+ drawingregion.prepend(warningelement);
+ },
+
/**
* The info about all pages in the pdf has been returned.
*
@@ -3837,7 +3852,8 @@ EDITOR.prototype = {
* @method prepare_pages_for_display
*/
prepare_pages_for_display: function(data) {
- var i, j, comment, error;
+ var i, j, comment, error, annotation, readonly;
+
if (!data.pagecount) {
if (this.dialogue) {
this.dialogue.hide();
@@ -3863,11 +3879,17 @@ EDITOR.prototype = {
comment.rawtext);
}
for (j = 0; j < this.pages[i].annotations.length; j++) {
- data = this.pages[i].annotations[j];
- this.pages[i].annotations[j] = this.create_annotation(data.type, data);
+ annotation = this.pages[i].annotations[j];
+ this.pages[i].annotations[j] = this.create_annotation(annotation.type, annotation);
}
}
+ readonly = this.get('readonly');
+ if (!readonly && data.partial) {
+ // Warn about non converted files, but only for teachers.
+ this.warning(M.util.get_string('partialwarning', 'assignfeedback_editpdf'));
+ }
+
// Update the ui.
if (this.quicklist) {
this.quicklist.load();
@@ -4817,6 +4839,7 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
"querystring-stringify-simple",
"moodle-core-notification-dialog",
"moodle-core-notification-alert",
+ "moodle-core-notification-warning",
"moodle-core-notification-exception",
"moodle-core-notification-ajaxexception"
]
diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/editor.js b/mod/assign/feedback/editpdf/yui/src/editor/js/editor.js
index 878eb496cfa..066d60f13f2 100644
--- a/mod/assign/feedback/editpdf/yui/src/editor/js/editor.js
+++ b/mod/assign/feedback/editpdf/yui/src/editor/js/editor.js
@@ -556,6 +556,21 @@ EDITOR.prototype = {
});
},
+ /**
+ * Display an error in a small part of the page (don't block everything).
+ *
+ * @param string The error text.
+ * @protected
+ * @method warning
+ */
+ warning: function(message) {
+ var drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
+
+ var warningelement = Y.Node.create('');
+ warningelement.setHTML(message);
+ drawingregion.prepend(warningelement);
+ },
+
/**
* The info about all pages in the pdf has been returned.
*
@@ -564,7 +579,8 @@ EDITOR.prototype = {
* @method prepare_pages_for_display
*/
prepare_pages_for_display: function(data) {
- var i, j, comment, error;
+ var i, j, comment, error, annotation, readonly;
+
if (!data.pagecount) {
if (this.dialogue) {
this.dialogue.hide();
@@ -590,11 +606,17 @@ EDITOR.prototype = {
comment.rawtext);
}
for (j = 0; j < this.pages[i].annotations.length; j++) {
- data = this.pages[i].annotations[j];
- this.pages[i].annotations[j] = this.create_annotation(data.type, data);
+ annotation = this.pages[i].annotations[j];
+ this.pages[i].annotations[j] = this.create_annotation(annotation.type, annotation);
}
}
+ readonly = this.get('readonly');
+ if (!readonly && data.partial) {
+ // Warn about non converted files, but only for teachers.
+ this.warning(M.util.get_string('partialwarning', 'assignfeedback_editpdf'));
+ }
+
// Update the ui.
if (this.quicklist) {
this.quicklist.load();
diff --git a/mod/assign/feedback/editpdf/yui/src/editor/meta/editor.json b/mod/assign/feedback/editpdf/yui/src/editor/meta/editor.json
index 2f2887d7907..dd8acf985cc 100644
--- a/mod/assign/feedback/editpdf/yui/src/editor/meta/editor.json
+++ b/mod/assign/feedback/editpdf/yui/src/editor/meta/editor.json
@@ -13,6 +13,7 @@
"querystring-stringify-simple",
"moodle-core-notification-dialog",
"moodle-core-notification-alert",
+ "moodle-core-notification-warning",
"moodle-core-notification-exception",
"moodle-core-notification-ajaxexception"
]