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

Development: Introduce athena module API #10294

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

Conversation

ole-ve
Copy link
Contributor

@ole-ve ole-ve commented Feb 8, 2025

Checklist

General

Server

  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I documented the Java code using JavaDoc style.

Motivation and Context

As part of the server modularization, we "facade" the service/repository declaration and method calls to module-external classes via a module API provided by the respective module.

Description

These changes add the module API for athena.

Steps for Testing

Can only be test on TS1, TS2, or TS3 (athena needs to be enabled)

Basically try to test all the functionality of athena regarding submissions, courses, and import/export.

Exam Mode Testing

not relevant - athena is not used for exam-related functionality

Review Progress

Performance Review

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Summary by CodeRabbit

  • New Features
    • Introduced comprehensive endpoints that enhance exercise management, including scheduling, cancellation, submission proposals, and tailored feedback suggestions for text, programming, and modeling exercises.

  • Refactor
    • Streamlined Athena-related functionality across courses, submissions, and assessments to ensure a more consistent and reliable user experience.

@ole-ve ole-ve self-assigned this Feb 8, 2025
@ole-ve ole-ve requested a review from a team as a code owner February 8, 2025 17:30
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) athena Pull requests that affect the corresponding module core Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module fileupload Pull requests that affect the corresponding module modeling Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module text Pull requests that affect the corresponding module labels Feb 8, 2025
Copy link

coderabbitai bot commented Feb 8, 2025

Walkthrough

This pull request consolidates several Athena-related service dependencies by introducing new API classes. A base abstract class (AbstractAthenaApi) and concrete implementations (AthenaApi and AthenaFeedbackApi) now encapsulate functionalities that were previously split across multiple services. Many instances of AthenaScheduleService, AthenaModuleService, AthenaSubmissionSelectionService, AthenaFeedbackSendingService, and AthenaFeedbackSuggestionsService have been replaced by AthenaApi or AthenaFeedbackApi. Additionally, a new ApiNotPresentException is introduced and architectural tests for the Athena module have been added or updated.

Changes

File(s) Change summary
src/main/java/de/tum/cit/aet/artemis/athena/api/AbstractAthenaApi.java Added new abstract class as base for Athena API implementations.
src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaApi.java Added new class extending AbstractAthenaApi with scheduling, submission, and access control methods.
src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaFeedbackApi.java Added new Spring controller for handling feedback suggestions and sending within Athena.
src/main/java/de/tum/cit/aet/artemis/core/exception/ApiNotPresentException.java Introduced new exception to indicate missing API when required profiles are inactive.
.../core/service/messaging/InstanceMessageReceiveService.java;
.../core/web/CourseResource.java;
.../exercise/service/SubmissionService.java;
.../fileupload/service/FileUploadSubmissionService.java
Replaced AthenaScheduleService, AthenaModuleService, and AthenaSubmissionSelectionService with unified AthenaApi in core services.
.../modeling/service/ModelingExerciseFeedbackService.java;
.../modeling/service/ModelingSubmissionService.java
Updated dependencies from AthenaFeedbackSuggestionsService and AthenaSubmissionSelectionService to AthenaFeedbackApi and AthenaApi respectively.
.../programming/service/ProgrammingAssessmentService.java;
.../programming/service/ProgrammingExerciseCodeReviewFeedbackService.java;
.../programming/service/ProgrammingSubmissionService.java
Replaced AthenaFeedbackSendingService and AthenaSubmissionSelectionService with AthenaApi/AthenaFeedbackApi in programming services.
.../programming/web/ProgrammingExerciseExportImportResource.java;
.../programming/web/ProgrammingExerciseResource.java
Replaced AthenaModuleService dependency with AthenaApi in programming web resources.
.../text/service/TextExerciseFeedbackService.java;
.../text/service/TextSubmissionService.java;
.../text/web/TextAssessmentResource.java;
.../text/web/TextExerciseResource.java
Updated Athena service dependencies (Feedback Suggestions, SubmissionSelection, FeedbackSending, Module) to AthenaFeedbackApi and AthenaApi in text services and resources.
src/test/java/de/tum/cit/aet/artemis/athena/architecture/AthenaApiArchitectureTest.java;
src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java
Added new architecture test for Athena API and enhanced filtering in module access architecture tests.

