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

Lectures: Add reference between video unit and attachment unit #10468

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

Conversation

sebastianloose
Copy link
Contributor

@sebastianloose sebastianloose commented Mar 12, 2025

⚠️ Do not deploy - contains database migration ⚠️

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 added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Iris needs to know which video unit belongs to which attachment unit.

Description

To enhance Iris chats and answer with more context from video units and attachment units, Iris needs to know exactly which video unit is connected to which attachment unit. This ensures both types of units are used when answering students queries. For that a OneToOne reference between video units and attachment units has been added.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Lecture
  • Multiple attachment and video units
  1. Log in to Artemis.
  2. Navigate to a lecture.
  3. Edit or create a new video unit.
  4. Select an attachment unit from the dropdown menu and save the video unit.
  5. Edit or create another video unit.
  6. Verify that the previously selected attachment unit no longer appears in the dropdown menu (since it is already linked to another video unit).
  7. Edit the first video unit and select the blank option from the dropdown to remove its connection to the attachment unit.
  8. Edit or create another video unit and confirm that the previously linked attachment unit now appears again in the dropdown menu, allowing you to select it and save the video unit.

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

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

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Screenshots

image

Summary by CodeRabbit

  • New Features

    • Enabled bidirectional linking between video and attachment units for a richer content management experience.
    • Enhanced video unit management forms to allow selecting an associated attachment unit via a new dropdown.
    • Improved localization by incorporating new attachment unit labels in multiple languages.
  • Tests

    • Extended test coverage to verify proper attachment unit selection and filtering during video unit creation and editing.

@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. lecture Pull requests that affect the corresponding module labels Mar 12, 2025
@sebastianloose sebastianloose marked this pull request as ready for review March 12, 2025 17:13
@sebastianloose sebastianloose requested a review from a team as a code owner March 12, 2025 17:13
Copy link

coderabbitai bot commented Mar 12, 2025

Walkthrough

This update establishes a bidirectional one-to-one relationship between video units and attachment units. On the backend, new fields and accessor methods are added to the AttachmentUnit and VideoUnit classes with appropriate JPA and JSON annotations. On the frontend, Angular models and form components are updated to include optional properties and inputs for managing these associations. In addition, test suites and localization files are modified to support and verify the new relationship.

Changes

