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: Use events instead of notifications for exercise updates - V2 #8578

Closed
wants to merge 36 commits into from

Conversation

coolchock
Copy link
Contributor

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I strictly followed the server 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.

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.
  • 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 added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • 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.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and Jenkins.

Motivation and Context

Description

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise with Complaints enabled
  1. Log in to Artemis
  2. Navigate to Course Administration
  3. ...

Exam Mode Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Exam with a Programming Exercise
  1. Log in to Artemis
  2. Participate in the exam as a student
  3. Make sure that the UI of the programming exercise in the exam mode stays unchanged. You can use the exam mode documentation as reference.
  4. ...

Testserver States

Note

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






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

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Screenshots

# Conflicts:
#	src/main/java/de/tum/in/www1/artemis/web/rest/TextExerciseResource.java
# Conflicts:
#	src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java
…te-events

# Conflicts:
#	src/main/java/de/tum/in/www1/artemis/web/rest/FileUploadExerciseResource.java
#	src/main/webapp/app/exam/participate/exam-participation.component.ts
#	src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts
…te-events

# Conflicts:
#	src/main/java/de/tum/in/www1/artemis/service/ExerciseService.java
@coolchock coolchock requested a review from a team as a code owner May 12, 2024 15:02
@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!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. labels May 12, 2024
Copy link

coderabbitai bot commented May 12, 2024

Walkthrough

The recent updates focus on enhancing the event and notification systems within an educational platform. Key changes include the introduction of a new event type for problem statement updates during exams, restructuring of notification handling in exercise services, and adjustments to service dependencies. These changes aim to improve real-time communication and interaction efficiency during exams and exercise updates.

Changes

File Path Change Summary
.../event/ProblemStatementUpdateEvent.java Introduced an event class for updating problem statements in exams.
.../service/ExerciseService.java Updated dependencies and added notification methods for exercise changes.
.../service/exam/ExamLiveEventsService.java Enhanced to handle sending problem statement update events.
.../service/learningpath/... Removed dependency on ExerciseService and added a new method to check user scores.
.../service/notifications/GroupNotificationService.java Modified notification logic for exercise updates, skipping certain conditions.
.../service/programming/ProgrammingExerciseService.java Integrated ExerciseService for notification handling.
.../web/rest/...ExerciseResource.java Centralized notification logic by replacing direct calls with exerciseService.notifyAboutExerciseChanges.
.../web/rest/dto/examevent/... Added DTOs for handling problem statement update events, including new fields and methods.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between af37347 and ca37e85.
Files ignored due to path filters (2)
  • src/main/resources/config/liquibase/changelog/20240418201711_changelog.xml is excluded by !**/*.xml
  • src/main/resources/config/liquibase/master.xml is excluded by !**/*.xml
