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 lti module API #10295

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

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

Steps for Testing

Can not be tested on TS0 (lti is disabled)

Basically try to test all the functionality of lti.

Exam Mode Testing

not relevant - lti 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
    • Rolled out a unified integration module for external learning tools, enhancing online course configuration and real-time result notifications.
  • Improvements
    • Streamlined assessment, quiz, and programming evaluations for a more reliable and seamless user experience.
    • Enhanced user management by smoothing the integration of externally created accounts.
  • Tests
    • Introduced architectural quality checks to ensure robust integration performance under varied conditions.

@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:54
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) assessment Pull requests that affect the corresponding module core Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module lti Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module quiz 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 replaces several LTI-related dependencies across the application with a new API, LtiApi. Existing references to services such as LtiNewResultService, LtiService, Lti13ResourceLaunchRepository, and OnlineCourseConfigurationService are removed and updated to use LtiApi. The changes affect various service and controller classes throughout the codebase. Additionally, new classes defining the LTI API infrastructure are introduced, along with updates to the architecture tests to accommodate these modifications.

Changes

File(s) Change Summary
src/main/java/de/tum/cit/aet/artemis/assessment/service/AssessmentService.java
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java
src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizStatisticService.java
src/main/java/de/tum/cit/aet/artemis/text/service/TextAssessmentService.java
src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java
Updated dependency injections and variable types to replace legacy LTI services (LtiNewResultService, Lti13ResourceLaunchRepository) with LtiApi. Method calls and constructor parameters were adjusted accordingly.
src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java
src/main/java/de/tum/cit/aet/artemis/core/web/UserResource.java
src/main/java/de/tum/cit/aet/artemis/core/web/admin/AdminCourseResource.java
Replaced usage of OnlineCourseConfigurationService and LtiService with LtiApi in controller classes, updating variable names, constructor signatures, and logic within resource methods.
src/main/java/de/tum/cit/aet/artemis/lti/api/AbstractLtiApi.java
src/main/java/de/tum/cit/aet/artemis/lti/api/LtiApi.java
Introduced a new abstract class (AbstractLtiApi) and its concrete implementation (LtiApi). The LtiApi class provides methods such as onNewResult, isLtiCreatedUser, createOnlineCourseConfiguration, and findByUserAndExercise, encapsulating LTI-related operations.
src/test/java/de/tum/cit/aet/artemis/lti/architecture/LtiApiArchitectureTest.java
src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java
Added a new architecture test class (LtiApiArchitectureTest) and enhanced the base module architecture tests by introducing a method to filter out ignored classes.

Sequence Diagram(s)

Manual Assessment Submission Flow

sequenceDiagram
    participant Client
    participant AssessmentService
    participant LtiApi
    participant "LTI Handler" as UnderlyingService

    Client->>AssessmentService: submitManualAssessment(participation)
    AssessmentService->>LtiApi: ifPresent(onNewResult(participation))
    LtiApi->>UnderlyingService: onNewResult(participation)
Loading

User Initialization Flow

sequenceDiagram
    participant Client
    participant UserResource
    participant LtiApi
    participant "LTI Check Service" as LtiCheckService

    Client->>UserResource: initializeUser(user)
    UserResource->>LtiApi: isLtiCreatedUser(user)
    LtiApi->>LtiCheckService: isLtiCreatedUser(user)
Loading

Online Course Configuration Flow

sequenceDiagram
    participant Client
    participant CourseResource
    participant LtiApi
    participant "Online Course Config Service" as OnlineCourseService

    Client->>CourseResource: updateCourse(courseUpdate)
    CourseResource->>LtiApi: createOnlineCourseConfiguration(courseUpdate)
    LtiApi->>OnlineCourseService: createOnlineCourseConfiguration(courseUpdate)
Loading

Possibly related PRs

  • Development: Refactor lti tests #9375: Addresses similar changes by replacing LtiNewResultService with LtiApi and introduces an LTI integration testing framework, indicating a strong code-level connection.

Suggested labels

ready to merge

Suggested reviewers

  • JohannesStoehr
  • az108
  • krusche
  • tobias-lippert
