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: Add exam rescheduled event #10026

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

coolchock
Copy link
Contributor

@coolchock coolchock commented Dec 15, 2024

Checklist

General

Server

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • 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

When the exam start and end dates are adjusted while the exam is already visible, but the duration remains unchanged (e.g., postponing the exam by 10 minutes), this currently triggers a working time update event in the client, which can be confusing since the working time is not affected. This pull request introduces a new live exam event type called ExamRescheduled to handle such cases more clearly.

Description

A new event called ExamRescheduled has been implemented on the server side. This event is triggered only when the exam is visible and before its start date, as postponing an exam that has already started would be irrelevant. The client side has also been updated to handle this new event type appropriately. The notification is shown only if the user is currently viewing the exam start page. If the user navigates to the exam page after the event has been sent, it is automatically acknowledged, as the exam page already reflects the updated exam information.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Student
  • 1 Exam
  1. Log in to Artemis
  2. Navigate to Exam Management as an instructor.
  3. Make the exam visible and ensure that the exam start date is in the future.
  4. In a different browser/incognito mode, navigate to the exam as a student.
  5. As an instructor, postpone/bring forward the exam while ensuring that the working time is not affected.
  6. Switch to the student view and verify that the ExamRescheduled event was received. Acknowledge the event.
  7. As a student, navigate to another section of Artemis.
  8. As an instructor, postpone/bring forward the exam again.
  9. As a student, return to the exam page.
  10. Verify that no pop-up notification was shown this time.
  11. Start the exam as a student (you can adjust the start date as an instructor to a past date, it will trigger a working time update event).
  12. As an instructor, postpone/bring forward the exam.
  13. As a student, verify that no event was received.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







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 even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Coverage

Client

Client

Class/File Line Coverage Confirmation (assert/expect)
exam-update.component.ts 88.43%
exam-live-events-button.component.ts 100%
exam-participation-live-events.service.ts 93.1%
exam-participation.component.ts 91.06%
exam-start-information.component.ts 98.18%
exam-live-event.component.ts 88.88%

Server

Class/File Line Coverage Confirmation (assert/expect)
ExamLiveEventsService.java 86%
ExamService.java 92%

Screenshots

Light mode
image

Dark mode
image

Summary by CodeRabbit

  • New Features

    • Introduced support for rescheduled exam events, allowing users to receive updates on new start and end dates.
    • Added a new event type for rescheduled exams in the event handling system.
    • Enhanced user interface to display messages regarding rescheduled exams.
    • Improved responsiveness of components to live updates for exam rescheduling.
  • Bug Fixes

    • Improved logic for notifying students about changes in exam scheduling and working times.
  • Documentation

    • Updated internationalization files to include translations and descriptions for rescheduled exam events.
  • Tests

    • Enhanced test coverage for exam participation logic, including scenarios for handling rescheduled exams.

@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. exam Pull requests that affect the corresponding module labels Dec 15, 2024
@github-actions github-actions bot added the tests label Dec 15, 2024
@coolchock coolchock marked this pull request as ready for review December 16, 2024 00:53
@coolchock coolchock requested a review from a team as a code owner December 16, 2024 00:53
Copy link

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request introduces a new feature for handling exam rescheduling events within the Artemis platform. It includes the creation of a new ExamRescheduledEvent class, a corresponding DTO, and updates to various services and components to accommodate this event type. The changes enable dynamic notifications for rescheduled exams, allowing instructors to inform students of changes in exam timings while maintaining the original working time.

Changes

File Path Change Summary
src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java New domain event class for exam rescheduling with fields for new start and end dates.
src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamRescheduledEventDTO.java New DTO for exam rescheduling events, implemented as a Java record.
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamLiveEventsService.java Added method to create and send exam rescheduled events.
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java Updated logic in updateStudentExamsAndRescheduleExercises method for handling notifications related to exam rescheduling.
src/main/webapp/app/exam/participate/exam-participation.component.ts Added subscription and handling for exam rescheduled events.
src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts Introduced new event type EXAM_RESCHEDULED and acknowledgment logic for rescheduled events.
src/main/webapp/app/exam/shared/events/exam-live-event.component.html Added UI template for displaying rescheduled exam events.
src/main/webapp/app/exam/shared/events/exam-live-event.component.scss New CSS class for styling rescheduled exam events.
src/main/webapp/i18n/de/exam.json, src/main/webapp/i18n/en/exam.json Added translations for exam rescheduling events.
src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts Updated tests for exam participation component to handle new rescheduling logic.
src/main/webapp/app/exam/manage/exams/exam-update.component.ts Modified handleSubmit method to include working time change checks.