Files selected for processing (30)
  • src/main/java/de/tum/in/www1/artemis/domain/exam/event/ProblemStatementUpdateEvent.java (1 hunks)
  • src/main/java/de/tum/in/www1/artemis/service/ExerciseService.java (6 hunks)
  • src/main/java/de/tum/in/www1/artemis/service/exam/ExamLiveEventsService.java (4 hunks)
  • src/main/java/de/tum/in/www1/artemis/service/learningpath/LearningPathRecommendationService.java (5 hunks)
  • src/main/java/de/tum/in/www1/artemis/service/notifications/GroupNotificationService.java (2 hunks)
  • src/main/java/de/tum/in/www1/artemis/service/programming/ProgrammingExerciseService.java (6 hunks)
  • src/main/java/de/tum/in/www1/artemis/web/rest/FileUploadExerciseResource.java (2 hunks)
  • src/main/java/de/tum/in/www1/artemis/web/rest/ModelingExerciseResource.java (1 hunks)
  • src/main/java/de/tum/in/www1/artemis/web/rest/TextExerciseResource.java (1 hunks)
  • src/main/java/de/tum/in/www1/artemis/web/rest/dto/examevent/ExamLiveEventDTO.java (1 hunks)
  • src/main/java/de/tum/in/www1/artemis/web/rest/dto/examevent/ProblemStatementUpdateEventDTO.java (1 hunks)
  • src/main/webapp/app/exam/participate/events/exam-live-events-button.component.ts (1 hunks)
  • src/main/webapp/app/exam/participate/events/exam-live-events-overlay.component.html (1 hunks)
  • src/main/webapp/app/exam/participate/events/exam-live-events-overlay.component.ts (3 hunks)
  • src/main/webapp/app/exam/participate/exam-participation-live-events.service.ts (2 hunks)
  • src/main/webapp/app/exam/participate/exam-participation.component.ts (6 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 (3 hunks)
  • src/main/webapp/app/shared/notification/notification-popup/notification-popup.component.html (1 hunks)
  • src/main/webapp/app/shared/notification/notification-popup/notification-popup.component.ts (8 hunks)
  • src/main/webapp/i18n/de/exam.json (2 hunks)
  • src/main/webapp/i18n/en/exam.json (2 hunks)
  • src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java (7 hunks)
  • src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingExerciseIntegrationTest.java (5 hunks)
  • src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTest.java (5 hunks)
  • src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java (7 hunks)
  • src/test/javascript/spec/component/exam/participate/events/exam-live-events-overlay.component.spec.ts (3 hunks)
  • src/test/javascript/spec/component/exam/participate/exam-participation.component.spec.ts (4 hunks)
  • src/test/javascript/spec/component/shared/notification/notification-popup.component.spec.ts (7 hunks)
Files not reviewed due to errors (1)
  • src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTest.java (no review received)
Additional Context Used
Path-based Instructions (28)
src/main/webapp/app/exam/participate/events/exam-live-events-overlay.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/shared/notification/notification-popup/notification-popup.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/in/www1/artemis/web/rest/dto/examevent/ExamLiveEventDTO.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/in/www1/artemis/web/rest/dto/examevent/ProblemStatementUpdateEventDTO.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/in/www1/artemis/domain/exam/event/ProblemStatementUpdateEvent.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/events/exam-live-events-overlay.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/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/test/javascript/spec/component/exam/participate/events/exam-live-events-overlay.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/java/de/tum/in/www1/artemis/service/exam/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/shared/notification/notification-popup/notification-popup.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/test/javascript/spec/component/shared/notification/notification-popup.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-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/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/main/java/de/tum/in/www1/artemis/service/notifications/GroupNotificationService.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/in/www1/artemis/web/rest/FileUploadExerciseResource.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/in/www1/artemis/web/rest/ModelingExerciseResource.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/in/www1/artemis/service/learningpath/LearningPathRecommendationService.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/in/www1/artemis/web/rest/TextExerciseResource.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/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/in/www1/artemis/service/ExerciseService.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/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

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/java/de/tum/in/www1/artemis/service/programming/ProgrammingExerciseService.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/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/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingExerciseIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

Learnings (7)
src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTest.java (1)
User: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-01-19T15:49:43.303Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
src/main/java/de/tum/in/www1/artemis/service/learningpath/LearningPathRecommendationService.java (1)
User: Strohgelaender
PR: ls1intum/Artemis#8030
File: src/main/java/de/tum/in/www1/artemis/service/CourseScoreCalculationService.java:21-49
Timestamp: 2024-02-16T16:56:16.054Z
Learning: The project consistently avoids using star-imports in Java files.
src/main/java/de/tum/in/www1/artemis/service/ExerciseService.java (1)
User: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-01-19T15:49:43.303Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java (1)
User: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-01-19T15:49:43.303Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
src/main/java/de/tum/in/www1/artemis/service/programming/ProgrammingExerciseService.java (1)
User: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-01-19T15:49:43.303Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingExerciseIntegrationTest.java (1)
User: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-01-19T15:49:43.303Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java (1)
User: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-01-19T15:49:43.303Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
Additional comments not posted (64)
src/main/webapp/app/exam/participate/events/exam-live-events-overlay.component.html (1)

4-9: Ensure proper usage of Angular's new directive syntax.

The use of @for and @if directives aligns with the new Angular syntax guidelines, replacing the older *ngIf and *ngFor. This is a good adoption of the latest features.

src/main/webapp/app/shared/notification/notification-popup/notification-popup.component.html (2)

5-9: Review the conditional rendering logic for notification icons.

The use of @if to conditionally render different icons based on the notification title is a clean and effective way to handle dynamic content. This aligns well with Angular's new directive enhancements.


15-18: Ensure translation functions are used correctly.

The use of Angular's translation pipe (artemisTranslate) in the template ensures that the application remains internationalization-friendly. This is a good practice for maintaining a global application.

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

42-45: Ensure consistency in the visual design for event types.

The addition of the .problemStatementUpdate class with consistent background and border colors aligns with the existing design patterns for event types. This maintains a uniform look and feel across different event notifications.

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

8-8: Verify the import and usage of new event types.

The import of ProblemStatementUpdateEvent and its usage in the component ensures that the new event type is integrated into the system. This is crucial for handling specific types of exam events effectively.


27-29: Review the implementation of new output emitters.

The addition of the onNavigate output emitter is a good practice, allowing parent components to react to navigation events. This enhances the component's reusability and interaction capabilities.


49-51: Ensure type casting is safe and appropriate.

The type casting of this.event to ProblemStatementUpdateEvent in the getter method is appropriate given the context. However, ensure that runtime type checks are in place to prevent errors if the wrong event type is passed.

src/main/java/de/tum/in/www1/artemis/web/rest/dto/examevent/ExamLiveEventDTO.java (1)

20-20: Verify the addition of new DTO subtype.

The addition of ProblemStatementUpdateEventDTO as a subtype in the JsonSubTypes annotation is correctly implemented. This ensures that the new event type can be correctly serialized and deserialized, which is crucial for the system's event handling capabilities.

src/main/java/de/tum/in/www1/artemis/web/rest/dto/examevent/ProblemStatementUpdateEventDTO.java (1)

1-70: Review the structure and implementation of the DTO.

The ProblemStatementUpdateEventDTO is well-structured, extending ExamLiveEventDTO and including specific fields and methods for problem statement updates. This encapsulation and extension are in line with good OOP practices and ensure that the DTO can effectively represent the data needed for problem statement update events.

src/main/java/de/tum/in/www1/artemis/domain/exam/event/ProblemStatementUpdateEvent.java (1)

1-73: Review the structure and implementation of the entity.

The ProblemStatementUpdateEvent entity is well-structured, extending ExamLiveEvent and including specific fields and methods for problem statement updates. This encapsulation and extension are in line with good OOP practices and ensure that the entity can effectively represent the data needed for problem statement update events.

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

9-15: Review the implementation of event type constants.

The definition of USER_DISPLAY_RELEVANT_EVENTS and USER_DISPLAY_RELEVANT_EVENTS_REOPEN constants is a good practice, allowing for easy management and reference of event types relevant to the user. This enhances the maintainability and readability of the code.

src/main/webapp/app/exam/participate/events/exam-live-events-overlay.component.ts (3)

4-4: Ensure that the newly imported ProblemStatementUpdateEvent is utilized appropriately in the component logic.

Verification successful

The verification process has confirmed that the ProblemStatementUpdateEvent is indeed utilized within the component logic of exam-live-events-overlay.component.ts. The search results show that this class is imported and then used to cast an event to the specific type ProblemStatementUpdateEvent. This indicates that the component handles this type of event, aligning with the expectations set in the review comment.

Given this information, the review comment is accurate as the newly imported ProblemStatementUpdateEvent is appropriately utilized in the component logic.

Final Response:

The usage of ProblemStatementUpdateEvent in exam-live-events-overlay.component.ts has been verified and is consistent with the expectations. It is appropriately utilized within the component's logic.

  • Location: src/main/webapp/app/exam/participate/events/exam-live-events-overlay.component.ts
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `ProblemStatementUpdateEvent` is used in the component logic.

# Test: Search for the usage of `ProblemStatementUpdateEvent`. Expect: At least one usage in the component.
rg --type ts 'ProblemStatementUpdateEvent' -- src/main/webapp/app/exam/participate/events/exam-live-events-overlay.component.ts

Length of output: 386


30-30: The addition of ExamExerciseUpdateService in the constructor enhances the component's capability to handle exercise-related updates. Ensure that this service is injected correctly and used where necessary.


63-68: The new navigateToExercise method enhances user interaction by allowing navigation to an exercise from an event. Ensure that the type casting to ProblemStatementUpdateEvent is safe and that the navigateToExamExercise method handles potential errors gracefully.

src/test/javascript/spec/component/exam/participate/events/exam-live-events-overlay.component.spec.ts (3)

8-8: The addition of ExamExerciseUpdateService in the test setup is necessary for testing the new navigation functionality. Ensure that this service is mocked appropriately.


14-14: The mock for ExamExerciseUpdateService is correctly set up. This is crucial for isolating the component behavior during testing.


97-109: The new test case for navigating to an exercise and acknowledging an event is comprehensive. It correctly mocks the necessary services and checks the expected outcomes. Ensure that all edge cases are considered, such as invalid event data.

src/main/java/de/tum/in/www1/artemis/service/exam/ExamLiveEventsService.java (2)

16-16: The import of ProblemStatementUpdateEvent is necessary for the new functionality. Ensure that this class is used correctly throughout the service.


136-178: The new methods for creating and sending problem statement update events are well-structured and follow good Java practices. However, ensure that the userRepository.getUser() method is thread-safe since it is used in an asynchronous context.

src/main/webapp/app/shared/notification/notification-popup/notification-popup.component.ts (2)

Line range hint 97-140: The new navigation logic based on the notification type is implemented correctly. However, ensure that all new routes and parameters are correctly configured in the router settings.


151-163: The updated logic for adding notifications based on their type is a good improvement. Ensure that the settings for allowing notifications are correctly implemented and tested.

src/test/javascript/spec/component/shared/notification/notification-popup.component.spec.ts (2)

13-13: The new imports for notification models are necessary for the new test cases. Ensure that these models are used correctly in the tests.


38-49: The new test case for handling new message notifications is well-structured. Ensure that the JSON structure used in the tests matches the actual application data structure.

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

22-22: The addition of PROBLEM_STATEMENT_UPDATE to ExamLiveEventType is necessary for handling new types of events. Ensure that this new event type is handled consistently throughout the service.


48-53: The new ProblemStatementUpdateEvent type is well-defined with appropriate fields. Ensure that this type is used correctly in the service methods that handle events.

src/main/java/de/tum/in/www1/artemis/service/notifications/GroupNotificationService.java (1)

82-86: The modification to skip notifications for exam exercises aligns with the PR's objective to use events instead of notifications. This is a good application of the single responsibility principle, as the method now clearly defines when not to send notifications.

src/main/java/de/tum/in/www1/artemis/web/rest/FileUploadExerciseResource.java (1)

284-284: The addition of notifyAboutExerciseChanges in the update process ensures that any changes to the exercise are communicated effectively. This centralization of notification logic is a good practice and reduces duplication.

src/main/java/de/tum/in/www1/artemis/web/rest/ModelingExerciseResource.java (1)

247-248: Integration of notifyAboutExerciseChanges method in updateModelingExercise.

The integration of the notifyAboutExerciseChanges method from ExerciseService into the updateModelingExercise method is correctly implemented. This change aligns with the PR's objective to shift from notifications to events for exercise updates in exam mode.

src/main/java/de/tum/in/www1/artemis/service/learningpath/LearningPathRecommendationService.java (5)

21-22: Addition of jakarta.validation.constraints.NotNull import.

The addition of the NotNull import is justified as it is used in the new method hasScoredAtLeast to ensure that neither the Exercise nor the User objects are null when passed to the method. This is a good practice for ensuring data integrity.


93-93: Modification of the constructor to include ParticipantScoreService.

The inclusion of ParticipantScoreService in the constructor is appropriate and aligns with the usage of this service in the newly added method hasScoredAtLeast. This change supports the functionality of checking if a user has achieved a minimum score on an exercise, which is crucial for the learning path recommendations.


611-626: Addition of the hasScoredAtLeast method.

The hasScoredAtLeast method is correctly implemented and uses the NotNull annotation to ensure that the method parameters are not null. This method enhances the functionality of the learning path recommendation service by allowing it to consider user scores on exercises, which is essential for personalized learning recommendations.


446-446: Modification of the scheduleExercisesByDistribution method to include a new filtering condition.

The modification to include a filtering condition in the scheduleExercisesByDistribution method is correctly implemented. This condition uses the hasScoredAtLeast method to filter out exercises where the user has already scored above a certain threshold, which is a sensible addition for optimizing the learning path recommendations.


29-29: Modification of the getRecommendedOrderOfLearningObjects method to handle new logic for learning objects.

The modifications to the getRecommendedOrderOfLearningObjects method are correctly implemented and integrate well with the existing functionality. The new logic enhances the method's ability to provide more accurate and personalized learning object recommendations within a competency.

src/main/java/de/tum/in/www1/artemis/web/rest/TextExerciseResource.java (1)

281-282: Ensure proper integration of notifyAboutExerciseChanges method.

Verification successful

The implementation of the notifyAboutExerciseChanges method in ExerciseService.java has been reviewed. The method differentiates between course exercises and exam exercises, handling notifications appropriately:

  • For course exercises, it schedules notifications based on the updates.
  • For exam exercises, it specifically checks for changes in the problem statement and triggers live event updates if there are changes.

This implementation aligns with the intended functionality of handling event creation and dispatch based on the type of exercise and the nature of the updates. The method is consistently used across different exercise types in the codebase, suggesting a proper integration.

Conclusion:
The notifyAboutExerciseChanges method is properly integrated and functions as expected across different parts of the codebase. It handles event creation and dispatch based on the exercise type and specific changes, which aligns with the changes described in the pull request.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `notifyAboutExerciseChanges` method properly handles event creation and dispatch.

# Test: Search for the method implementation and usage in other parts of the codebase.
rg --type java $'notifyAboutExerciseChanges'

Length of output: 1247



Script:

#!/bin/bash
# Description: View the implementation of `notifyAboutExerciseChanges` in `ExerciseService.java`.

# Display the method implementation to verify event handling.
rg --type java -A 10 -B 2 'public void notifyAboutExerciseChanges' src/main/java/de/tum/in/www1/artemis/service/ExerciseService.java

Length of output: 826

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

39-45: Ensure proper import and service initialization for new event handling.

The addition of ExamParticipationLiveEventsService and ExamExerciseUpdateService is aligned with the PR's objective to shift from notifications to events for exercise updates. This change should enhance the handling of live updates during exams.


99-100: Manage event subscriptions effectively.

The initialization of workingTimeUpdateEventsSubscription and problemStatementUpdateEventsSubscription is crucial for handling the new event-driven updates. This setup allows the component to react to live updates efficiently.

src/main/java/de/tum/in/www1/artemis/service/ExerciseService.java (4)

19-19: Consider using specific imports instead of wildcard imports for better clarity and to avoid potential conflicts.

- import org.apache.commons.lang3.StringUtils;
+ import org.apache.commons.lang3.StringUtils.equals;
Skipped due to learnings
User: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-01-19T15:49:43.303Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.

62-63: The addition of ExamLiveEventsService and GroupNotificationScheduleService imports aligns with the PR's objectives to enhance event handling for exam exercises.


134-135: The modification of the constructor to include ExamLiveEventsService and GroupNotificationScheduleService is correctly implemented and necessary for the integration of the new event handling system.


794-800: The implementation of notifyAboutExerciseChanges method is robust, correctly distinguishing between course and exam exercises and using appropriate services for each.

src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java (5)

25-25: Ensure that SpyBean is the appropriate choice for dependency injection in this context.

Verification successful

The output from the executed script shows extensive usage of @SpyBean across various test classes in the project. This indicates that the use of @SpyBean is a common practice within the test suite of this application, suggesting that its use in FileUploadExerciseIntegrationTest.java is consistent with the testing strategies employed elsewhere in the project.

Given this widespread usage, it's reasonable to infer that @SpyBean is an appropriate choice for dependency injection in the test context of this project, especially for integration tests where partial mocking of beans might be necessary.

Since the usage of @SpyBean aligns with the project's testing conventions, there appears to be no issue with its application in the context of the file under review.


Usage of @SpyBean is appropriate and consistent with project standards

  • The use of @SpyBean in FileUploadExerciseIntegrationTest.java is consistent with its usage across numerous other test classes within the project.
  • This suggests that @SpyBean is a standard practice for the testing strategy in this application, particularly for integration tests that might require partial mocking of Spring beans.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `SpyBean` in the test context to ensure it's suitable for the testing scenario.

# Test: Search for the usage of `SpyBean` in other test files for consistency.
rg --type java '@SpyBean' src/test/java/

Length of output: 4833


55-56: Added dependencies on ExamLiveEventsService and GroupNotificationScheduleService are aligned with the PR's objectives to enhance event handling.


442-443: Verify that the never() and times(1) usage with examLiveEventsService and groupNotificationScheduleService respectively are correctly applied according to the expected behavior in the test scenarios.

Verification successful

The extracted test method logic from the FileUploadExerciseIntegrationTest.java confirms the usage of verify(examLiveEventsService, never()).createAndSendProblemStatementUpdateEvent(any(), any()); and verify(groupNotificationScheduleService, times(1)).checkAndCreateAppropriateNotificationsWhenUpdatingExercise(any(), any(), any());. These verifications are part of a test scenario where a FileUploadExercise is updated and the response is checked for correctness.

The use of never() with examLiveEventsService suggests that in this particular test scenario, there should be no event triggered for updating the problem statement, which is consistent with the test's setup and expectations. Similarly, the use of times(1) with groupNotificationScheduleService indicates that exactly one notification should be created and sent when the exercise is updated, which aligns with the test's purpose to verify notification behavior upon exercise updates.

Given this context, the usage of never() and times(1) appears to be correctly applied according to the expected behavior in the test scenarios. Therefore, the review comment is consistent with the codebase.

  • The test ensures that no problem statement update event is sent when updating a file upload exercise.
  • It also checks that exactly one notification is created and sent during the exercise update process.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct usage of Mockito verification methods `never()` and `times(1)` in the test scenarios.

# Test: Check the logic in the test methods to ensure that the usage of these methods is justified.
rg --type java 'verify\(.*never\(\)' src/test/java/
rg --type java 'verify\(.*times\(1\)\)' src/test/java/

Length of output: 29151



Script:

#!/bin/bash
# Description: Extract the test method logic surrounding the usage of Mockito verification methods `never()` and `times(1)` for `examLiveEventsService` and `groupNotificationScheduleService` in FileUploadExerciseIntegrationTest.java.

# Extract relevant test method logic
rg --type java -C 10 'verify\(.*examLiveEventsService, never\(\)' src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java
rg --type java -C 10 'verify\(.*groupNotificationScheduleService, times\(1\)\)' src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java

Length of output: 3911


464-464: Ensure that the setProblemStatement method is correctly used and aligns with the new event-driven architecture.


473-474: Correct usage of createAndSendProblemStatementUpdateEvent and checkAndCreateAppropriateNotificationsWhenUpdatingExercise methods in the test ensures proper integration with the new event system.

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

58-58: Import of ExamExerciseUpdateService added.

This import is necessary for the new functionality related to handling exercise updates via events instead of notifications.


71-71: Service ExamExerciseUpdateService added to the component.

This addition aligns with the PR's objective to handle exercise updates through events, enhancing the component's capabilities to react to live updates during exams.


132-132: Service ExamExerciseUpdateService is being injected.

Proper dependency injection of ExamExerciseUpdateService ensures that the component can utilize this service effectively for handling live exercise updates.


546-558: Websocket subscription for problem statement updates.

This test ensures that the component correctly handles incoming problem statement updates via websockets, which is crucial for maintaining the integrity and timeliness of exam content.

src/main/webapp/i18n/en/exam.json (3)

185-186: New event type for attendance checks added correctly.


191-191: New functionality to navigate to exercises from events added correctly.


202-204: Enhancements to problem statement update events added correctly, improving clarity and user information.

src/main/java/de/tum/in/www1/artemis/service/programming/ProgrammingExerciseService.java (3)

Line range hint 179-226: Ensure proper dependency injection and service initialization.

The constructor has been modified to include ExerciseService as a dependency. This change aligns with the PR's objective to enhance event handling by centralizing notification logic in ExerciseService. The constructor's parameters are well-organized, promoting clean code and maintainability.


562-563: Verify the integration of ExerciseService in the updateProgrammingExercise method.

This script checks the usage of updateProgrammingExercise to ensure that the integration of ExerciseService is done correctly and does not introduce any duplicate logic or errors.


674-674: Ensure the notifyAboutExerciseChanges method is correctly used in the updateProblemStatement method.

The integration of ExerciseService in the updateProblemStatement method for notifying about exercise changes is correctly implemented. This usage aligns with the PR's goals to centralize notification logic, enhancing the maintainability and scalability of the notification system.

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

185-186: Ensure the translations maintain an informal tone as per the project guidelines.


201-204: The translation for "problemStatementUpdate" should maintain an informal tone, especially in the interaction messages.

src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingExerciseIntegrationTest.java (4)

24-24: Added @SpyBean for ExamLiveEventsService.

This addition aligns with the PR's objective to shift from notifications to events for exercise updates in exam mode.


130-132: Introduced @SpyBean for ExamLiveEventsService.

This change is crucial for testing the integration of the new event-based update system in exam mode. It allows for the verification of method invocations without affecting the actual business logic.


248-248: Correct usage of Mockito's never() to ensure that createAndSendProblemStatementUpdateEvent is not called for non-exam exercises.

This ensures that the event system behaves correctly by not triggering events where they are not applicable.


269-270: Verification of createAndSendProblemStatementUpdateEvent being called exactly once.

This is a key part of ensuring that the new event system is triggered appropriately for exam exercises.

src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java (3)

7-10: Ensure the newly added static imports are utilized within the test cases.

Verification successful

The verification script confirms that the file TextExerciseIntegrationTest.java does indeed utilize the newly added static imports from the Mockito library. This means that the imports for org.mockito.ArgumentMatchers.any, org.mockito.Mockito.never, org.mockito.Mockito.times, and org.mockito.Mockito.verify are being used in the test cases within this file.

Since the script output shows that the file contains matches for all the specified imports, we can conclude that the static imports are appropriately utilized in the test cases.


Static Imports Verified in Test Cases

The static imports added to TextExerciseIntegrationTest.java are confirmed to be utilized within the test cases. This ensures that the imports are not redundant and are serving their intended purpose in the test suite.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of newly added static imports in TextExerciseIntegrationTest.java.

# Test: Search for usage of the static imports. Expect: At least one usage of each import.
rg --type java --files-with-matches 'org.mockito.ArgumentMatchers.any|org.mockito.Mockito.never|org.mockito.Mockito.times|org.mockito.Mockito.verify' src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java

Length of output: 301


153-155: Ensure GroupNotificationScheduleService is appropriately utilized in the test cases where its methods are expected to be called.

Verification successful

The verification process has confirmed that the GroupNotificationScheduleService is indeed utilized within the TextExerciseIntegrationTest.java. The service is specifically used in assertions to verify the behavior of the method checkAndCreateAppropriateNotificationsWhenUpdatingExercise under different conditions. This aligns with the expectation set in the review comment to ensure that the service is appropriately utilized in the test cases.

  • The service is verified to never be called in one scenario (verify(groupNotificationScheduleService, never())).
  • In another scenario, it is verified to be called exactly once (verify(groupNotificationScheduleService, times(1))).

This demonstrates that the GroupNotificationScheduleService is actively involved in the test logic, confirming that it is not just declared but also appropriately integrated into the test validations.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `GroupNotificationScheduleService` in TextExerciseIntegrationTest.java.

# Test: Search for method calls to `GroupNotificationScheduleService`. Expect: At least one method call.
rg --type java --files-with-matches 'groupNotificationScheduleService' src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java

Length of output: 220



Script:

#!/bin/bash
# Description: Extract the usage details of `GroupNotificationScheduleService` in TextExerciseIntegrationTest.java.

# Extract lines where `groupNotificationScheduleService` is referenced to understand the context of its usage.
rg 'groupNotificationScheduleService' src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java -C 3

Length of output: 1430


430-432: The method updateTextExercise now includes updates to the problem statement. Ensure that the new problem statement is correctly handled and triggers appropriate events or notifications if required.

Verification successful

The examination of the setProblemStatement method usage within the TextExerciseIntegrationTest.java file reveals that after updating the problem statement, there are indeed triggers for events or notifications. Specifically, the method verify(examLiveEventsService, times(1)).createAndSendProblemStatementUpdateEvent(any(), any()) is called, which indicates that an event related to the problem statement update is being created and sent. Additionally, there is a verification that no notifications are scheduled when updating the exercise through verify(groupNotificationScheduleService, never()).checkAndCreateAppropriateNotificationsWhenUpdatingExercise(any(), any(), any()).

This confirms that the new problem statement is correctly handled and triggers appropriate events, as required by the original review comment.

  • The event triggering is confirmed by the call to createAndSendProblemStatementUpdateEvent.
  • The absence of notifications is confirmed by the verification that checkAndCreateAppropriateNotificationsWhenUpdatingExercise is never called.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of problem statement updates in `updateTextExercise`.

# Test: Search for logic handling the new problem statement. Expect: Logic that triggers events or notifications.
rg --type java --files-with-matches 'setProblemStatement' src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java

Length of output: 207



Script:

#!/bin/bash
# Description: Extract the usage of `setProblemStatement` and check for associated logic related to events or notifications.

# Extract lines around the usage of `setProblemStatement` to understand the context and check for event/notification logic.
rg --type java --context 10 'setProblemStatement' src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java

Length of output: 2774


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Comment on lines +591 to +615
if (this.workingTimeUpdateEventsSubscription) {
this.workingTimeUpdateEventsSubscription.unsubscribe();
}
this.liveEventsSubscription = this.liveEventsService.observeNewEventsAsSystem([ExamLiveEventType.WORKING_TIME_UPDATE]).subscribe((event: WorkingTimeUpdateEvent) => {
// Create new object to make change detection work, otherwise the date will not update
this.studentExam = { ...this.studentExam, workingTime: event.newWorkingTime! };
this.examParticipationService.currentlyLoadedStudentExam.next(this.studentExam);
this.individualStudentEndDate = dayjs(startDate).add(this.studentExam.workingTime!, 'seconds');
this.individualStudentEndDateWithGracePeriod = this.individualStudentEndDate.clone().add(this.exam.gracePeriod!, 'seconds');
this.liveEventsService.acknowledgeEvent(event, false);
});
this.workingTimeUpdateEventsSubscription = this.liveEventsService
.observeNewEventsAsSystem([ExamLiveEventType.WORKING_TIME_UPDATE])
.subscribe((event: WorkingTimeUpdateEvent) => {
// Create new object to make change detection work, otherwise the date will not update
this.studentExam = { ...this.studentExam, workingTime: event.newWorkingTime! };
this.examParticipationService.currentlyLoadedStudentExam.next(this.studentExam);
this.individualStudentEndDate = dayjs(startDate).add(this.studentExam.workingTime!, 'seconds');
this.individualStudentEndDateWithGracePeriod = this.individualStudentEndDate.clone().add(this.exam.gracePeriod!, 'seconds');
this.liveEventsService.acknowledgeEvent(event, false);
});
}