Sequence Diagram(s)

sequenceDiagram
    participant IMS as InstanceMessageReceiveService
    participant AA as AthenaApi
    IMS->>AA: scheduleExerciseForAthenaIfRequired(exercise)
    AA-->>IMS: Confirmation/Result
Loading
sequenceDiagram
    participant Client as API Client
    participant AFA as AthenaFeedbackApi
    Client->>AFA: getTextFeedbackSuggestions(exercise, submission, isGraded)
    AFA-->>Client: List<TextFeedbackDTO>
Loading

Suggested labels

ready for review, server, atlas, lti, programming, exercise, core, communication, maintainer-approved

Suggested reviewers

  • JohannesStoehr
  • maximiliansoelch
  • SimonEntholzer
  • egekurt123

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 PMD (7.8.0)
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseCodeReviewFeedbackService.java

[ERROR] Error at ruleset.xml:58:5
56|
57|
58|
^^^^^ Unable to find referenced rule BooleanInstantiation; perhaps the rule name is misspelled?

59|
60|
[WARN] Warning at ruleset.xml:66:5
64|
65|
66|
^^^^^ Use Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitch instead of the deprecated Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt. PMD 8.0.0 will remove support for this deprecated Rule name usage.

67|
68|
[ERROR] Error at ruleset.xml:71:5
69|
70|
71|
^^^^^ Unable to find referenced rule DontImportJavaLang; perhaps the rule name is misspelled?

72|
73|
[ERROR] Error at ruleset.xml:75:5
73|
74|
75|
^^^^^ Unable to find referenced rule DuplicateImports; perhaps the rule name is misspelled?

76|
77|
[ERROR] Error at ruleset.xml:78:5
76|
77|
78|
^^^^^ Unable to find referenced rule EmptyFinallyBlock; perhaps the rule name is misspelled?

79|
80|
[ERROR] Error at ruleset.xml:79:5
77|
78|
79|
^^^^^ Unable to find referenced rule EmptyIfStmt; perhaps the rule name is misspelled?

80|
81|
[ERROR] Error at ruleset.xml:81:5
79|
80|
81|
^^^^^ Unable to find referenced rule EmptyInitializer; perhaps the rule name is misspelled?

82|
83|
[ERROR] Error at ruleset.xml:82:5
80|
81|
82|
^^^^^ Unable to find referenced rule EmptyStatementBlock; perhaps the rule name is misspelled?

83|
84|
[ERROR] Error at ruleset.xml:83:5
81|
82|
83|
^^^^^ Unable to find referenced rule EmptyStatementNotInLoop; perhaps the rule name is misspelled?

84|
85|
[ERROR] Error at ruleset.xml:84:5
82|
83|
84|
^^^^^ Unable to find referenced rule EmptySwitchStatements; perhaps the rule name is misspelled?

85|
86|
[ERROR] Error at ruleset.xml:85:5
83|
84|
85|
^^^^^ Unable to find referenced rule EmptySynchronizedBlock; perhaps the rule name is misspelled?

86|
87|
[ERROR] Error at ruleset.xml:86:5
84|
85|
86|
^^^^^ Unable to find referenced rule EmptyTryBlock; perhaps the rule name is misspelled?

87|
88|
[ERROR] Error at ruleset.xml:87:5
85|
86|
87|
^^^^^ Unable to find referenced rule EmptyWhileStmt; perhaps the rule name is misspelled?

88|
89|
[ERROR] Error at ruleset.xml:90:5
88|
89|
90|
^^^^^ Unable to find referenced rule ExcessiveClassLength; perhaps the rule name is misspelled?

91|
92|
[ERROR] Error at ruleset.xml:91:5
89|
90|
91|
^^^^^ Unable to find referenced rule ExcessiveMethodLength; perhaps the rule name is misspelled?

92|
93|
[ERROR] Error at ruleset.xml:106:5
104|
105|
106|
^^^^^ Unable to find referenced rule ImportFromSamePackage; perhaps the rule name is misspelled?

