mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
MDL-45580 assignfeedback_editpdf: Delete draft content on new submission
This commit is contained in:
parent
098f7dd438
commit
7dbbb848c6
2 changed files with 20 additions and 1 deletions
|
@ -438,8 +438,10 @@ class document_services {
|
||||||
if (!empty($files)) {
|
if (!empty($files)) {
|
||||||
$first = reset($files);
|
$first = reset($files);
|
||||||
if (!$readonly && $first->get_timemodified() < $submission->timemodified) {
|
if (!$readonly && $first->get_timemodified() < $submission->timemodified) {
|
||||||
// Image files are stale - regenerate them, except in readonly mode.
|
// Image files are stale, we need to regenerate them, except in readonly mode.
|
||||||
|
// We also need to remove the draft annotations and comments associated with this attempt.
|
||||||
$fs->delete_area_files($contextid, $component, $filearea, $itemid);
|
$fs->delete_area_files($contextid, $component, $filearea, $itemid);
|
||||||
|
page_editor::delete_draft_content($itemid);
|
||||||
$files = array();
|
$files = array();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -340,4 +340,21 @@ class page_editor {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the draft annotations and comments.
|
||||||
|
*
|
||||||
|
* This is intended to be used when the version of the PDF has changed and the annotations
|
||||||
|
* might not be relevant any more, therefore we should delete them.
|
||||||
|
*
|
||||||
|
* @param int $gradeid The grade ID.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function delete_draft_content($gradeid) {
|
||||||
|
global $DB;
|
||||||
|
$conditions = array('gradeid' => $gradeid, 'draft' => 1);
|
||||||
|
$result = $DB->delete_records('assignfeedback_editpdf_annot', $conditions);
|
||||||
|
$result = $result && $DB->delete_records('assignfeedback_editpdf_cmnt', $conditions);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue