mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
MDL-69570 assignfeedback_editpdf: Remove temp pdf files
This adds a new method to the assignfeedback edit pdf library to specify user data file areas that will return just the meaningful annotated feedback pdf. get_file_areas has been updated for this plugin to return all file areas related to assignfeedback_editpdf, and should stop producing orphaned files and records when a course reset is done. Thanks to @toniginard who provided a base solution for me to work off.
This commit is contained in:
parent
0ea3d45e04
commit
b50c240ab5
@ -106,7 +106,7 @@ class provider implements
|
||||
$currentpath[] = get_string('privacy:path', 'assignfeedback_editpdf');
|
||||
$assign = $exportdata->get_assign();
|
||||
$plugin = $assign->get_plugin_by_type('assignfeedback', 'editpdf');
|
||||
$fileareas = $plugin->get_file_areas();
|
||||
$fileareas = $plugin->get_user_data_file_areas();
|
||||
$grade = $exportdata->get_pluginobject();
|
||||
foreach ($fileareas as $filearea => $notused) {
|
||||
writer::with_context($exportdata->get_context())
|
||||
|
@ -405,6 +405,7 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
|
||||
list($gradeids, $params) = $DB->get_in_or_equal(array_keys($grades), SQL_PARAMS_NAMED);
|
||||
$DB->delete_records_select('assignfeedback_editpdf_annot', 'gradeid ' . $gradeids, $params);
|
||||
$DB->delete_records_select('assignfeedback_editpdf_cmnt', 'gradeid ' . $gradeids, $params);
|
||||
$DB->delete_records_select('assignfeedback_editpdf_rot', 'gradeid ' . $gradeids, $params);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -436,7 +437,28 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
|
||||
* @return array - An array of fileareas (keys) and descriptions (values)
|
||||
*/
|
||||
public function get_file_areas() {
|
||||
return array(document_services::FINAL_PDF_FILEAREA => $this->get_name());
|
||||
return [
|
||||
document_services::FINAL_PDF_FILEAREA => $this->get_name(),
|
||||
document_services::COMBINED_PDF_FILEAREA => $this->get_name(),
|
||||
document_services::PARTIAL_PDF_FILEAREA => $this->get_name(),
|
||||
document_services::IMPORT_HTML_FILEAREA => $this->get_name(),
|
||||
document_services::PAGE_IMAGE_FILEAREA => $this->get_name(),
|
||||
document_services::PAGE_IMAGE_READONLY_FILEAREA => $this->get_name(),
|
||||
document_services::STAMPS_FILEAREA => $this->get_name(),
|
||||
document_services::TMP_JPG_TO_PDF_FILEAREA => $this->get_name(),
|
||||
document_services::TMP_ROTATED_JPG_FILEAREA => $this->get_name()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all file areas for user data related to this plugin.
|
||||
*
|
||||
* @return array - An array of user data fileareas (keys) and descriptions (values)
|
||||
*/
|
||||
public function get_user_data_file_areas(): array {
|
||||
return [
|
||||
document_services::FINAL_PDF_FILEAREA => $this->get_name(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3601,7 +3601,18 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$fileareas = $plugin->get_file_areas();
|
||||
|
||||
if ($type == 'editpdf') {
|
||||
$this->assertEquals(array('download' => 'Annotate PDF'), $fileareas);
|
||||
$checkareas = [
|
||||
'download' => 'Annotate PDF',
|
||||
'combined' => 'Annotate PDF',
|
||||
'partial' => 'Annotate PDF',
|
||||
'importhtml' => 'Annotate PDF',
|
||||
'pages' => 'Annotate PDF',
|
||||
'readonlypages' => 'Annotate PDF',
|
||||
'stamps' => 'Annotate PDF',
|
||||
'tmp_jpg_to_pdf' => 'Annotate PDF',
|
||||
'tmp_rotated_jpg' => 'Annotate PDF'
|
||||
];
|
||||
$this->assertEquals($checkareas, $fileareas);
|
||||
$usingfilearea++;
|
||||
} else if ($type == 'file') {
|
||||
$this->assertEquals(array('feedback_files' => 'Feedback files'), $fileareas);
|
||||
|
@ -2,6 +2,8 @@ This files describes API changes in the assign code.
|
||||
=== 4.1 ===
|
||||
* New method \assign::is_userid_filtered() has been implemented. It returns false if user id is filtered out by either
|
||||
user preferences for grading table or submission status filter. Otherwise, returns true.
|
||||
* A new method was added to feedback/editpdf/locallib.php - get_user_data_file_areas() This just returns the necessary file areas
|
||||
for retrieving a complete feedback pdf.
|
||||
|
||||
=== 4.0 ===
|
||||
* The method \assign::grading_disabled() now has optional $gradinginfo parameter to improve performance
|
||||
|
Loading…
x
Reference in New Issue
Block a user