107|
108|
[ERROR] Error at ruleset.xml:119:5
117|
118|
119|
^^^^^ Unable to find referenced rule MissingBreakInSwitch; perhaps the rule name is misspelled?

120|
121|
[WARN] Warning at ruleset.xml:124:5
122|
123|
124|
^^^^^ Use Rule name category/java/errorprone.xml/NonCaseLabelInSwitch instead of the deprecated Rule name category/java/errorprone.xml/NonCaseLabelInSwitchStatement. PMD 8.0.0 will remove support for this deprecated Rule name usage.

125|
126|
[ERROR] Error at ruleset.xml:134:9
132|
133| // It's okay to use short variable names in DTOs, e.g. "id" or "name"
134| ./de/tum/in/www1/artemis/web/rest/dto/.
^^^^^^^^^^^^^^^^ Unexpected element 'exclude-pattern' in rule ShortVariable

135|
136|
[ERROR] Error at ruleset.xml:137:5
135|
136|
137|
^^^^^ Unable to find referenced rule SimplifyBooleanAssertion; perhaps the rule name is misspelled?

138|
139|
[WARN] Warning at ruleset.xml:184:5
182|
183|
184|
^^^^^ Use Rule name category/ecmascript/errorprone.xml/InaccurateNumericLiteral instead of the deprecated Rule name category/ecmascript/errorprone.xml/InnaccurateNumericLiteral. PMD 8.0.0 will remove support for this deprecated Rule name usage.

185|
186|
[ERROR] Cannot load ruleset category/vm/bestpractices.xml: Cannot resolve rule/ruleset reference 'category/vm/bestpractices.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.

src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaFeedbackApi.java

[ERROR] Error at ruleset.xml:58:5
56|
57|
58|
^^^^^ Unable to find referenced rule BooleanInstantiation; perhaps the rule name is misspelled?

59|
60|
[WARN] Warning at ruleset.xml:66:5
64|
65|
66|
^^^^^ Use Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitch instead of the deprecated Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt. PMD 8.0.0 will remove support for this deprecated Rule name usage.

67|
68|
[ERROR] Error at ruleset.xml:71:5
69|
70|
71|
^^^^^ Unable to find referenced rule DontImportJavaLang; perhaps the rule name is misspelled?

72|
73|
[ERROR] Error at ruleset.xml:75:5
73|
74|
75|
^^^^^ Unable to find referenced rule DuplicateImports; perhaps the rule name is misspelled?

76|
77|
[ERROR] Error at ruleset.xml:78:5
76|
77|
78|
^^^^^ Unable to find referenced rule EmptyFinallyBlock; perhaps the rule name is misspelled?

79|
80|
[ERROR] Error at ruleset.xml:79:5
77|
78|
79|
^^^^^ Unable to find referenced rule EmptyIfStmt; perhaps the rule name is misspelled?

80|
81|
[ERROR] Error at ruleset.xml:81:5
79|
80|
81|
^^^^^ Unable to find referenced rule EmptyInitializer; perhaps the rule name is misspelled?

82|
83|
[ERROR] Error at ruleset.xml:82:5
80|
81|
82|
^^^^^ Unable to find referenced rule EmptyStatementBlock; perhaps the rule name is misspelled?

83|
84|
[ERROR] Error at ruleset.xml:83:5
81|
82|
83|
^^^^^ Unable to find referenced rule EmptyStatementNotInLoop; perhaps the rule name is misspelled?

84|
85|
[ERROR] Error at ruleset.xml:84:5
82|
83|
84|
^^^^^ Unable to find referenced rule EmptySwitchStatements; perhaps the rule name is misspelled?

85|
86|
[ERROR] Error at ruleset.xml:85:5
83|
84|
85|
^^^^^ Unable to find referenced rule EmptySynchronizedBlock; perhaps the rule name is misspelled?

86|
87|
[ERROR] Error at ruleset.xml:86:5
84|
85|
86|
^^^^^ Unable to find referenced rule EmptyTryBlock; perhaps the rule name is misspelled?

87|
88|
[ERROR] Error at ruleset.xml:87:5
85|
86|
87|
^^^^^ Unable to find referenced rule EmptyWhileStmt; perhaps the rule name is misspelled?