private subscribeToProblemStatementUpdates() {
if (this.problemStatementUpdateEventsSubscription) {
this.problemStatementUpdateEventsSubscription.unsubscribe();
}
this.problemStatementUpdateEventsSubscription = this.liveEventsService
.observeNewEventsAsSystem([ExamLiveEventType.PROBLEM_STATEMENT_UPDATE])
.subscribe((event: ProblemStatementUpdateEvent) => {
this.examExerciseUpdateService.updateLiveExamExercise(event.exerciseId, event.problemStatement);
this.liveEventsService.acknowledgeEvent(event, false);
});
Copy link

Choose a reason for hiding this comment

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

Optimize event subscription logic.

The methods subscribeToWorkingTimeUpdates and subscribeToProblemStatementUpdates handle the subscription to the new event types. However, consider refactoring to reduce redundancy and improve error handling. For instance, unsubscribing before subscribing can be extracted into a utility function to avoid duplication.

private manageSubscription(subscription: Subscription, newSubscriptionCallback: () => Subscription): void {
    if (subscription) {
        subscription.unsubscribe();
    }
    subscription = newSubscriptionCallback();
}

Then use this utility method in both subscribeToWorkingTimeUpdates and subscribeToProblemStatementUpdates.

},
"from": "von",
"acknowledge": "Bestätigen",
"acknowledgeAll": "Alle bestätigen",
"navigateToExercise": "Navigiere zur Aufgabe",
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search results indicate that the formal pronoun "Sie" is used in various German translation files, including the exam.json file which contains the specific translation in question. This suggests that the translation does not consistently maintain an informal tone as required.

