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

Adaptive learning: Fix course deletion when competency relations exist #8969

Merged

Conversation

JohannesStoehr
Copy link
Contributor

@JohannesStoehr JohannesStoehr commented Jul 4, 2024

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).

Motivation and Context

Fix #8954

Description

We now also delete the prerequisites and relations between competencies when we delete a course.

Steps for Testing

Prerequisites:

  • 1 Administrator
  1. Log in to Artemis
  2. Navigate to Course Administration
  3. Create two or more competencies and at least one prerequisite
  4. Create at least one relation between competencies
  5. Delete the course (you need admin privileges for that)

Testserver States

Note

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







Review Progress

Performance Review

  • I (as a reviewer) confirm that the 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

Test Coverage

Server

Class/File Line Coverage Confirmation (assert/expect)
CourseService.java 93%

Summary by CodeRabbit

  • New Features

    • Improved course deletion to also remove associated competencies, relations, and prerequisites automatically, ensuring data consistency.
  • Tests

    • Enhanced test coverage to verify the deletion of course-related competencies, relations, and prerequisites.

@JohannesStoehr JohannesStoehr added ready for review server Pull requests that update Java code. (Added Automatically!) priority:high small bugfix labels Jul 4, 2024
@JohannesStoehr JohannesStoehr added this to the 7.4.1 milestone Jul 4, 2024
@JohannesStoehr JohannesStoehr self-assigned this Jul 4, 2024
@JohannesStoehr JohannesStoehr requested a review from a team as a code owner July 4, 2024 10:17
Copy link

coderabbitai bot commented Jul 4, 2024

Walkthrough

The changes address the issue where courses could not be deleted if competency relations existed. A method deleteAllByCourseId was added to CompetencyRelationRepository to delete competency relations by course ID. The CourseService was updated to use this method and also handle deletions of prerequisites and competency relations within the deleteCompetenciesOfCourse method. Corresponding tests in CompetencyIntegrationTest were extended to verify the deletion of competencies, their relations, and prerequisites when a course is deleted.

Changes

File Summary
src/main/java/.../repository/CompetencyRelationRepository.java Added deleteAllByCourseId method to delete CompetencyRelation entities by course ID.
src/main/java/.../service/CourseService.java Introduced import for Prerequisite, added CompetencyRelationRepository field, and extended deleteCompetenciesOfCourse method logic.
src/test/java/.../lecture/CompetencyIntegrationTest.java Expanded deleteCourseShouldAlsoDeleteCompetency to deleteCourseShouldAlsoDeleteCompetencyAndRelations to verify deletion of prerequisites and relations.

Assessment against linked issues

Objective Addressed Explanation
Courses cannot be deleted if competency relations exist (#8954)

Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between e133097 and 84ec6d5.

Files selected for processing (1)
  • src/main/java/de/tum/in/www1/artemis/service/CourseService.java (5 hunks)
Additional context used
Path-based instructions (1)
src/main/java/de/tum/in/www1/artemis/service/CourseService.java (1)

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

Learnings (1)
src/main/java/de/tum/in/www1/artemis/service/CourseService.java (1)
Learnt from: 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.
Additional comments not posted (4)
src/main/java/de/tum/in/www1/artemis/service/CourseService.java (4)

61-61: Imports look good!

The import statements for CompetencyRelationRepository and Prerequisite are necessary for the new functionality.


119-119: Field declaration looks good!

The new field competencyRelationRepository is necessary to access the CompetencyRelationRepository methods.


207-207: Constructor changes look good!

The constructor was updated to include and assign the new competencyRelationRepository field, which is necessary for dependency injection.

Also applies to: 246-246


534-536: Method changes look good!

The method deleteCompetenciesOfCourse was expanded to delete CompetencyRelation entities using competencyRelationRepository, ensuring comprehensive cleanup.


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

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

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.

@github-actions github-actions bot added the tests label Jul 4, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 4, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 4, 2024
@JohannesStoehr JohannesStoehr changed the title Fix and test issue Adaptive Learning: Fix course deletion when competency relations exist Jul 4, 2024
Copy link
Contributor

@JohannesWt JohannesWt left a comment

Choose a reason for hiding this comment

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

Code 👍

Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Tested on TS3 and looks good 👍

Copy link
Contributor

@egekurt123 egekurt123 left a comment

Choose a reason for hiding this comment

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

Code LGTM, demonstrated in Testing session, works as expected on TS3

Copy link
Contributor

@florian-glombik florian-glombik left a comment

Choose a reason for hiding this comment

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

Approve code

@krusche krusche changed the title Adaptive Learning: Fix course deletion when competency relations exist Adaptive learning: Fix course deletion when competency relations exist Jul 5, 2024
@krusche krusche merged commit 4476527 into develop Jul 5, 2024
49 of 54 checks passed
@krusche krusche deleted the bugfix/adaptive-learning/delete-relations-when-course-delete branch July 5, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix priority:high ready to merge server Pull requests that update Java code. (Added Automatically!) small tests
Projects
Archived in project
Status: Done
Development

Successfully merging this pull request may close these issues.

Courses cannot be deleted if competency relations exist
6 participants