88|
89|
[ERROR] Error at ruleset.xml:90:5
88|
89|
90|
^^^^^ Unable to find referenced rule ExcessiveClassLength; perhaps the rule name is misspelled?

91|
92|
[ERROR] Error at ruleset.xml:91:5
89|
90|
91|
^^^^^ Unable to find referenced rule ExcessiveMethodLength; perhaps the rule name is misspelled?

92|
93|
[ERROR] Error at ruleset.xml:106:5
104|
105|
106|
^^^^^ Unable to find referenced rule ImportFromSamePackage; perhaps the rule name is misspelled?

107|
108|
[ERROR] Error at ruleset.xml:119:5
117|
118|
119|
^^^^^ Unable to find referenced rule MissingBreakInSwitch; perhaps the rule name is misspelled?

120|
121|
[WARN] Warning at ruleset.xml:124:5
122|
123|
124|
^^^^^ Use Rule name category/java/errorprone.xml/NonCaseLabelInSwitch instead of the deprecated Rule name category/java/errorprone.xml/NonCaseLabelInSwitchStatement. PMD 8.0.0 will remove support for this deprecated Rule name usage.

125|
126|
[ERROR] Error at ruleset.xml:134:9
132|
133| // It's okay to use short variable names in DTOs, e.g. "id" or "name"
134| ./de/tum/in/www1/artemis/web/rest/dto/.
^^^^^^^^^^^^^^^^ Unexpected element 'exclude-pattern' in rule ShortVariable

135|
136|
[ERROR] Error at ruleset.xml:137:5
135|
136|
137|
^^^^^ Unable to find referenced rule SimplifyBooleanAssertion; perhaps the rule name is misspelled?

138|
139|
[WARN] Warning at ruleset.xml:184:5
182|
183|
184|
^^^^^ Use Rule name category/ecmascript/errorprone.xml/InaccurateNumericLiteral instead of the deprecated Rule name category/ecmascript/errorprone.xml/InnaccurateNumericLiteral. PMD 8.0.0 will remove support for this deprecated Rule name usage.

185|
186|
[ERROR] Cannot load ruleset category/vm/bestpractices.xml: Cannot resolve rule/ruleset reference 'category/vm/bestpractices.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.

src/main/java/de/tum/cit/aet/artemis/athena/api/AbstractAthenaApi.java

[ERROR] Error at ruleset.xml:58:5
56|
57|
58|
^^^^^ Unable to find referenced rule BooleanInstantiation; perhaps the rule name is misspelled?

59|
60|
[WARN] Warning at ruleset.xml:66:5
64|
65|
66|
^^^^^ Use Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitch instead of the deprecated Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt. PMD 8.0.0 will remove support for this deprecated Rule name usage.

67|
68|
[ERROR] Error at ruleset.xml:71:5
69|
70|
71|
^^^^^ Unable to find referenced rule DontImportJavaLang; perhaps the rule name is misspelled?

72|
73|
[ERROR] Error at ruleset.xml:75:5
73|
74|
75|
^^^^^ Unable to find referenced rule DuplicateImports; perhaps the rule name is misspelled?

76|
77|
[ERROR] Error at ruleset.xml:78:5
76|
77|
78|
^^^^^ Unable to find referenced rule EmptyFinallyBlock; perhaps the rule name is misspelled?

79|
80|
[ERROR] Error at ruleset.xml:79:5
77|
78|
79|
^^^^^ Unable to find referenced rule EmptyIfStmt; perhaps the rule name is misspelled?

80|
81|
[ERROR] Error at ruleset.xml:81:5
79|
80|
81|
^^^^^ Unable to find referenced rule EmptyInitializer; perhaps the rule name is misspelled?

82|
83|
[ERROR] Error at ruleset.xml:82:5
80|
81|
82|
^^^^^ Unable to find referenced rule EmptyStatementBlock; perhaps the rule name is misspelled?

83|
84|
[ERROR] Error at ruleset.xml:83:5
81|
82|
83|
^^^^^ Unable to find referenced rule EmptyStatementNotInLoop; perhaps the rule name is misspelled?