Here are the specific instances where the formal tone is used:

  • student-dashboard.json
    • Multiple instances where "Sie" is used in explanations about grades and bonus points.
  • tutorialGroups.json
    • Used in the context of explaining the timezone feature.
  • exam.json
    • Used in descriptions and announcements within the exam context.
  • featureOverview.json
    • Used extensively in descriptions about exam processes and features.
  • exerciseChatbot.json
    • Used in descriptions about the functionalities of a chatbot.
  • competency.json
    • Mentioned in the context of optional competencies.

Given these findings, it is clear that the informal tone is not consistently applied across the German translations in the application. This includes the specific line under review in exam.json.

Action Required:

  • Review and revise the translations to ensure consistency with the informal tone requirement across all German translation files.
Analysis chain

Verify that the translation for "Navigate to exercise" is consistent with the informal tone required.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the informal tone in German translations.

# Test: Search for formal tone usage. Expect: No occurrences of formal tone.
rg --type json 'Sie' src/main/webapp/i18n/de/**/*.json

Length of output: 130



Script:

#!/bin/bash
# Description: Re-verify the informal tone in German translations by correcting the path issue.

# Test: Search for formal tone usage. Expect: No occurrences of formal tone.
rg --type json 'Sie' src/main/webapp/i18n/de/