Suggested Labels

small, ready to merge, maintainer-approved

Suggested Reviewers

  • SimonEntholzer
  • JohannesStoehr
  • EneaGore
  • az108
  • BBesrour

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🔭 Outside diff range comments (1)
src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)

Line range hint 51-62: Add null checks for optional properties

The updateInformationBoxes method should include null checks for optional properties to prevent potential runtime errors.

     private updateInformationBoxes(): void {
+        if (!this.exam || !this.studentExam) {
+            return;
+        }
         this.totalPoints = this.exam.examMaxPoints;
         this.totalWorkingTimeInMinutes = Math.floor(this.exam.workingTime! / 60);
         this.moduleNumber = this.exam.moduleNumber;
         this.courseName = this.exam.courseName;
         this.examiner = this.exam.examiner;
         this.numberOfExercisesInExam = this.exam.numberOfExercisesInExam;
         this.examinedStudent = this.studentExam.user?.name;
         this.startDate = this.exam.startDate;
-        this.gracePeriodInMinutes = Math.floor(this.exam.gracePeriod! / 60);
+        this.gracePeriodInMinutes = this.exam.gracePeriod ? Math.floor(this.exam.gracePeriod / 60) : undefined;
🧹 Nitpick comments (10)
src/main/webapp/app/exam/participate/exam-participation.component.ts (1)

674-674: Simplify object property assignment using ES6 shorthand

You can use ES6 property shorthand to make the code more concise.

Apply this diff to simplify the object assignment:

- this.exam = { ...this.exam, startDate: startDate, endDate: endDate };
+ this.exam = { ...this.exam, startDate, endDate };
src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts (1)

155-158: Ensure consistent use of date handling in tests

The use of dayjs() is appropriate for mocking dates. However, ensure that all test cases consistently use the mocked server date to prevent flakiness.

No action needed if consistency is already maintained across tests.

src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamRescheduledEventDTO.java (1)

14-14: Consider using Instant for date fields for consistency

To maintain consistency with other DTOs and avoid potential serialization issues, consider using Instant instead of ZonedDateTime for newStartDate and newEndDate.

Apply this diff to replace ZonedDateTime with Instant:

- public record ExamRescheduledEventDTO(Long id, String createdBy, Instant createdDate, ZonedDateTime newStartDate, ZonedDateTime newEndDate) implements ExamLiveEventBaseDTO {
+ public record ExamRescheduledEventDTO(Long id, String createdBy, Instant createdDate, Instant newStartDate, Instant newEndDate) implements ExamLiveEventBaseDTO {
src/main/webapp/app/exam/shared/events/exam-live-event.component.scss (1)

47-57: Reduce style duplication using a shared class

The .wt-title styles are duplicated between .workingTimeUpdate and .examRescheduled classes.

Extract common styles:

+    %event-title {
+        font-weight: bold;
+        font-size: 1.5em;
+        text-align: center;
+        margin-bottom: 15px;
+    }

    &.workingTimeUpdate {
        background-color: var(--artemis-alert-warning-background);
        border-color: var(--artemis-alert-warning-border);

        .wt-title {
-            font-weight: bold;
-            font-size: 1.5em;
-            text-align: center;
-            margin-bottom: 15px;
+            @extend %event-title;
        }
    }

    &.examRescheduled {
        background-color: var(--artemis-alert-warning-background);
        border-color: var(--artemis-alert-warning-border);

        .wt-title {
-            font-weight: bold;
-            font-size: 1.5em;
-            text-align: center;
-            margin-bottom: 15px;
+            @extend %event-title;
        }
    }
src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1)

17-21: Consider improving constant name and adding documentation

While the separation of events is logical, the purpose of USER_DISPLAY_RELEVANT_EVENTS_REOPEN is not immediately clear. Consider:

  1. Renaming to something more descriptive like EXAM_PRE_START_RELEVANT_EVENTS
  2. Adding JSDoc comments explaining when each constant should be used
-export const USER_DISPLAY_RELEVANT_EVENTS_REOPEN = [
+/** Events that are relevant before the exam starts and can trigger reopening of the event dialog */
+export const EXAM_PRE_START_RELEVANT_EVENTS = [
src/main/webapp/app/exam/shared/events/exam-live-event.component.html (1)

74-82: LGTM with a minor accessibility enhancement suggestion

The implementation of the exam rescheduled event case is correct and follows Angular best practices. Consider adding an ARIA label for better screen reader support.

             @case (ExamLiveEventType.EXAM_RESCHEDULED) {
                 <div>
                     <div
                         [jhiTranslate]="'artemisApp.exam.events.messages.examRescheduled.description'"
                         [translateValues]="{ startDate: examRescheduledEvent.newStartDate | artemisDate, endDate: examRescheduledEvent.newEndDate | artemisDate }"
                         class="wt-title"
+                        role="alert"
+                        aria-live="polite"
                     ></div>
                 </div>
             }
src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)

35-40: Consider optimizing change detection

While the implementation is correct, consider adding change detection optimization to prevent unnecessary updates:

-    ngOnChanges(): void {
+    ngOnChanges(changes: SimpleChanges): void {
+        // Only update if exam or studentExam inputs have changed
+        if (changes['exam'] || changes['studentExam']) {
           this.updateInformationBoxes();
+        }
     }
src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (1)

56-59: Consider timezone handling for dates

The date fields should explicitly handle timezone conversions to prevent any potential timezone-related issues.

Consider using a utility function:

 export type ExamRescheduledEvent = ExamLiveEvent & {
-    newStartDate: dayjs.Dayjs;
-    newEndDate: dayjs.Dayjs;
+    newStartDate: dayjs.Dayjs & { utc: true };
+    newEndDate: dayjs.Dayjs & { utc: true };
 };
src/main/webapp/i18n/en/exam.json (1)

190-191: Enhance message clarity

The current message could be more informative about the implications of the rescheduling.

Consider this improved message:

-                    "examRescheduled": "Exam rescheduled"
+                    "examRescheduled": "Exam schedule changed"
                     "description": "The exam has been rescheduled.<br />The exam will take place from {{ startDate }} to {{ endDate }}.<br />The working time has not been affected."
+                    "description": "Important: The exam schedule has been updated.<br />New exam time: {{ startDate }} to {{ endDate }}.<br />Note: Your allocated working time remains unchanged. Please adjust your schedule accordingly."

Also applies to: 211-212

src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)

1450-1451: Improve clarity of comments and conditions.

The current comment and condition could be more explicit about the logic:

-// If the old working time equals the new working time, the exam has been rescheduled
-if (studentExam.getWorkingTime().equals(originalStudentWorkingTime)) {
+// If the working time hasn't changed, this update is for rescheduling the exam dates
+if (Objects.equals(studentExam.getWorkingTime(), originalStudentWorkingTime)) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b21a9c4 and 3b8eb1b.

⛔ Files ignored due to path filters (2)
  • src/main/resources/config/liquibase/changelog/20241211131711_changelog.xml is excluded by !**/*.xml
  • src/main/resources/config/liquibase/master.xml is excluded by !**/*.xml
📒 Files selected for processing (15)
  • src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamLiveEventBaseDTO.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamRescheduledEventDTO.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exam/service/ExamLiveEventsService.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1 hunks)
  • src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1 hunks)
  • src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (3 hunks)
  • src/main/webapp/app/exam/participate/exam-participation.component.ts (6 hunks)
  • src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (4 hunks)
  • src/main/webapp/app/exam/shared/events/exam-live-event.component.html (1 hunks)
  • src/main/webapp/app/exam/shared/events/exam-live-event.component.scss (1 hunks)
  • src/main/webapp/app/exam/shared/events/exam-live-event.component.ts (2 hunks)
  • src/main/webapp/i18n/de/exam.json (2 hunks)
  • src/main/webapp/i18n/en/exam.json (2 hunks)
  • src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamLiveEventBaseDTO.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/webapp/app/exam/shared/events/exam-live-event.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exam/shared/events/exam-live-event.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamRescheduledEventDTO.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/exam/service/ExamLiveEventsService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/i18n/de/exam.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

src/main/webapp/app/exam/participate/exam-participation.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamRescheduledEvent.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)
Learnt from: SamuelRoettgermann
PR: ls1intum/Artemis#9303
File: src/main/java/de/tum/in/www1/artemis/service/exam/StudentExamService.java:266-267
Timestamp: 2024-11-12T12:51:58.050Z
Learning: When reviewing code in this project, avoid suggesting code changes that are outside the scope of the PR.
🔇 Additional comments (8)
src/main/java/de/tum/cit/aet/artemis/exam/dto/examevent/ExamLiveEventBaseDTO.java (1)

20-20: Addition of ExamRescheduledEventDTO is correctly implemented

The new subtype ExamRescheduledEventDTO has been appropriately added to the @JsonSubTypes annotation.

src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1)

