Skip to content

Commit 73ad359

Browse files
committed
fix: ignore deleted files in submissions
If a file is deleted from disk somehow after the student response has been submitted, the api will still respond with metadata about these files. However, the download url will be empty, resulting in broken files in the frontend ui: the preview pane will display an "Unknown error", and downloading the files will result in downloaded files with the correct file names but invalid content. The student view in ORA handles these deleted files by simply ignoring them and not displaying them to the user. So here we do the same: simply filter out any deleted files from the api. Private-ref: https://tasks.opencraft.com/browse/BB-9781
1 parent 715cc60 commit 73ad359

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/data/services/lms/api.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,15 @@ const fetchSubmission = (submissionUUID) => get(
5252
[paramKeys.oraLocation]: locationId(),
5353
[paramKeys.submissionUUID]: submissionUUID,
5454
}),
55-
).then(response => response.data);
55+
).then(response => ({
56+
...response.data,
57+
response: {
58+
...response.data.response,
59+
// The API includes metadata for deleted files (without a download url);
60+
// we don't want to deal with deleted files here, so filter them out like the student view does.
61+
files: response.data.response.files.filter((file) => file.downloadUrl),
62+
},
63+
}));
5664

5765
/**
5866
* get('/api/submission/files', { oraLocation, submissionUUID })
@@ -65,7 +73,12 @@ const fetchSubmissionFiles = (submissionUUID) => get(
6573
[paramKeys.oraLocation]: locationId(),
6674
[paramKeys.submissionUUID]: submissionUUID,
6775
}),
68-
).then(response => response.data);
76+
).then(response => ({
77+
...response.data,
78+
// The API includes metadata for deleted files (without a download url);
79+
// we don't want to deal with deleted files here, so filter them out like the student view does.
80+
files: response.data.files.filter((file) => file.downloadUrl),
81+
}));
6982

7083
/**
7184
* fetches the current grade, gradeStatus, and rubricResponse data for the given submission

0 commit comments

Comments
 (0)