Length of output: 3451

Comment on lines +150 to +152
@SpyBean
private ExamLiveEventsService examLiveEventsService;

Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The ExamLiveEventsService is declared in TextExerciseIntegrationTest.java but none of its methods are called within the test cases. This might indicate an oversight or unnecessary declaration. It would be beneficial to review the necessity of this service in the test setup.

  • TextExerciseIntegrationTest.java: ExamLiveEventsService is declared but not utilized.
Analysis chain

Ensure ExamLiveEventsService is appropriately utilized in the test cases where its methods are expected to be called.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `ExamLiveEventsService` in TextExerciseIntegrationTest.java.

# Test: Search for method calls to `ExamLiveEventsService`. Expect: At least one method call.
rg --type java --files-with-matches 'examLiveEventsService' src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java

Length of output: 209



Script:

#!/bin/bash
# Description: Extract specific method calls to `ExamLiveEventsService` in TextExerciseIntegrationTest.java.

# Test: Search for specific method calls to `examLiveEventsService`.
rg 'examLiveEventsService\.\w+' src/test/java/de/tum/in/www1/artemis/text/TextExerciseIntegrationTest.java

Length of output: 108

Comment on lines +62 to +72
@case (ExamLiveEventType.PROBLEM_STATEMENT_UPDATE) {
<div>
<div>
{{ 'artemisApp.exam.events.messages.problemStatementUpdate.description' | artemisTranslate: { exerciseName: problemStatementUpdateEvent.exerciseName } }}
</div>
@if (problemStatementUpdateEvent.text) {
<div>{{ 'artemisApp.exam.events.messages.problemStatementUpdate.instructorMessage' | artemisTranslate }}</div>
<div [innerHTML]="problemStatementUpdateEvent.text | htmlForMarkdown"></div>
}
</div>
}
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search for the i18n keys problemStatementUpdate.description and problemStatementUpdate.instructorMessage within the language-specific directories (de and en) did not yield any results. This confirms that these translation keys are not present in the i18n files, which is necessary for the proper display and localization of the new case for ProblemStatementUpdateEvent in the application.