✨ 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

🔭 Outside diff range comments (1)
src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (1)

309-316: Consider adding explicit error handling for missing LTI API.

When a course is marked as online but the LTI API is not available, the code silently continues without creating the configuration. Consider throwing an appropriate exception to provide better feedback.

Apply this diff to improve error handling:

 if (courseUpdate.isOnlineCourse() != existingCourse.isOnlineCourse()) {
     if (courseUpdate.isOnlineCourse() && ltiApi.isPresent()) {
         ltiApi.get().createOnlineCourseConfiguration(courseUpdate);
     }
-    else {
+    else if (courseUpdate.isOnlineCourse()) {
+        throw new BadRequestAlertException("Cannot create online course: LTI module is not enabled", Course.ENTITY_NAME, "ltiNotEnabled");
+    }
+    else {
         courseUpdate.setOnlineCourseConfiguration(null);
     }
 }
🧹 Nitpick comments (5)
src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java (2)

28-29: Well-structured architectural test modifications.

The test modifications effectively incorporate ignored class filtering while maintaining the original architectural constraints. The implementation follows ArchUnit best practices and maintains good readability.

Consider adding JavaDoc to document the purpose of ignored classes and their impact on the architectural rules.

 public abstract class AbstractModuleAccessArchitectureTest extends AbstractArchitectureTest implements ModuleArchitectureTest {
+    /**
+     * Tests that classes outside the module can only access API, domain, or DTO classes,
+     * except for specifically ignored classes that may have different architectural requirements.
+     */
     @Test
     void shouldOnlyAccessApiDomainDto() {

Also applies to: 36-37, 42-43


58-60: Add JavaDoc to document the purpose and usage of getIgnoredClasses.

The method is well-implemented but lacks documentation. Add JavaDoc to explain:

  • The purpose of ignored classes in architectural tests
  • When and how subclasses should override this method
  • The significance of the default empty set
+    /**
+     * Returns a set of classes that should be excluded from architectural rule checks.
+     * This method can be overridden by subclasses to specify classes that have special
+     * architectural requirements or exceptions to the standard module rules.
+     *
+     * @return A Set of Class<?> objects to be ignored in architectural tests
+     */
     protected Set<Class<?>> getIgnoredClasses() {
         return Set.of();
     }
src/main/java/de/tum/cit/aet/artemis/core/exception/ApiNotPresentException.java (1)

16-18: Consider enhancing the error message format.

The error message is informative but could be more user-friendly.

-        super(String.format("Api %s is not enabled, because Spring profile %s is not enabled. Did you enable it?", api.getName(), profile));
+        super(String.format("API '%s' is not available because Spring profile '%s' is not enabled. Please enable the required profile.", api.getSimpleName(), profile));
src/main/java/de/tum/cit/aet/artemis/lti/api/LtiApi.java (1)

40-54: Add JavaDoc documentation for public methods.

The public methods lack documentation explaining their purpose and parameters.

+    /**
+     * Handles new result submission for LTI.
+     * @param participation The student participation containing the result
+     */
     public void onNewResult(StudentParticipation participation) {
         ltiNewResultService.onNewResult(participation);
     }

+    /**
+     * Checks if a user was created through LTI.
+     * @param user The user to check
+     * @return true if the user was created through LTI, false otherwise
+     */
     public boolean isLtiCreatedUser(User user) {
         return ltiService.isLtiCreatedUser(user);
     }

+    /**
+     * Creates online course configuration for LTI.
+     * @param course The course to configure
+     */
     public void createOnlineCourseConfiguration(Course course) {
         onlineCourseConfigurationService.createOnlineCourseConfiguration(course);
     }

+    /**
+     * Finds LTI resource launches for a specific user and exercise.
+     * @param user The user to find launches for
+     * @param exercise The exercise to find launches for
+     * @return Collection of LTI resource launches
+     */
     public Collection<LtiResourceLaunch> findByUserAndExercise(User user, Exercise exercise) {
         return lti13ResourceLaunchRepository.findByUserAndExercise(user, exercise);
     }
src/main/java/de/tum/cit/aet/artemis/text/service/TextAssessmentService.java (1)

60-93: Consider breaking down the large method into smaller, focused methods.

The prepareSubmissionForAssessment method handles multiple responsibilities and could be split into smaller methods for better maintainability.

Consider extracting the following methods:

+    private Result createOrLoadResult(TextSubmission textSubmission, @Nullable Result result) {
+        if (result != null) {
+            final List<Feedback> assessments = feedbackRepository.findByResult(result);
+            result.setFeedbacks(assessments);
+            result.setSubmission(textSubmission);
+            return result;
+        }
+        
+        result = new Result();
+        result.setParticipation(textSubmission.getParticipation());
+        resultService.createNewRatedManualResult(result);
+        result.setCompletionDate(null);
+        result = resultRepository.save(result);
+        result.setSubmission(textSubmission);
+        textSubmission.addResult(result);
+        submissionRepository.save(textSubmission);
+        return result;
+    }

+    private void prepareTextBlocks(TextSubmission textSubmission) {
+        final var textBlocks = textBlockService.findAllBySubmissionId(textSubmission.getId());
+        textSubmission.setBlocks(textBlocks);
+
+        if (textSubmission.getBlocks() == null || !isInitialized(textSubmission.getBlocks()) || textSubmission.getBlocks().isEmpty()) {
+            textBlockService.computeTextBlocksForSubmissionBasedOnSyntax(textSubmission);
+        }
+    }
📜 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 c09a7c8.

📒 Files selected for processing (15)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/AssessmentService.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/exception/ApiNotPresentException.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/web/UserResource.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/web/admin/AdminCourseResource.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/lti/api/AbstractLtiApi.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/lti/api/LtiApi.java (1 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/ProgrammingMessagingService.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizStatisticService.java (3 hunks)
  • src/main/java/de/tum/cit/aet/artemis/text/service/TextAssessmentService.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/lti/architecture/LtiApiArchitectureTest.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/lti/api/AbstractLtiApi.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/exercise/service/ExerciseService.java
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/AssessmentService.java
  • src/main/java/de/tum/cit/aet/artemis/core/web/admin/AdminCourseResource.java
  • src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java
  • src/main/java/de/tum/cit/aet/artemis/lti/api/LtiApi.java
  • src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizStatisticService.java
  • src/main/java/de/tum/cit/aet/artemis/text/service/TextAssessmentService.java
  • src/main/java/de/tum/cit/aet/artemis/core/web/UserResource.java
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.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/lti/architecture/LtiApiArchitectureTest.java
  • src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java
📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (2)
Learnt from: julian-christl
PR: ls1intum/Artemis#9322
File: src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java:0-0
Timestamp: 2024-11-12T12:51:51.201Z
Learning: In Artemis, an `ExerciseGroup` always has an associated `Exam`, so `exerciseGroup.exam` is never null.
Learnt from: julian-christl
PR: ls1intum/Artemis#9322
File: src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java:170-172
Timestamp: 2024-11-12T12:51:46.554Z
Learning: In Artemis, `exercise.exerciseGroup` may be null, as not all exercises belong to an `ExerciseGroup`.
⏰ 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-style
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (26)
src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java (1)

3-4: LGTM: Import statements are well-organized.

The new imports are appropriately placed and follow Java conventions. The static imports enhance code readability for the predicate usage.

Also applies to: 10-10

src/test/java/de/tum/cit/aet/artemis/lti/architecture/LtiApiArchitectureTest.java (1)

9-20: LGTM! The architecture test class is well-structured.

The implementation correctly extends AbstractModuleAccessArchitectureTest and provides appropriate overrides for module package definition and ignored classes.

src/main/java/de/tum/cit/aet/artemis/core/exception/ApiNotPresentException.java (1)

6-9: LGTM! Documentation is clear and descriptive.

The JavaDoc clearly explains the purpose of the exception.

src/main/java/de/tum/cit/aet/artemis/lti/api/LtiApi.java (2)

20-22: LGTM! Proper Spring configuration.

The class is correctly configured with appropriate Spring annotations and profile.


32-38: LGTM! Constructor follows dependency injection best practices.

All dependencies are injected via constructor, following the guidelines.

src/main/java/de/tum/cit/aet/artemis/text/service/TextAssessmentService.java (1)

39-45: LGTM! Constructor properly updated for LTI API integration.

The constructor correctly integrates the Optional and follows dependency injection guidelines.

src/main/java/de/tum/cit/aet/artemis/core/web/UserResource.java (3)

34-34: LGTM!

Import statement for LtiApi is correctly added.


68-68: LGTM!

The field declaration and constructor parameter have been correctly updated to use Optional<LtiApi>. The constructor initialization follows best practices by using constructor injection.

Also applies to: 72-77


147-147: LGTM!

The LTI user check has been correctly updated to use the new LtiApi. The logic maintains the same behavior while using the new API.

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

33-33: LGTM!

Import statement for LtiApi is correctly added.


48-52: LGTM!

The constructor parameters and super constructor call have been correctly updated to use Optional<LtiApi>. The changes maintain proper dependency injection.


127-127: LGTM!

The LTI result submission has been correctly updated to use the new LtiApi. The lambda expression maintains readability while using the new API.

src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizStatisticService.java (3)

20-20: LGTM!

Import statement for LtiApi is correctly added.


47-47: LGTM!

The field declaration and constructor parameter have been correctly updated to use Optional<LtiApi>. The constructor follows best practices by using constructor injection.

Also applies to: 51-58


111-111: LGTM!

The LTI result submission has been correctly updated to use the new LtiApi. The lambda expression maintains readability while using the new API.

src/main/java/de/tum/cit/aet/artemis/core/web/admin/AdminCourseResource.java (3)

47-47: LGTM!

Import statement for LtiApi is correctly added.


77-77: LGTM!

The field declaration and constructor parameter have been correctly updated to use Optional<LtiApi>. The constructor follows best practices by using constructor injection.

Also applies to: 80-87


143-145: LGTM!

The online course configuration has been correctly updated to use the new LtiApi. The logic maintains the same behavior while using the new API.

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java (1)

34-34: LGTM! The LTI service migration is consistent.

The changes correctly replace LtiNewResultService with LtiApi across imports, field declarations, constructor parameters, and method calls. The migration maintains the same functionality while aligning with the server modularization efforts.

Also applies to: 55-55, 66-66, 71-71, 194-194

src/main/java/de/tum/cit/aet/artemis/assessment/service/AssessmentService.java (1)

36-36: LGTM! The LTI service migration is consistent.

The changes correctly replace LtiNewResultService with LtiApi across imports, field declarations, constructor parameters, and method calls. The migration maintains the same functionality while aligning with the server modularization efforts.

Also applies to: 64-64, 72-72, 84-84, 246-250

src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1)

65-65: LGTM! The LTI service migration is consistent.

The changes correctly replace LtiNewResultService with LtiApi across imports, field declarations, constructor parameters, and method calls. The migration maintains the same functionality while aligning with the server modularization efforts.

Also applies to: 91-91, 133-136, 144-144, 192-194

src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java (1)

76-76: LGTM! The LTI service migration is consistent.

The changes correctly replace Lti13ResourceLaunchRepository with LtiApi across imports, field declarations, constructor parameters, and method calls. The migration maintains the same functionality while aligning with the server modularization efforts.

Also applies to: 108-108, 140-140, 152-152, 198-201

src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (4)

122-122: LGTM!

The import for LtiApi is correctly placed and aligns with the PR's objective of introducing the LTI module API.


150-150: LGTM!

The field declaration is well-designed:

  • Uses Optional to handle cases where LTI is not enabled
  • Follows immutability best practices with final
  • Maintains proper encapsulation with private

193-199: LGTM!

The constructor changes follow best practices:

  • Uses constructor injection as per coding guidelines
  • Maintains alphabetical parameter ordering
  • Properly handles optional LTI dependency

203-203: LGTM!

The field assignment is correctly implemented and follows the class's initialization pattern.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 8, 2025
HanyangXu0508
HanyangXu0508 previously approved these changes Feb 14, 2025
Copy link

@HanyangXu0508 HanyangXu0508 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 server3 and worked well.

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/exercise/service/ExerciseService.java (1)

88-88: Consider splitting this service into smaller, more focused services.

The ExerciseService class has grown quite large and handles multiple responsibilities (exercises, teams, statistics, competencies, etc.). Consider breaking it down into smaller, more focused services to improve maintainability and adhere to the Single Responsibility Principle.

Potential split:

  • ExerciseManagementService: Core exercise CRUD operations
  • ExerciseTeamService: Team-related operations
  • ExerciseStatisticsService: Statistics calculations
  • ExerciseCompetencyService: Competency-related operations
src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (2)

193-199: Consider reducing the constructor’s parameter list.
This constructor has many parameters, which can hamper readability and maintainability. You might consider refactoring to a builder/factory pattern or applying the single-responsibility principle to reduce complexity.


310-312: Use the functional style for Optionals.
Rather than calling isPresent() and then get(), consider using ltiApi.ifPresent(api -> api.createOnlineCourseConfiguration(courseUpdate)); for cleaner, more idiomatic code.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c09a7c8 and e9c320d.

📒 Files selected for processing (3)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (4 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`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/web/CourseResource.java
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java
  • src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java
🧠 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (2)
Learnt from: julian-christl
PR: ls1intum/Artemis#9322
File: src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java:0-0
Timestamp: 2024-11-12T12:51:51.201Z
Learning: In Artemis, an `ExerciseGroup` always has an associated `Exam`, so `exerciseGroup.exam` is never null.
Learnt from: julian-christl
PR: ls1intum/Artemis#9322
File: src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java:170-172
Timestamp: 2024-11-12T12:51:46.554Z
Learning: In Artemis, `exercise.exerciseGroup` may be null, as not all exercises belong to an `ExerciseGroup`.
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: client-style
  • GitHub Check: client-tests
  • GitHub Check: server-style
  • GitHub Check: server-tests
  • GitHub Check: Analyse
  • GitHub Check: Mend Security Check
🔇 Additional comments (13)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (5)

65-65: LGTM!

The import statement follows the coding guidelines by using a specific import rather than a star import.


91-91: LGTM!

The field declaration follows best practices:

  • Uses final modifier for immutability
  • Has private access following the principle of least privilege
  • Correctly uses Optional to handle potential absence of LTI functionality

133-136: LGTM!

The constructor changes follow the coding guidelines:

  • Uses constructor injection for dependency management
  • Maintains consistent parameter ordering and formatting

144-144: LGTM!

The field initialization is correctly done in the constructor and is consistent with the parameter changes.


192-193: LGTM!

The LTI service usage is correctly updated to use the new API while maintaining the same functionality:

  • Proper type checking for ProgrammingExerciseStudentParticipation
  • Correct null-safety check using Optional.isPresent()
  • Appropriate method call through the new API facade
src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java (5)

76-76: LGTM!

The import is correctly placed and follows Java best practices by using a specific import rather than a wildcard.


108-108: LGTM!

The field declaration follows best practices:

  • Appropriate access modifier (private)
  • Immutability (final)
  • Proper use of Optional for dependency injection

138-144: LGTM!

The constructor changes follow the coding guidelines:

  • Uses constructor injection
  • Maintains parameter ordering
  • Consistent with field declaration

152-152: LGTM!

The field initialization is consistent with the constructor parameter.


198-201: LGTM!

The changes successfully encapsulate the LTI resource check behind the new API while maintaining functional equivalence. This aligns well with the modularization objectives.

src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java (3)

122-122: Explicit import usage is consistent.
No issues identified. The explicit import of LtiApi aligns well with the guideline to avoid wildcard imports.


150-150: Optional dependency field injection looks fine.
Declaring this dependency as private final Optional<LtiApi> respects the principle of injecting dependencies via the constructor.


203-203: Straightforward assignment.
No issues identified regarding this.ltiApi = ltiApi;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assessment Pull requests that affect the corresponding module core Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module lti Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module quiz 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.

3 participants