Files Change Summary
src/main/java/de/tum/cit/aet/artemis/lecture/domain/AttachmentUnit.java
src/main/java/de/tum/cit/aet/artemis/lecture/domain/VideoUnit.java
Added bidirectional one-to-one relationship fields (correspondingVideoUnit in AttachmentUnit and correspondingAttachmentUnit in VideoUnit) with corresponding getter/setter methods, JPA, and JSON annotations.
src/main/webapp/app/entities/lecture-unit/attachmentUnit.model.ts
src/main/webapp/app/entities/lecture-unit/videoUnit.model.ts
Extended Angular models with new optional properties (correspondingVideoUnit, correspondingAttachmentUnit) and updated relevant import statements.
src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/** Updated create and edit video unit components and form components: added new input properties (formData, availableAttachmentUnits), modified async data retrieval and filtering logic, and enhanced form groups to allow attachment unit selection.
src/main/webapp/i18n/{de,en}/lectureUnit.json Added new localization keys for attachment unit labels in both German and English.
src/test/javascript/spec/** Enhanced test suites across create, edit, and form components to verify the handling of attachment units, including new test cases and mock setups with LectureService.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Component
    participant LectureService
    participant VideoForm

    User->>Component: Initiate create/edit video unit
    Component->>LectureService: Request lecture details
    LectureService-->>Component: Return lecture details (with attachment units)
    Component->>Component: Filter available attachment units
    Component->>VideoForm: Supply formData and availableAttachmentUnits
    VideoForm-->>User: Render form with attachment unit selection
Loading

Possibly related PRs

  • Lectures: Fix lecture unit file attachment names #9721: The changes in the main PR, which involve adding a correspondingVideoUnit field to the AttachmentUnit class, are related to the changes in the retrieved PR, which introduces a correspondingAttachmentUnit field in the VideoUnit class, as both modifications establish a one-to-one relationship between these two classes.
  • General: Add course archive for old courses from previous semesters #9343: The changes in the main PR, which involve adding a correspondingVideoUnit field to the AttachmentUnit class, are related to the retrieved PR that introduces a correspondingAttachmentUnit field to the VideoUnit class, as both modifications establish a one-to-one relationship between these two classes.
  • Lectures: Add editing functionality to attachment PDF preview #9265: The changes in the main PR, which involve adding a correspondingVideoUnit field and methods to the AttachmentUnit class, are related to the changes in the retrieved PR, which adds a correspondingAttachmentUnit field and methods to the VideoUnit class, as both modifications establish a one-to-one relationship between these two classes.

Suggested labels

feature, ready to merge, core, refactoring

Suggested reviewers

  • florian-glombik
  • SimonEntholzer
  • JohannesStoehr
  • HawKhiem
  • az108
  • Cathy0123456789
  • krusche

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between db4230a and 33fff21.

📒 Files selected for processing (1)
  • src/test/javascript/spec/component/lecture-unit/video-unit/edit-video-unit.component.spec.ts (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/javascript/spec/component/lecture-unit/video-unit/edit-video-unit.component.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-tests
  • GitHub Check: client-tests-selected
  • GitHub Check: server-style
  • GitHub Check: server-tests
  • GitHub Check: Analyse

🪧 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 generate docstrings to generate docstrings for this 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: 2

🔭 Outside diff range comments (1)
src/test/javascript/spec/component/lecture/lecture-units.component.spec.ts (1)

82-99: 🛠️ Refactor suggestion

Check the response type in mocked lecture data.
You're assigning new Lecture() to HttpResponse<VideoUnit>. Update the generic type to Lecture if that’s truly the returned object.

🧹 Nitpick comments (2)
src/test/javascript/spec/component/lecture-unit/video-unit/create-video-unit.component.spec.ts (1)

163-163: Fix typo in test description.

There's a typo in the test description: "expect" should be "except".

-  it('should provide all attachment units expect attachment unit a attached to a different video unit', fakeAsync(() => {
+  it('should provide all attachment units except attachment unit attached to a different video unit', fakeAsync(() => {
src/main/webapp/app/lecture/lecture-units/lecture-units.component.ts (1)

340-355: Well-implemented method for fetching attachment units.

The fetchAvailableAttachmentUnitsForVideoUnit method is well-structured with proper error handling and filtering logic. Consider adding a comment explaining the purpose of the empty object at the beginning of the availableAttachmentUnits array (it's likely for creating a "none" option in a dropdown).

                this.availableAttachmentUnits = [
-                    {},
+                    {}, // Empty object to provide a "None" option in the dropdown
                    ...(lecture.body?.lectureUnits ?? []).filter((unit: LectureUnit) => {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b099120 and db4230a.

⛔ Files ignored due to path filters (2)
  • src/main/resources/config/liquibase/changelog/20250312010510_changelog.xml is excluded by !**/*.xml
  • src/main/resources/config/liquibase/master.xml is excluded by !**/*.xml
📒 Files selected for processing (18)
  • src/main/java/de/tum/cit/aet/artemis/lecture/domain/AttachmentUnit.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/lecture/domain/VideoUnit.java (2 hunks)
  • src/main/webapp/app/entities/lecture-unit/attachmentUnit.model.ts (1 hunks)
  • src/main/webapp/app/entities/lecture-unit/videoUnit.model.ts (1 hunks)
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/create-video-unit/create-video-unit.component.html (1 hunks)
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/create-video-unit/create-video-unit.component.ts (3 hunks)
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/edit-video-unit/edit-video-unit.component.html (1 hunks)
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/edit-video-unit/edit-video-unit.component.ts (3 hunks)
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component.html (1 hunks)
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component.ts (3 hunks)
  • src/main/webapp/app/lecture/lecture-units/lecture-units.component.html (1 hunks)
  • src/main/webapp/app/lecture/lecture-units/lecture-units.component.ts (7 hunks)
  • src/main/webapp/i18n/de/lectureUnit.json (1 hunks)
  • src/main/webapp/i18n/en/lectureUnit.json (1 hunks)
  • src/test/javascript/spec/component/lecture-unit/video-unit/create-video-unit.component.spec.ts (3 hunks)
  • src/test/javascript/spec/component/lecture-unit/video-unit/edit-video-unit.component.spec.ts (7 hunks)
  • src/test/javascript/spec/component/lecture-unit/video-unit/video-unit-form.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/lecture/lecture-units.component.spec.ts (7 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`src/main/webapp/i18n/de/**/*.json`: German language transla...

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/i18n/de/lectureUnit.json
`src/main/webapp/**/*.ts`: angular_style:https://angular.io/...

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/entities/lecture-unit/videoUnit.model.ts
  • src/main/webapp/app/entities/lecture-unit/attachmentUnit.model.ts
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component.ts
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/create-video-unit/create-video-unit.component.ts
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/edit-video-unit/edit-video-unit.component.ts
  • src/main/webapp/app/lecture/lecture-units/lecture-units.component.ts
`src/test/javascript/spec/**/*.ts`: jest: true; mock: NgMock...

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/test/javascript/spec/component/lecture-unit/video-unit/video-unit-form.component.spec.ts
  • src/test/javascript/spec/component/lecture/lecture-units.component.spec.ts
  • src/test/javascript/spec/component/lecture-unit/video-unit/edit-video-unit.component.spec.ts
  • src/test/javascript/spec/component/lecture-unit/video-unit/create-video-unit.component.spec.ts
`src/main/webapp/**/*.html`: @if and @for are new and valid ...

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/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component.html
  • src/main/webapp/app/lecture/lecture-units/lecture-units.component.html
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/create-video-unit/create-video-unit.component.html
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/edit-video-unit/edit-video-unit.component.html
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

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/lecture/domain/VideoUnit.java
  • src/main/java/de/tum/cit/aet/artemis/lecture/domain/AttachmentUnit.java
🧠 Learnings (1)
src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component.ts (1)
Learnt from: florian-glombik
PR: ls1intum/Artemis#9656
File: src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts:69-71
Timestamp: 2025-03-12T13:33:48.254Z
Learning: In the `src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts`, the `isFormValid` computed property intentionally uses a logical OR between `this.statusChanges() === 'VALID'` and `this.fileName()` to mirror the original `isSubmitPossible` getter, ensuring consistent form validation behavior.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (53)
src/main/webapp/app/entities/lecture-unit/attachmentUnit.model.ts (1)

4-4: Looks good - bidirectional relationship established

The addition of the VideoUnit import and the correspondingVideoUnit property correctly implements the one-to-one relationship between AttachmentUnit and VideoUnit as mentioned in the PR objectives.

Also applies to: 11-11

src/main/webapp/app/entities/lecture-unit/videoUnit.model.ts (1)

2-2:

❓ Verification inconclusive

Code looks good, but be aware of potential circular dependency

The addition of the AttachmentUnit import and the correspondingAttachmentUnit property correctly implements the bidirectional relationship. However, there's now a circular dependency between these two model files that could potentially cause issues with some JavaScript bundlers.

Also applies to: 9-9


🏁 Script executed:

#!/bin/bash
# Check if the circular dependency might cause issues with the current bundler configuration

# Look for any TypeScript configuration files that might handle circular dependencies
fd -e json -e js "tsconfig|webpack" --exec cat {}

# Check if there are any existing circular dependencies in the codebase as precedent
rg -p "import.*from.*" --glob "*.ts" | rg -A 1 -B 1 "circular|cycle"

Length of output: 7315


Circular Dependency Caution for Video Unit Model

The updated import for AttachmentUnit correctly establishes the bidirectional relationship; however, this introduces a circular dependency between the model files. Our search of the TS and bundler configuration files didn’t reveal any special handling for circular dependencies. Although there’s no current evidence of issues in production, please double-check that your bundler can safely resolve such cycles. The same caution applies to the corresponding update on lines 9-9.

src/main/webapp/app/lecture/lecture-units/lecture-units.component.html (1)

36-36: Property binding looks good

The addition of the [availableAttachmentUnits] input property to the video unit form component correctly passes the list of available attachment units to be used in the dropdown.

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

73-73: Translation looks good

The German translation "Dateieinheit" for "attachmentUnit" follows the informal style (dutzen) as required by the coding guidelines.

src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/edit-video-unit/edit-video-unit.component.html (1)

2-2: New property added for mapping attachment units to video units.

The component now passes available attachment units to the video form component, supporting the new one-to-one relationship between video units and attachment units as described in the PR objectives.

src/test/javascript/spec/component/lecture-unit/video-unit/video-unit-form.component.spec.ts (1)

128-128: Test assertion updated to include new attachment relationship.

The test now correctly verifies that the form submission includes the correspondingAttachmentUnitId property, which is properly initialized to null. This ensures the new relationship between video and attachment units is properly tested.

src/main/webapp/i18n/en/lectureUnit.json (1)

73-73: Added localization for new attachment unit field.

The new localization entry supports the UI for selecting a corresponding attachment unit in the video unit form, aligning with the PR objective to establish a connection between video and attachment units.

src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component.html (1)

108-115: Added form field for attachment unit selection.

The form now includes a select dropdown that allows users to choose a corresponding attachment unit for the video unit. This implements the UI portion of the one-to-one relationship described in the PR objectives.

A few observations:

  • The component correctly uses the new availableAttachmentUnits() method
  • The form uses modern Angular syntax with @for instead of *ngFor as per guidelines
  • The field is optional (no required marker or validation), which is appropriate for this relationship
src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/create-video-unit/create-video-unit.component.html (1)

2-2: Correctly implemented inputs for attachment unit reference.

The addition of [formData]="formData" and [availableAttachmentUnits]="availableAttachmentUnits" inputs properly enables the reference between video and attachment units, which aligns with the PR objectives.

src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component.ts (4)

13-13: Appropriate import of AttachmentUnit model.

The addition of the import statement follows the coding guidelines by avoiding star imports and maintaining proper organization.


21-21: Model extended with corresponding attachment unit reference.

The addition of the optional correspondingAttachmentUnitId property to the VideoUnitFormData interface properly supports the bidirectional relationship being established.


76-76: Input property added for available attachment units.

The new input property follows Angular best practices and the coding guidelines by using camelCase and proper typing.


96-96: Form control added for corresponding attachment unit.

The form control properly integrates with the existing form structure and allows for the optional selection of an attachment unit.

src/main/java/de/tum/cit/aet/artemis/lecture/domain/VideoUnit.java (4)

6-7: Appropriate imports for JPA annotations.

The JPA annotations are correctly imported individually rather than using star imports, adhering to the coding guidelines.


9-9: JsonIgnoreProperties import properly added.

The import is correctly added to support the JSON serialization annotations required for the bidirectional relationship.


39-42: One-to-one relationship properly established.

The @OneToOne and @JoinColumn annotations correctly set up the relationship with AttachmentUnit, and the @JsonIgnoreProperties prevents infinite recursion during serialization by ignoring the back-reference.


44-50: Accessor methods follow least access principle.

The getter and setter methods adhere to the Java coding guidelines by following the least access principle and CamelCase naming conventions.

src/main/java/de/tum/cit/aet/artemis/lecture/domain/AttachmentUnit.java (2)

35-37: Bidirectional one-to-one relationship correctly configured.

The @OneToOne(mappedBy = "correspondingAttachmentUnit") annotation properly establishes the bidirectional relationship, with VideoUnit being the owning side. The @JsonIgnoreProperties prevents infinite recursion during serialization.


73-79: Accessor methods for corresponding video unit.

The getter and setter methods correctly follow Java naming conventions and encapsulation principles, providing a clean API for accessing and modifying the relationship.

src/test/javascript/spec/component/lecture-unit/video-unit/edit-video-unit.component.spec.ts (7)

4-4: Good use of fakeAsync and tick.
No concerns with adding asynchronous testing utilities.


19-23: New imports look fine.
Bringing in the ProfileService, LectureService, AttachmentUnit, and TextUnit is valid and aligns with the added functionality.


35-35: Consistent approach for mocking dependencies.
Using MockProvider(LectureService) is consistent with how other services are handled.


71-76: Compile and component creation steps are correct.
No issues found with the updated approach to compile components and set up the fixtures.


125-134: Duplicate concern about type mismatch.
This block repeats the same pattern of using HttpResponse<VideoUnit> for a Lecture object.


177-220: Recurrent type mismatch in test.
Please update the generic type to match the Lecture object in the response:

- const lectureResponse: HttpResponse<VideoUnit> = ...
+ const lectureResponse: HttpResponse<Lecture> = ...

222-272: 1) Same type inconsistency.
Again, this test sets a Lecture object in HttpResponse<VideoUnit>. The same fix applies as before.

2) Grammar nitpick in the test name.
Consider changing it from "expect attachment unit a attached" to "except the attachment unit attached."

src/test/javascript/spec/component/lecture/lecture-units.component.spec.ts (7)

2-2: Proper import for asynchronous test utilities.
No issues with adding fakeAsync and tick.


33-33: Importing LectureService is appropriate.
Aligns with the new test logic.


54-54: Mocking LectureService is consistent.
The approach matches other mock provider patterns.


771-779: Repeat type mismatch in test.
Consistently apply HttpResponse<Lecture> where new Lecture() is returned.


789-798: Recurrent type mismatch.
Similar fix required for HttpResponse<VideoUnit> vs. Lecture object.


809-840: Similar type mismatch in lecture-based data.
Use the correct generic type in the mocked response.


842-882: 1) Wrong test name wording.
Change “expect attachment unit a attached” to “except the attachment unit attached.”

2) Reused mismatch concern.
HttpResponse<VideoUnit> is populated with a Lecture.

src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/create-video-unit/create-video-unit.component.ts (3)

8-16: New imports appear valid.
Inclusion of finalize, switchMap, take, and additional model/service imports aligns with the updated data flow.


28-36: Added dependencies and properties look correct.
Injecting LectureService and declaring formData plus a list of availableAttachmentUnits is consistent with the new feature requirements.


74-82: Form data destructuring is clear.
The logic responsibly checks if correspondingAttachmentUnitId exists before setting correspondingAttachmentUnit, ensuring a correct one-to-one link.

src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/edit-video-unit/edit-video-unit.component.ts (7)

9-15: Good job with adding the necessary imports!

The imports are well-organized and follow a logical order. You've correctly imported the required dependencies for the newly added functionality.


26-26: Correctly injected the LectureService.

The LectureService is properly injected as a private service, following Angular's dependency injection pattern.


33-35: Good approach storing videoUnitId as a class property.

Moving videoUnitId from a local variable to a class property improves reusability across methods. The addition of availableAttachmentUnits property is also appropriate for the new functionality.


46-48: Good use of forkJoin for concurrent requests.

Using forkJoin to fetch both the video unit and lecture details concurrently is an excellent performance optimization compared to sequential requests.


55-64: Properly handling the response data.

The destructuring of results from forkJoin and setting up the formData with the correspondingAttachmentUnitId is well implemented.


66-74: Well-implemented filtering logic for attachment units.

The filtering logic ensures that only relevant attachment units are displayed - either those not linked to any video unit or those linked to the current video unit being edited.


81-87: Correctly handling the correspondingAttachmentUnit relationship.

The updateVideoUnit method properly destructures the formData to include correspondingAttachmentUnitId and sets the correspondingAttachmentUnit property with the correct type.

src/test/javascript/spec/component/lecture-unit/video-unit/create-video-unit.component.spec.ts (4)

20-25: Appropriate imports added for testing.

The new imports for LectureService, AttachmentUnit, TextUnit, and Lecture are correctly added to support the new test cases.


37-37: Correctly added MockProvider for LectureService.

The LectureService is properly mocked in the testing module setup.


134-161: Good test case for verifying attachment units retrieval.

This test thoroughly verifies that all attachment units are correctly retrieved from the lecture and filtered properly, while text units are excluded.


164-194: Good test for filtering out attached units.

This test correctly verifies that attachment units linked to other video units are excluded from the available options.

src/main/webapp/app/lecture/lecture-units/lecture-units.component.ts (6)

20-27: Appropriate imports added.

The HttpResponse import and LectureService are correctly added to support the new functionality.


50-50: Correctly injected the LectureService.

The LectureService is properly injected as a protected service, following the pattern used for other services in this component.


85-85: Good addition of availableAttachmentUnits property.

This property is needed to store the attachment units available for selection in the video unit form.


107-107: Properly integrating attachment unit fetching in workflow.

The fetchAvailableAttachmentUnitsForVideoUnit method is correctly called when creating a video unit.


161-171: Well-implemented video unit update with attachment relationship.

The createEditVideoUnit method correctly handles the correspondingAttachmentUnitId from the form data and properly sets the correspondingAttachmentUnit property with the correct type.


307-314: Good integration in edit workflow.

The fetchAvailableAttachmentUnitsForVideoUnit method is correctly called when editing a video unit, passing the videoUnitId parameter. The correspondingAttachmentUnitId is also properly included in the videoUnitFormData.

@ls1intum ls1intum deleted a comment from coderabbitai bot Mar 13, 2025
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. lecture Pull requests that affect the corresponding module ready for review 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.

1 participant