Action Required: Add Missing i18n Keys

  • The translation keys problemStatementUpdate.description and problemStatementUpdate.instructorMessage are missing from the i18n files. Please add these keys to the respective language files to ensure the application displays the correct localized messages.
Analysis chain

The new case for ProblemStatementUpdateEvent correctly displays the event details. Ensure that the translations for problemStatementUpdate.description and problemStatementUpdate.instructorMessage are provided in the i18n files.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the existence of new i18n keys for problem statement updates.

# Test: Search for the new i18n keys in translation files. Expect: Keys exist.
rg 'problemStatementUpdate.description|problemStatementUpdate.instructorMessage' -- src/main/webapp/i18n

Length of output: 106



Script:

#!/bin/bash
# Description: List all i18n translation files to confirm the scope of the search.

# List all files in the i18n directory to ensure all were considered in the initial search.
ls src/main/webapp/i18n

Length of output: 31



Script:

#!/bin/bash
# Description: Search for the i18n keys within language-specific directories.

# Search for the specified i18n keys in both 'de' and 'en' translation files.
rg 'problemStatementUpdate.description|problemStatementUpdate.instructorMessage' -- src/main/webapp/i18n/de
rg 'problemStatementUpdate.description|problemStatementUpdate.instructorMessage' -- src/main/webapp/i18n/en

