Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiz exercises: Simplify drag-and-drop image upload #7003

Closed

Conversation

julian-christl
Copy link
Member

@julian-christl julian-christl commented Jul 29, 2023

Checklist

General

Server

  • I followed the coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I implemented the changes with a good performance and prevented too many database calls.
  • I documented the Java code using JavaDoc style.

Client

  • I followed the coding and design guidelines and ensured that the layout is responsive.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Follow-up of #5733 and #5427 to replace the file upload before entity persistence with a multipart file and entity upload.

Description

The changes only affect the drag-and-drop section of the quizzes. But because the quiz editor allows creating all different types of quiz questions, I had to make the component saving the entity to retrieve the files from potential drag-and-drop question children and upload them together with the files.

It affects the Creation, Update, Re-evaluation and Import of quiz exercises. Additionally, it also affects the creation of drag-and-drop mode quizzes. However, those use the same creation endpoint.

I excluded one cypress tests that blocks this PR because it only fails on CI. It works locally and manual tests confirm that the functionality works. We try debugging and fixing this test in #6631 not further to block this PR.

Steps for Testing

We need to fully test the quiz functionalities, including:

  • Creation of a normal quiz
  • Creation of a Drag and Drop Model Quiz
  • Edit
  • Import
  • Reevaluation
  • Adding existing questions (bottom of the editor) to a quiz exercise

During all of these five checks, it makes sense to work

  • with and without dnd questions
  • with and without background
  • with and without picture drag and drop items
  • with and without text drag and drop items
  • with both drag and drop items
  • with adding, removing, replacing Drag Items and Questions to make sure the files get cleared up and not sent to the server

Always check if the quiz gets rendered as expected.

Exam Mode Testing

Most of the changes are unrelated to the exam mode. I do not think testing is necessary to test the exam mode as extensively. However, it makes sense to just test the normal quiz exam workflow (creation and conduction) to be sure.

The only change that does require testing here is the import functionality of an existing exercise.

Review Progress

Code Review

  • Review 1
  • Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Tests

  • Test 1
  • Test 2

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
FileService.java 87.0%
QuizExerciseImportService.java 93.7%
QuizExerciseService.java 97.7%
ExamImportService.java 95.5%
QuizExerciseResource.java 93.6%
quiz-exercise-generator.ts 89.6%
drag-and-drop-question-edit.component.ts 91.6%
quiz-exercise-detail.component.ts 92.8%
quiz-question-list-edit.component.ts 94.8%
quiz-question-list-edit-existing.component.ts 98.9%
re-evaluate-drag-and-drop-question.component.ts 100%
quiz-re-evaluate.component.ts 86.1%
quiz-exercise.service.ts 100%
quiz-re-evaluate.service.ts 100%
file.service.ts 63.0%

Screenshots

Upload background before (before changes):
1409d1ba0c797661134ab989845ec831
Upload Background before (after changes):
e050fc2202937de46c2976423242c873

Upload background after (before changes):
80251aeeb77554f93832507fce51ee06
Upload background after (after changes):
3557ddaac548194325b3defb284e7f34

Upload picture drag item after (before changes):
593948ae5992864d34e4832ef35d9341
Upload picture drag item after (after changes):
f7deccf1b245d6010fb76aa3a1abbff3

@julian-christl julian-christl self-assigned this Jul 29, 2023
@artemis-bot artemis-bot added this to In progress in Artemis Development Jul 29, 2023
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) cypress Pull requests that update cypress tests. (Added Automatically!) labels Jul 29, 2023
@@ -224,11 +250,11 @@
public String copyExistingFileToTarget(String oldFilePath, String targetFolder, Long entityId) {
if (oldFilePath != null && !oldFilePath.contains("files/temp")) {
try {
Path source = Path.of(actualPathForPublicPath(oldFilePath));
Path source = Path.of(actualPathForPublicPathOrThrow(oldFilePath));

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1). This path depends on a [user-provided value](2). This path depends on a [user-provided value](3).
// Need to copy the file and get a new path, otherwise two different questions would share the same image and would cause problems in case one was deleted
if (dndQuestion.getBackgroundFilePath() != null) {
String actualPath = fileService.actualPathForPublicPath(dndQuestion.getBackgroundFilePath());
if (actualPath != null && Files.exists(Path.of(actualPath))) {

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1). This path depends on a [user-provided value](2). This path depends on a [user-provided value](3).
continue;
}
String actualPath = fileService.actualPathForPublicPath(dragItem.getPictureFilePath());
if (actualPath != null && Files.exists(Path.of(actualPath))) {

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1). This path depends on a [user-provided value](2). This path depends on a [user-provided value](3).

// We need to ensure that we can access the store file and the stored file is the same as was passed to us in the request
final var storedFileHash = DigestUtils.md5Hex(Files.newInputStream(Path.of(savePath)));
final var storedFileHash = DigestUtils.md5Hex(Files.newInputStream(Path.of(newLocalPath)));

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1). This path depends on a [user-provided value](1). This path depends on a [user-provided value](2). This path depends on a [user-provided value](2).
@julian-christl
Copy link
Member Author

Closed in favour of #7259 to recreate all build plans after inactivity

@julian-christl julian-christl deleted the feature/reimplement-quiz-image-upload-2 branch September 29, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) cypress Pull requests that update cypress tests. (Added Automatically!) enhancement refactoring server Pull requests that update Java code. (Added Automatically!) tests
Projects
No open projects
Artemis Development
  
In progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant