MDL-68262 assignfeedback_editpdf: Correct args to make_request_directory

This commit is contained in:
Andrew Nicols 2024-05-30 09:37:25 +08:00 committed by Huong Nguyen
parent 2debc731ef
commit f0445d5cac
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A
2 changed files with 7 additions and 13 deletions

View File

@ -414,7 +414,7 @@ EOD;
return [];
}
$tmpdir = \make_request_directory('assignfeedback_editpdf/pageimages/' . self::hash($assignment, $userid, $attemptnumber));
$tmpdir = \make_request_directory();
$combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
$document->get_combined_file()->copy_content_to($combined); // Copy the file.
@ -681,7 +681,7 @@ EOD;
$file = $document->get_combined_file();
$tmpdir = make_request_directory('assignfeedback_editpdf/final/' . self::hash($assignment, $userid, $attemptnumber));
$tmpdir = make_request_directory();
$combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
$file->copy_content_to($combined); // Copy the file.
@ -702,7 +702,7 @@ EOD;
}
$fs = get_file_storage();
$stamptmpdir = make_request_directory('assignfeedback_editpdf/stamps/' . self::hash($assignment, $userid, $attemptnumber));
$stamptmpdir = make_request_directory();
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
// Copy any new stamps to this instance.
if ($files = $fs->get_area_files($assignment->get_context()->id,
@ -1004,8 +1004,7 @@ EOD;
$degree = ($degree - 90) % 360;
}
$filename = $matches[0].'png';
$tmpdir = make_request_directory(self::COMPONENT . '/' . self::PAGE_IMAGE_FILEAREA . '/'
. self::hash($assignment, $userid, $attemptnumber));
$tmpdir = make_request_directory();
$tempfile = $tmpdir . '/' . time() . '_' . $filename;
imagepng($content, $tempfile);
@ -1041,9 +1040,7 @@ EOD;
private static function save_jpg_to_pdf($assignment, $userid, $attemptnumber, $file, $size=null) {
// Temporary file.
$filename = $file->get_filename();
$tmpdir = make_request_directory('assignfeedback_editpdf' . DIRECTORY_SEPARATOR
. self::TMP_JPG_TO_PDF_FILEAREA . DIRECTORY_SEPARATOR
. self::hash($assignment, $userid, $attemptnumber));
$tmpdir = make_request_directory();
$tempfile = $tmpdir . DIRECTORY_SEPARATOR . $filename . ".pdf";
// Determine orientation.
$orientation = 'P';
@ -1092,9 +1089,7 @@ EOD;
*/
private static function save_rotated_image_file($assignment, $userid, $attemptnumber, $rotateddata, $filename) {
$filearea = self::TMP_ROTATED_JPG_FILEAREA;
$tmpdir = make_request_directory('assignfeedback_editpdf' . DIRECTORY_SEPARATOR
. $filearea . DIRECTORY_SEPARATOR
. self::hash($assignment, $userid, $attemptnumber));
$tmpdir = make_request_directory();
$tempfile = $tmpdir . DIRECTORY_SEPARATOR . basename($filename);
imagejpeg($rotateddata, $tempfile);
$newfile = self::save_file($assignment, $userid, $attemptnumber, $filearea, $tempfile);
@ -1104,5 +1099,4 @@ EOD;
}
return $newfile;
}
}

View File

@ -49,7 +49,7 @@ final class document_services_test extends \advanced_testcase {
$filearea = document_services::TMP_ROTATED_JPG_FILEAREA;
$content = 'some random content';
$tempfile = make_request_directory('assignfeedback_editpdf') . DIRECTORY_SEPARATOR . 'mock.file';
$tempfile = make_request_directory() . DIRECTORY_SEPARATOR . 'mock.file';
file_put_contents($tempfile, $content);
// Invoke the method and confirm, that the file is saved.