Moodle mdl_file table, 检查文件是否被删除

Moodle mdl_file table, check if a file is deleted

我正在使用 Moodle 3.1+。我正在尝试使用以下查询从 mdl_files table 的课程摘要中添加图片和视频。

select filename from {files} where contextid= :contextid and component = :component and filearea = :filearea and (filename is not null or filename != '') and (source is not null or source != '') order by timemodified desc limit 1

一切正常。但问题是我怎么知道文件是否从编辑器中删除了?以上查询 returns 文件即使从编辑器中删除并保存后也是如此。

视情况而定,如果您想要检索已上传到编辑器中的图像,您必须使用存储在 component = user, filearea = draft 下的文件。这些文件是暂时的,仅在内容编辑期间存储,它们在保存时迁移(见下文)。不过,为了有效地执行此操作,您还必须了解 draftitemid.

如果您感兴趣的是获取课程摘要文件,那么您必须在component = course, filearea = overviewfiles中搜索。只有在用户保存任何更改后,这些记录才会受到影响,因此这将始终代表所有访问者看到的内容。

仅当单击编辑器上的 'Manage files' 按钮删除文件时,文件详细信息才会从 mdl_files table 中删除。