15-16: LGTM: Event type addition is correct

The addition of ExamLiveEventType.EXAM_RESCHEDULED to the relevant events array is appropriate and aligns with the PR objectives.

src/main/webapp/app/exam/participate/exam-start-information/exam-start-information.component.ts (1)

1-1: LGTM: Proper implementation of OnChanges

The addition of the OnChanges interface is appropriate for handling reactive updates to exam information.

Also applies to: 17-17

src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (2)

23-23: LGTM: Event type addition

The new event type follows the established naming convention.


195-198: Review auto-acknowledgment behavior

While auto-acknowledging rescheduled events prevents notification spam, it might hide important information from users who navigate to the exam page after the event was sent.

Let's verify the impact:

Consider adding a visual indicator in the UI that shows the exam was rescheduled, even if the event is auto-acknowledged.

src/main/webapp/i18n/de/exam.json (2)

190-191: LGTM! Translation for exam rescheduled event type.

The German translation "Prüfung verschoben" is appropriate and follows the informal style (dutzen) guideline.


211-213: LGTM! Translation for exam rescheduled event message.

The German message is well-structured with:

  • Clear communication of the schedule change
  • Proper placeholders for dates
  • Important note about unchanged working time
  • Consistent formatting with other messages
src/main/java/de/tum/cit/aet/artemis/exam/service/ExamService.java (1)