Length of output: 219

Comment on lines +76 to +85
@if (showAcknowledge) {
<button class="btn btn-primary w-100 mt-2" (click)="acknowledgeEvent()">
<fa-icon [icon]="faCheck" />
<span jhiTranslate="artemisApp.exam.events.acknowledge"></span>
</button>
}
@if (event.eventType === ExamLiveEventType.PROBLEM_STATEMENT_UPDATE) {
<button class="btn btn-primary w-100 mt-2" (click)="navigateToExercise()">
<span jhiTranslate="artemisApp.exam.events.navigateToExercise"></span>
</button>
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The Angular version used in the project is 17.3.8, which supports the event binding syntax (click)="methodName()" as seen in the HTML snippet. However, the conditional rendering syntax @if is not standard Angular syntax; Angular uses *ngIf for such purposes. This suggests a potential issue with the conditional rendering in the provided HTML code.

  • The event handlers acknowledgeEvent() and navigateToExercise() are correctly implemented and bound in exam-live-event.component.ts.

Recommendation:

  • Replace @if with *ngIf in the HTML file to align with standard Angular practices.
Analysis chain

The buttons for acknowledging and navigating to exercises are implemented using the new Angular syntax. Verify that this syntax is supported in the project's Angular version and that the event handlers are correctly bound.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify support for new Angular syntax and correct binding of event handlers.

# Test: Check Angular version and search for event handler implementations. Expect: Supported syntax and correct implementations.
cat package.json | jq '.dependencies.angular'
rg --type ts '(acknowledgeEvent|navigateToExercise)' -- src/main/webapp/app/exam/shared/events

Length of output: 335



Script:

#!/bin/bash
# Correcting the query to fetch Angular version from package.json
cat package.json | jq '.dependencies["@angular/core"]'

Length of output: 65

@undernagruzez undernagruzez temporarily deployed to artemis-test4.artemis.cit.tum.de May 17, 2024 18:49 — with GitHub Actions Inactive
@coolchock coolchock closed this May 18, 2024
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. 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.

None yet

2 participants