mirror of
https://github.com/moodle/moodle.git
synced 2025-03-22 08:30:04 +01:00
MDL-45580 assignfeedback_editpdf: Delete draft content on new submission
This commit is contained in:
parent
098f7dd438
commit
7dbbb848c6
@ -438,8 +438,10 @@ class document_services {
|
||||
if (!empty($files)) {
|
||||
$first = reset($files);
|
||||
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);
|
||||
page_editor::delete_draft_content($itemid);
|
||||
$files = array();
|
||||
} else {
|
||||
|
||||
|
@ -340,4 +340,21 @@ class page_editor {
|
||||
|
||||
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…
x
Reference in New Issue
Block a user