84|
85|
[ERROR] Error at ruleset.xml:84:5
82|
83|
84|
^^^^^ Unable to find referenced rule EmptySwitchStatements; perhaps the rule name is misspelled?

85|
86|
[ERROR] Error at ruleset.xml:85:5
83|
84|
85|
^^^^^ Unable to find referenced rule EmptySynchronizedBlock; perhaps the rule name is misspelled?

86|
87|
[ERROR] Error at ruleset.xml:86:5
84|
85|
86|
^^^^^ Unable to find referenced rule EmptyTryBlock; perhaps the rule name is misspelled?

87|
88|
[ERROR] Error at ruleset.xml:87:5
85|
86|
87|
^^^^^ Unable to find referenced rule EmptyWhileStmt; perhaps the rule name is misspelled?

88|
89|
[ERROR] Error at ruleset.xml:90:5
88|
89|
90|
^^^^^ Unable to find referenced rule ExcessiveClassLength; perhaps the rule name is misspelled?

91|
92|
[ERROR] Error at ruleset.xml:91:5
89|
90|
91|
^^^^^ Unable to find referenced rule ExcessiveMethodLength; perhaps the rule name is misspelled?

92|
93|
[ERROR] Error at ruleset.xml:106:5
104|
105|
106|
^^^^^ Unable to find referenced rule ImportFromSamePackage; perhaps the rule name is misspelled?

107|
108|
[ERROR] Error at ruleset.xml:119:5
117|
118|
119|
^^^^^ Unable to find referenced rule MissingBreakInSwitch; perhaps the rule name is misspelled?

120|
121|
[WARN] Warning at ruleset.xml:124:5
122|
123|
124|
^^^^^ Use Rule name category/java/errorprone.xml/NonCaseLabelInSwitch instead of the deprecated Rule name category/java/errorprone.xml/NonCaseLabelInSwitchStatement. PMD 8.0.0 will remove support for this deprecated Rule name usage.

125|
126|
[ERROR] Error at ruleset.xml:134:9
132|
133| // It's okay to use short variable names in DTOs, e.g. "id" or "name"
134| ./de/tum/in/www1/artemis/web/rest/dto/.
^^^^^^^^^^^^^^^^ Unexpected element 'exclude-pattern' in rule ShortVariable

135|
136|
[ERROR] Error at ruleset.xml:137:5
135|
136|
137|
^^^^^ Unable to find referenced rule SimplifyBooleanAssertion; perhaps the rule name is misspelled?

138|
139|
[WARN] Warning at ruleset.xml:184:5
182|
183|
184|
^^^^^ Use Rule name category/ecmascript/errorprone.xml/InaccurateNumericLiteral instead of the deprecated Rule name category/ecmascript/errorprone.xml/InnaccurateNumericLiteral. PMD 8.0.0 will remove support for this deprecated Rule name usage.

185|
186|
[ERROR] Cannot load ruleset category/vm/bestpractices.xml: Cannot resolve rule/ruleset reference 'category/vm/bestpractices.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.

  • 18 others
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (3)
src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaFeedbackApi.java (1)

1-3: Consider declaring this as a REST endpoint if consumed as an external API.
The current class is annotated with @controller, which typically expects view-based rendering. If this API is meant for REST-based usage, switching to @RestController (or adding @responsebody to the relevant methods) might simplify usage and avoid confusion.

src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaApi.java (1)

34-56: Consider adding null checks and validation.

While the service delegation is clean, consider adding parameter validation and null checks before delegating to services.

Example for scheduleExerciseForAthenaIfRequired:

 public void scheduleExerciseForAthenaIfRequired(Exercise exercise) {
+    if (exercise == null) {
+        throw new IllegalArgumentException("Exercise cannot be null");
+    }
     athenaScheduleService.scheduleExerciseForAthenaIfRequired(exercise);
 }
src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (1)

1-1468: Great architectural improvement!

The changes successfully implement the module API pattern by:

  1. Encapsulating athena-specific functionality behind a well-defined API
  2. Reducing direct dependencies on internal services
  3. Making the interaction between components more structured

This aligns well with the PR objectives of improving server modularization.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 67a5a03 and e311424.

