by Chien Wen-chang.
I have that same problem too. I queried from Moodle database and got some records as below:SELECT * from mdl_files where filename = 'onlinetext-onlinetext.html'
# id, contenthash, pathnamehash, contextid, component, filearea, itemid, filepath, filename, userid, filesize, mimetype, status, source, author, license, timecreated, timemodified, sortorder, referencefileid
'4338471', 'c202da428649a754c4f6dd5c8d92d9813bcb41ca', '418c8298bcb563d54ace86254cfb12a781e9dc6b', '775407', 'assignfeedback_editpdf', 'importhtml', '828702', '/', 'onlinetext-onlinetext.html', NULL, '78', 'text/html', '0', NULL, NULL, NULL, '1476790383', '1476790383', '0', NULL
...
...
Deleted those records, this fixes the problem.
I traced source code of /mod/assign/feedback/editpdf/classes/document_services.php,
found the error occurred at $fs->create_file_from_string($record, $file)
-------------------------------------------------------------------------------------
public static function list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber) {
:
:
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = 'assignfeedback_editpdf';
$record->filearea = self::IMPORT_HTML_FILEAREA;
$record->itemid = $submission->id;
$record->filepath = '/';
$record->filename = $plugin->get_type() . '-' . $filename;
$htmlfile = $fs->create_file_from_string($record, $file); <======= error occurred at here
$convertedfile = $fs->get_converted_document($htmlfile, 'pdf');
$htmlfile->delete();
:
:
--------------------------------------------------------------------------------------
Some information is https://docs.moodle.org/dev/File_API
The $fs->get_converted_document method of Moodle file API uses "unoconv" command to convert
document to pdf. But "unoconv" is not stable. $htmlfile->delete() is not executed when unoconv
execute fail. Next time someone annotate this assignment, error occur when re-execute
$fs->create_file_from_string.
I solved this problem by adding some codes in /mod/assign/feedback/editpdf/classes/document_services.php that are listed below
-------------------------------------------------------------------------------------
public static function list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber) {
:
:
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = 'assignfeedback_editpdf';
$record->filearea = self::IMPORT_HTML_FILEAREA;
$record->itemid = $submission->id;
$record->filepath = '/';
$record->filename = $plugin->get_type() . '-' . $filename;
//======================================================
// Get old file
$oldfile = $fs->get_file($record->contextid, $record->component, $record->filearea, $record->itemid, $record->filepath, $record->filename);
// Delete it if it exists
if ($oldfile) {
$oldfile->delete();
}
//======================================================
$htmlfile = $fs->create_file_from_string($record, $file);
$convertedfile = $fs->get_converted_document($htmlfile, 'pdf');
$htmlfile->delete();
:
:
--------------------------------------------------------------------------------------