1448-1458: Verify the impact of exam rescheduling.

The rescheduling logic assumes that equal working times indicate a reschedule. Please verify:

  1. That this assumption holds true for all cases
  2. That there are no edge cases where working time equality could lead to incorrect event type selection
✅ Verification successful

Based on the search results, I can now generate a final response as we have sufficient evidence from the codebase:

The exam rescheduling logic is correctly implemented and documented

The assumption about equal working times indicating a reschedule is valid because:

  • The ExamRescheduledEvent class explicitly documents: "An event indicating that the exam's start and end dates have been rescheduled. The working time remains unchanged in such cases."
  • The implementation correctly separates working time changes from rescheduling events:
    • Working time changes trigger WorkingTimeUpdateEvent
    • Date changes (with unchanged working time) trigger ExamRescheduledEvent

The logic is consistent across the codebase and there are no edge cases where working time equality could lead to incorrect event selection, as the system:

  1. Handles working time changes during conduction separately via dedicated message topics
  2. Has distinct handling paths for rescheduling vs working time updates
  3. Maintains clear separation between date changes and duration changes in the event system
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other places where exam rescheduling is handled to verify consistency
rg -A 5 "exam.*reschedul" 

# Search for test cases to verify the rescheduling logic
ast-grep --pattern 'test.*reschedul.*exam'

Length of output: 9430

Copy link
Member

@BBesrour BBesrour left a comment

Choose a reason for hiding this comment

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

code lgtm. thnx for the changes

Copy link
Contributor

@AjayvirS AjayvirS left a comment

Choose a reason for hiding this comment

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

Tested on TS3, notification shown correctly depending on date change and working time change:

image

Copy link
Contributor

@magaupp magaupp left a comment

Choose a reason for hiding this comment

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

Tested on TS3. Reschedule event is displayed as a popup while the exam page is displayed. Reschedule event is not shown while the exam page is not displayed.
Working as intended.
image

@coolchock
Copy link
Contributor Author

Tested on TS2. Everytime I postpone the exam, a pop up notifications is displayed. whether in step 9 or step 13. Is it not a good behaviour to notify students when the exam is postponed or have I misunderstood the testing instructions 😅? Also should students also be notified when the start date of the exam is being pushed ealier? I tried setting the start time of the exam to be earlier as well as due time so that the working time remains the same, students don't see any notifications

image

Notifications should appear in the list when you click the button in the top-right corner (as shown in your picture). However, the modal should not open automatically if you navigate to the exam page after the exam has been rescheduled. The pop-up should only appear automatically if the reschedule event occurs while you are already on the exam page.

Copy link

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test3.artemis.cit.tum.de" is already in use by PR #9921.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Dec 21, 2024
@github-actions github-actions bot removed the deployment-error Added by deployment workflows if an error occured label Dec 21, 2024
@sawys777 sawys777 temporarily deployed to artemis-test1.artemis.cit.tum.de December 21, 2024 21:09 — with GitHub Actions Inactive
Copy link

@sawys777 sawys777 left a comment

Choose a reason for hiding this comment

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

Tested on TS1, everything works as intended

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!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. exam Pull requests that affect the corresponding module ready to merge server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

9 participants