📒 Files selected for processing (21)
  • src/main/java/de/tum/cit/aet/artemis/athena/api/AbstractAthenaApi.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaApi.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaFeedbackApi.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/exception/ApiNotPresentException.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/service/messaging/InstanceMessageReceiveService.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (5 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exercise/service/SubmissionService.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/fileupload/service/FileUploadSubmissionService.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingExerciseFeedbackService.java (7 hunks)
  • src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingSubmissionService.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseCodeReviewFeedbackService.java (6 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingSubmissionService.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (5 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (6 hunks)
  • src/main/java/de/tum/cit/aet/artemis/text/service/TextExerciseFeedbackService.java (6 hunks)
  • src/main/java/de/tum/cit/aet/artemis/text/service/TextSubmissionService.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/text/web/TextAssessmentResource.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/text/web/TextExerciseResource.java (7 hunks)
  • src/test/java/de/tum/cit/aet/artemis/athena/architecture/AthenaApiArchitectureTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/de/tum/cit/aet/artemis/athena/api/AbstractAthenaApi.java
🧰 Additional context used
📓 Path-based instructions (2)
`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/core/exception/ApiNotPresentException.java
  • src/main/java/de/tum/cit/aet/artemis/fileupload/service/FileUploadSubmissionService.java
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingSubmissionService.java
  • src/main/java/de/tum/cit/aet/artemis/text/web/TextExerciseResource.java
  • src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingExerciseFeedbackService.java
  • src/main/java/de/tum/cit/aet/artemis/text/web/TextAssessmentResource.java
  • src/main/java/de/tum/cit/aet/artemis/core/service/messaging/InstanceMessageReceiveService.java
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java
  • src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingSubmissionService.java
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseCodeReviewFeedbackService.java
  • src/main/java/de/tum/cit/aet/artemis/text/service/TextSubmissionService.java
  • src/main/java/de/tum/cit/aet/artemis/exercise/service/SubmissionService.java
  • src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaApi.java
  • src/main/java/de/tum/cit/aet/artemis/text/service/TextExerciseFeedbackService.java
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java
  • src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaFeedbackApi.java
  • src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java
`src/test/java/**/*.java`: test_naming: descriptive; test_si...

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/cit/aet/artemis/athena/architecture/AthenaApiArchitectureTest.java
  • src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java
📓 Learnings (3)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-11-12T12:51:51.201Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseCodeReviewFeedbackService.java (1)
Learnt from: undernagruzez
PR: ls1intum/Artemis#8498
File: src/main/java/de/tum/in/www1/artemis/service/programming/ProgrammingExerciseCodeReviewFeedbackService.java:236-236
Timestamp: 2024-11-12T12:51:40.391Z
Learning: Rate limit exceptions for AI feedback requests are handled in the client app.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1)
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-11-12T12:51:51.201Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
⏰ 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-style
  • GitHub Check: server-tests
  • GitHub Check: server-style
  • GitHub Check: Analyse
🔇 Additional comments (54)
src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaFeedbackApi.java (2)

29-39: Constructor injection is correctly used.
This approach is consistent with the coding guidelines and promotes cleaner object instantiation. No changes required here.


40-63: Validate exception handling strategy.
All these public methods can throw a NetworkingException (or call downstream methods that can). Ensure that any upstream callers or controllers properly handle these exceptions and provide a meaningful response to the user.

src/main/java/de/tum/cit/aet/artemis/text/service/TextExerciseFeedbackService.java (4)

26-27: Imports and optional injection transition to AthenaFeedbackApi look good.
Replacing direct usage of AthenaFeedbackSuggestionsService with AthenaFeedbackApi aligns with the new architecture. No issues identified.

Also applies to: 42-42


56-58: Constructor injection of AthenaFeedbackApi is consistent with best practices.
This change keeps the code modular and testable.


76-78: Asynchronous invocation might mask exceptions.
Because you're using CompletableFuture.runAsync, exceptions thrown within the lambda won't be rethrown on the calling thread. Ensure your logs or error handlers capture problems effectively, as the main thread won't see them.

Also applies to: 86-86


122-123: ApiNotPresentException usage ensures robust fallback logic.
Throwing this exception clarifies when the Athena profile is unavailable. Good practice for optional dependencies. No changes needed.

src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingExerciseFeedbackService.java (4)

23-23: Refactoring to AthenaFeedbackApi is structurally consistent.
Replacing AthenaFeedbackSuggestionsService with AthenaFeedbackApi (in alignment with the new architecture) follows the single-responsibility principle.

Also applies to: 25-25, 42-42


54-56: Constructor injection approach is on point.
Ensures dependencies are explicit and promotes testability.


73-75: CompletableFuture consideration & exception handling.
Similar to the text feedback service, the asynchronous feedback generation process should be carefully monitored and logged in case of exceptions, ensuring they don’t silently fail.

Also applies to: 86-86


165-167: Lambda stream usage is clear and concise.
The filtering step using .filter(...) before mapping is straightforward and easy to read. No changes needed.

src/test/java/de/tum/cit/aet/artemis/athena/architecture/AthenaApiArchitectureTest.java (1)

8-19: LGTM! Well-structured architecture test implementation.

The test class follows best practices:

  • Descriptive naming convention
  • Proper extension of base test class
  • Clear method overrides
src/main/java/de/tum/cit/aet/artemis/core/exception/ApiNotPresentException.java (1)

6-19: LGTM! Well-designed exception class with clear documentation.

The implementation follows best practices:

  • Clear JavaDoc documentation
  • Informative error message
  • Proper parameter usage
src/main/java/de/tum/cit/aet/artemis/athena/api/AthenaApi.java (2)

18-20: LGTM! Proper Spring configuration.

The class is correctly configured with:

  • Profile-specific activation
  • Controller annotation
  • Proper inheritance

22-32: LGTM! Clean dependency injection pattern.

The implementation follows best practices:

  • Constructor injection
  • Final fields for immutability
  • Clear service dependencies
src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java (4)

27-32: LGTM! Improved architecture rule with ignored classes support.

The modification correctly excludes ignored classes from the architecture rule check.


35-38: LGTM! Enhanced inheritance check with exclusions.

The rule properly validates API class inheritance while respecting ignored classes.


41-44: LGTM! Updated controller annotation check.

The rule correctly validates API class structure with proper exclusions.


58-60: LGTM! Clean default implementation.

The method provides a good default empty set, allowing subclasses to override when needed.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java (4)

23-23: LGTM!

The import statement correctly references the new API class.


44-44: LGTM!

The field declaration follows Java best practices with proper access modifiers and type declaration.


48-54: LGTM!

The constructor properly injects the new API dependency and maintains the same functionality.


143-145: LGTM!

The method correctly checks for API presence and delegates the feedback sending to the API.

src/main/java/de/tum/cit/aet/artemis/text/service/TextSubmissionService.java (2)

20-20: LGTM!

The import statement correctly references the new API class.


57-59: LGTM!

The constructor properly injects the new API dependency and maintains the same functionality.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseCodeReviewFeedbackService.java (5)

23-23: LGTM!

The import statements correctly reference the new API class and the exception class.

Also applies to: 26-26


50-50: LGTM!

The field declaration follows Java best practices with proper access modifiers and type declaration.


64-70: LGTM!

The constructor properly injects the new API dependency and maintains the same functionality.


90-92: LGTM!

The method correctly checks for API presence and delegates the rate limit check to the API.


137-138: LGTM!

The code properly handles the case when the API is not present by throwing a specific exception.

src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingSubmissionService.java (2)

26-26: LGTM!

The import statement correctly references the new API class.


71-73: LGTM!

The constructor properly injects the new API dependency and maintains the same functionality.

src/main/java/de/tum/cit/aet/artemis/fileupload/service/FileUploadSubmissionService.java (1)

26-26: LGTM! Clean refactoring to use the new AthenaApi.

The changes correctly update the import statement and constructor to use the new AthenaApi while maintaining the Optional pattern for dependency injection.

Also applies to: 65-67

src/main/java/de/tum/cit/aet/artemis/core/service/messaging/InstanceMessageReceiveService.java (1)

18-18: LGTM! Clean refactoring to use the new AthenaApi.

The changes correctly:

  • Update the import statement and field type to use AthenaApi
  • Maintain the Optional pattern for dependency injection
  • Update the method calls to use the new API methods

Also applies to: 52-52, 70-71, 75-75, 234-234, 239-239

src/main/java/de/tum/cit/aet/artemis/text/web/TextAssessmentResource.java (1)

43-43: LGTM! Clean refactoring to use the new AthenaFeedbackApi.

The changes correctly:

  • Update the import statement and field type to use AthenaFeedbackApi
  • Maintain the Optional pattern for dependency injection
  • Update the method calls to use the new API methods

Also applies to: 102-102, 108-108, 120-120, 523-525

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java (1)

44-44: LGTM! Clean refactoring to use the new AthenaApi.

The changes correctly:

  • Update the import statement and field type to use AthenaApi
  • Maintain the Optional pattern for dependency injection
  • Update the method call to use the new API method

Also applies to: 132-132, 141-142, 157-157, 248-248

src/main/java/de/tum/cit/aet/artemis/text/web/TextExerciseResource.java (4)

43-43: Import changes managed by formatter.


155-155: LGTM! Field declaration correctly uses Optional for dependency injection.

The change from AthenaModuleService to AthenaApi is consistent with the module API refactoring.


228-228: LGTM! Access control check correctly handles both cases.

The change preserves the existing behavior while using the new API:

  • If athenaApi is present: checks access using the new API
  • If athenaApi is not present: disables feedback suggestions

281-284: LGTM! Access control and validation checks are correctly implemented.

The changes maintain the required checks while using the new API:

  1. Access control check with proper fallback
  2. Additional validation to prevent module changes after due date
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingSubmissionService.java (2)

32-32: Import changes managed by formatter.


118-120: LGTM! Constructor correctly updated to use the new API.

The changes maintain consistency:

  • Parameter type updated to Optional<AthenaApi>
  • Super call correctly passes the new parameter
src/main/java/de/tum/cit/aet/artemis/exercise/service/SubmissionService.java (4)

34-34: Import changes managed by formatter.


92-92: LGTM! Field declaration correctly uses Optional for dependency injection.

The change from AthenaSubmissionSelectionService to AthenaApi is consistent with the module API refactoring.


97-98: LGTM! Constructor correctly updated to use the new API.

The parameter type is correctly updated to Optional<AthenaApi> while maintaining the parameter order.


273-276: LGTM! Method correctly uses the new API while maintaining behavior.

The changes preserve the existing functionality:

  1. Checks if feedback suggestions are enabled and API is present
  2. Correctly retrieves the proposed submission ID using the new API
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (5)

44-44: Import changes managed by formatter.


155-155: LGTM! Field declaration correctly uses Optional for dependency injection.

The change from AthenaModuleService to AthenaApi is consistent with the module API refactoring.


168-191: LGTM! Constructor correctly updated to use the new API.

The changes maintain consistency:

  • Parameter type updated to Optional<AthenaApi>
  • Field assignment correctly uses the new parameter

248-248: LGTM! Access control check correctly handles both cases.

The change preserves the existing behavior while using the new API:

  • If athenaApi is present: checks access using the new API
  • If athenaApi is not present: disables feedback suggestions

342-345: LGTM! Access control and validation checks are correctly implemented.

The changes maintain the required checks while using the new API:

  1. Access control check with proper fallback
  2. Additional validation to prevent module changes after due date
src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (4)

67-67: LGTM!

The import statement for AthenaApi is correctly placed and follows Java import conventions.


178-178: LGTM!

The field declaration follows best practices:

  • Uses final for immutability
  • Uses Optional to handle potential null values
  • Follows Java naming conventions

198-199: LGTM!

The constructor changes are consistent with the field changes and follow dependency injection best practices.

Also applies to: 218-218


333-336: LGTM!

The method call is correctly updated to use the new API and maintains proper null safety using Optional#ifPresent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
athena Pull requests that affect the corresponding module core Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module fileupload Pull requests that affect the corresponding module modeling Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module server Pull requests that update Java code. (Added Automatically!) tests text Pull requests that affect the corresponding module
Projects
Status: Work In Progress
Development

Successfully merging this pull request may close these issues.

1 participant