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

Exam mode: Only send student notifications when end time has changed #7382

Conversation

aplr
Copy link
Contributor

@aplr aplr commented Oct 15, 2023

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I followed the coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Motivation and Context

This PR fixes a bug introduced in #7284. When saving, the code comparing the new and old end date uses equals, which always returns false. This concern was already discussed about in the comments of the PR, however failed to address it properly, and the issue was not found in manual testing.

Description

This PR now uses the comparator, comparing dates on seconds-precision.

Steps for Testing

Case 1: No date change - no notification

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Exam
  1. Log in to Artemis
  2. Navigate to Course Administration
  3. Set the exam dates so the exam can be worked on by students
  4. Go to exam edit
  5. Save the exam, without changing the dates.
  6. The students should NOT receive a notification

Case 2: Date change + notification

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Exam
  1. Log in to Artemis
  2. Navigate to Course Administration
  3. Set the exam dates so the exam can be worked on by students
  4. Go to exam edit
  5. Change the end date of the exam
  6. Save the exam, without changing the dates.
  7. The students SHOULD receive a notification

Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

@aplr aplr linked an issue Oct 15, 2023 that may be closed by this pull request
@github-actions github-actions bot added the server Pull requests that update Java code. (Added Automatically!) label Oct 15, 2023
@aplr aplr changed the title Fix #7380 Exam mode: Only send notifications when end time has changed Oct 15, 2023
@aplr
Copy link
Contributor Author

aplr commented Oct 15, 2023

TODO:

  • Server: Test if notifications are sent when time was changed
  • Server: Test if no notification is sent when time was not changed
  • Client: E2E test if confirmation pops up when time was changed
  • Client: E2E test if confirmation does not pop up if no time was changed

I'd skip the E2E's as it was a server issue, and rather do them in a separate PR.

@aplr aplr changed the title Exam mode: Only send notifications when end time has changed Exam mode: Only send student notifications when end time has changed Oct 15, 2023
@Strohgelaender
Copy link
Contributor

Please add a comment why equals cannot be used here.

@aplr
Copy link
Contributor Author

aplr commented Oct 16, 2023

Please add a comment why equals cannot be used here.

There's already an explanation a few lines above. Imho, this is sufficient. Tell me if you think otherwise.

// We can't test dates for equality as the dates retrieved from the database lose precision. Also use instant to take timezones into account

@aplr
Copy link
Contributor Author

aplr commented Oct 16, 2023

Interesting thing: There is a test for the case, that a exam title is updated, without updating the dates, and no notification should be sent. However, this test just does not work, as the update data is not sent from the client, but uses the server-side dates. These dates of course match (i.e. oldDate.equals(newDate) returns true) -> the notification is never sent.

However, if the data is coming from the client, the dates do not match w/ equals. We have to verify that in the tests.

Here's the test:

// Update the exam -> ok
exam1.setTitle("Best exam ever");
var returnedExam = request.putWithResponseBody("/api/courses/" + course1.getId() + "/exams", exam1, Exam.class, HttpStatus.OK);
assertThat(returnedExam).isEqualTo(exam1);
verify(instanceMessageSendService, never()).sendProgrammingExerciseSchedule(any());

@github-actions github-actions bot added the tests label Oct 16, 2023
if (!originalExam.getEndDate().equals(savedExam.getEndDate())) {
if (comparator.compare(originalExam.getEndDate(), savedExam.getEndDate()) != 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is the only change in this PR. The rest is adding & fixing tests

@aplr aplr marked this pull request as ready for review October 16, 2023 15:04
@aplr aplr requested a review from a team as a code owner October 16, 2023 15:04
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: In general, I've ripped some tests apart and created individual tests. This way, it is clearer what is tested, failing cases can be pinned down more easily, and when refactoring, only single test cases have to be touched. Please tell me if you explicitly want these aggregated test cases in Artemis, and this was a design decision.

Copy link
Contributor

@Strohgelaender Strohgelaender left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, thanks for taking the time to cleanup and improve the tests. Just a few small suggestions:

@aplr aplr added deploy:artemis-test5 and removed deployment-error Added by deployment workflows if an error occured labels Nov 8, 2023
@github-actions github-actions bot added deployment-error Added by deployment workflows if an error occured and removed deploy:artemis-test5 labels Nov 8, 2023
@aplr aplr added deploy:artemis-test5 and removed deployment-error Added by deployment workflows if an error occured labels Nov 8, 2023
@ls1intum ls1intum deleted a comment from github-actions bot Nov 8, 2023
@ls1intum ls1intum deleted a comment from github-actions bot Nov 8, 2023
@ls1intum ls1intum deleted a comment from github-actions bot Nov 8, 2023
@aplr aplr temporarily deployed to artemis-test5.artemis.cit.tum.de November 8, 2023 14:29 — with GitHub Actions Inactive
@aplr aplr temporarily deployed to artemis-test1.artemis.cit.tum.de November 8, 2023 14:43 — with GitHub Actions Inactive
Copy link
Contributor

@jakubriegel jakubriegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on ts1

Copy link
Contributor

@lennart-keller lennart-keller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in testing session

Copy link

@vinceclifford vinceclifford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected, tested on ts1

@krusche krusche added this to the 6.6.5 milestone Nov 10, 2023
@krusche krusche merged commit c104b9f into develop Nov 10, 2023
90 of 97 checks passed
@krusche krusche deleted the 7380-exam-mode-misleading-notification-when-updating-exam-details branch November 10, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge server Pull requests that update Java code. (Added Automatically!) tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exam mode: Misleading notification when updating exam details