-
Notifications
You must be signed in to change notification settings - Fork 311
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
Programming exercises
: Add endpoint to fetch ProgrammingExerciseStudentParticipation by repo
#9406
Conversation
WalkthroughThis pull request implements multiple modifications across the application’s programming exercise functionality. It adds a new field and getter to the Feedback domain class to store test case IDs more efficiently. A comprehensive DTO record for student participation, along with several nested DTOs for submissions, results, feedback, exercise details, course, and test case, is introduced. Furthermore, a new REST endpoint is added to fetch participation details by repository name with associated submissions, results, and feedbacks, along with corresponding integration tests. Additionally, a new constructor for building repository URIs and an extended repository query method for fetching the latest submission are incorporated. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ParticipationResource
participant SubmissionRepository
participant DTOConverter
Client->>ParticipationResource: Request participation by repo name
ParticipationResource->>SubmissionRepository: findLatestWithLatestResultAndFeedbacksByParticipationId(id)
SubmissionRepository-->>ParticipationResource: Latest submission with result and feedbacks
ParticipationResource->>DTOConverter: Convert domain objects to DTO
DTOConverter-->>ParticipationResource: Participation DTO
ParticipationResource-->>Client: 200 OK with Participation DTO
Suggested labels
Suggested reviewers
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/repository/ProgrammingSubmissionRepository.java[ERROR] Error at ruleset.xml:58:5 59| 67| 72| 76| 79| 80| 82| 83| 84| 85| 86| 87| 88| 91| 92| 107| 120| 125| 135| 138| 185| src/main/java/de/tum/cit/aet/artemis/programming/domain/VcsRepositoryUri.java[ERROR] Error at ruleset.xml:58:5 59| 67| 72| 76| 79| 80| 82| 83| 84| 85| 86| 87| 88| 91| 92| 107| 120| 125| 135| 138| 185| src/main/java/de/tum/cit/aet/artemis/programming/dto/RepoUrlProgrammingStudentParticipationDTO.java[ERROR] Error at ruleset.xml:58:5 59| 67| 72| 76| 79| 80| 82| 83| 84| 85| 86| 87| 88| 91| 92| 107| 120| 125| 135| 138| 185|
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)
Pattern
src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java
Outdated
Show resolved
Hide resolved
should be replaced by AtLeastStudentInExercise but this has to be implemented without the macro, because no exerciseID is passed |
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)
Pattern
src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java
Outdated
Show resolved
Hide resolved
ProgrammingExercise
: Add ProgrammingExercise by ProjectKey endpoint
ProgrammingExercise
: Add ProgrammingExercise by ProjectKey endpointProgramming Exercise
: Add ProgrammingExercise by ProjectKey endpoint
Programming Exercise
: Add ProgrammingExercise by ProjectKey endpointProgramming exercises
: Add ProgrammingExercise by ProjectKey endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but you also should add some simple server tests.
good point thanks |
…into feature/re-key
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |
There was a problem hiding this 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/programming/dto/RepoUrlProgrammingStudentParticipationDTO.java (3)
30-49
: Add field-level documentation.While the
of
method is well-documented, consider adding field-level documentation to describe the purpose of each field in the record, especially for fields likebuildPlanId
andbranch
whose meanings might not be immediately clear.Add Javadoc for fields:
@JsonInclude(JsonInclude.Include.NON_EMPTY) +/** + * DTO for programming exercise student participation accessed via repository URL. + * + * @param id The unique identifier of the participation + * @param individualDueDate Individual due date for this participation + * @param submissions Set of submissions for this participation + * @param participantName Name of the participant + * @param participantIdentifier Unique identifier of the participant + * @param repositoryUri URI of the student's repository + * @param buildPlanId Identifier for the CI/CD build plan + * @param branch The Git branch name for this participation + * @param exercise Associated programming exercise details + */ public record RepoUrlProgrammingStudentParticipationDTO(
51-70
: Maintain consistency in boolean field types.The record uses a mix of primitive
boolean
and wrapperBoolean
types. Consider using wrapper types consistently for all boolean fields to maintain uniformity in null handling.Apply this diff:
public record RepoUrlSubmissionDTO(long id, Boolean submitted, ZonedDateTime submissionDate, SubmissionType type, Boolean exampleSubmission, Long durationInMinutes, - List<RepoUrlResultDTO> results, String commitHash, boolean buildFailed) { + List<RepoUrlResultDTO> results, String commitHash, Boolean buildFailed) {
150-165
: Maintain consistency in numeric field types.The record uses a mix of primitive
double
and wrapperDouble
types. Consider using wrapper types consistently for all numeric fields to maintain uniformity in null handling.Apply this diff:
public record RepoUrlTestCaseDTO(long id, String testName, Double weight, - double bonusMultiplier, double bonusPoints, Boolean active, + Double bonusMultiplier, Double bonusPoints, Boolean active, Visibility visibility, ProgrammingExerciseTestCaseType type) {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/de/tum/cit/aet/artemis/programming/dto/RepoUrlProgrammingStudentParticipationDTO.java
(1 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/programming/dto/RepoUrlProgrammingStudentParticipationDTO.java
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: server-tests
- GitHub Check: client-tests
- GitHub Check: server-style
- GitHub Check: Call Build Workflow / Build .war artifact
- GitHub Check: Call Build Workflow / Build and Push Docker Image
- GitHub Check: Analyse
🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/programming/dto/RepoUrlProgrammingStudentParticipationDTO.java (1)
1-29
: LGTM! Clean imports organization.The imports are well-organized and specific, avoiding wildcard imports as per coding guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General feedback:
- Please re-add the motivation part in your PR description to explain the motivation behind this PR (e.g. why it is needed)
- Your test case table has 2 test cases outside of it. Maybe a formatting issue?
...in/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
Show resolved
Hide resolved
…om:ls1intum/Artemis into feature/programming-exercise-by-projectkey
There was a problem hiding this 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
♻️ Duplicate comments (2)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java (2)
195-198
: 🛠️ Refactor suggestionAdd @transactional annotation for database operations.
The method performs multiple database operations but lacks transaction management.
Add the @transactional annotation:
@GetMapping("programming-exercise-participations/repo-identifier/{repoIdentifier}") @EnforceAtLeastStudent @AllowedTools(ToolTokenType.SCORPIO) + @Transactional(readOnly = true) public ResponseEntity<RepoUrlProgrammingStudentParticipationDTO> getStudentParticipationWithLatestSubmissionLatestResultFeedbacksByRepoIdentifier(
202-203
:⚠️ Potential issueImprove input validation and error handling for repository identifier.
The current implementation has potential issues:
- No validation of repoIdentifier format
- Potential NPE when splitting project key
- No error handling for malformed URLs
Apply this diff to add proper validation and error handling:
- var projectKey = repoIdentifier.split("-")[0]; - String repoUrl = vcUrl + "/git/" + projectKey.toUpperCase() + "/" + repoIdentifier + ".git"; + if (repoIdentifier == null || repoIdentifier.isBlank()) { + throw new BadRequestAlertException("Repository identifier cannot be empty", ENTITY_NAME, "emptyIdentifier"); + } + + String[] parts = repoIdentifier.split("-"); + if (parts.length < 2) { + throw new BadRequestAlertException("Invalid repository identifier format. Expected format: projectKey-identifier", ENTITY_NAME, "invalidFormat"); + } + + var projectKey = parts[0].toUpperCase(); + try { + String repoUrl = vcUrl + "/git/" + projectKey + "/" + repoIdentifier + ".git"; + new URI(repoUrl); // Validate URL format + return repoUrl; + } catch (URISyntaxException e) { + throw new BadRequestAlertException("Invalid repository URL format: " + e.getMessage(), ENTITY_NAME, "invalidUrl"); + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
(8 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/programming/web/ProgrammingExerciseParticipationResource.java
🧠 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.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 (7)
- GitHub Check: Call Build Workflow / Build .war artifact
- GitHub Check: Call Build Workflow / Build and Push Docker Image
- GitHub Check: client-tests
- GitHub Check: client-style
- GitHub Check: server-tests
- GitHub Check: server-style
- GitHub Check: Analyse
🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java (1)
9-9
: LGTM! Constructor injection and field declarations follow best practices.The changes adhere to the coding guidelines:
- Constructor injection is used for dependencies
- Fields have appropriate access levels
- Imports follow Java conventions
Also applies to: 35-36, 79-82, 112-112, 119-120, 135-136
...in/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
Outdated
Show resolved
Hide resolved
...in/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed the code, see my inline comments.
I am somewhat concerned with the addition of a new column from Feedback->TestCase:
- coupling on DB-entities between assessment to programming => are there alternatives?
- how do we handle exercise that already exist in our (PROD-)DB? seems uncritical with
insertable/updatable = false
but would still need to be tested. - Nevertheless, I could not find a migration adding the column.
If you have questions regarding my feedback, feel free to reach out.
src/main/java/de/tum/cit/aet/artemis/exercise/repository/SubmissionRepository.java
Outdated
Show resolved
Hide resolved
...in/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
Show resolved
Hide resolved
...in/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
Outdated
Show resolved
Hide resolved
...in/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
Outdated
Show resolved
Hide resolved
...java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java
Show resolved
Hide resolved
There was a problem hiding this 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
♻️ Duplicate comments (1)
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java (1)
718-726
: 🛠️ Refactor suggestionAdd safety check for infinite loop scenario.
The do-while loop could theoretically run indefinitely if unique repository URLs cannot be generated.
+ int maxRetries = 10; + int retryCount = 0; do { + if (retryCount++ >= maxRetries) { + throw new IllegalStateException("Failed to generate unique repository URL after " + maxRetries + " attempts"); + } repoUrl = new URI(participation.getRepositoryUri()); repoUrl = new URI(repoUrl.getScheme(), repoUrl.getUserInfo(), repoUrl.getHost(), repoUrl.getPort(), "/" + UUID.randomUUID().toString(), repoUrl.getQuery(), repoUrl.getFragment()); foundParticipation = programmingExerciseStudentParticipationRepository.findByRepositoryUri(repoUrl.toString()); } while (foundParticipation.isPresent());
🧹 Nitpick comments (7)
src/main/java/de/tum/cit/aet/artemis/programming/domain/VcsRepositoryUri.java (1)
47-50
: Improve constructor documentation.The Javadoc should:
- Explain the expected format of repositoryName
- Document the thrown exceptions
- Provide example values
/** * Initializes a new instance of the {@link VcsRepositoryUri} class from a repository name * builds an url to format <server.url>/git/<project_key>/<repo-name>.git * + * Example: + * vcBaseUrl: "https://example.com" + * repositoryName: "PROJ-user123" + * Result: "https://example.com/git/PROJ/PROJ-user123.git" * * @param vcBaseUrl The base URL of the version control system * @param repositoryName containing the project key at the beginning + * @throws URISyntaxException if the constructed URI is invalid + * @throws IllegalArgumentException if the input parameters are invalid */src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java (2)
146-155
: Optimize JPQL query performance.The current query uses subqueries which could impact performance with large datasets. Consider:
- Using ORDER BY and LIMIT instead of subqueries
- Adding appropriate indexes for the join columns
- @Query(""" - SELECT DISTINCT s - FROM ProgrammingSubmission s - LEFT JOIN FETCH s.results r - LEFT JOIN FETCH r.feedbacks f - WHERE s.participation.id = :participationId - AND (s.id IS NULL OR s.id = (SELECT MAX(s2.id) FROM ProgrammingSubmission s2 WHERE s2.participation.id = :participationId)) - AND (r.id IS NULL OR r.id = (SELECT MAX(re2.id) FROM s.results re2)) - """) + @Query(value = """ + WITH LatestSubmission AS ( + SELECT MAX(s.id) as sid + FROM ProgrammingSubmission s + WHERE s.participation.id = :participationId + ), + LatestResult AS ( + SELECT MAX(r.id) as rid + FROM ProgrammingSubmission s + JOIN s.results r + WHERE s.id = (SELECT sid FROM LatestSubmission) + ) + SELECT DISTINCT s + FROM ProgrammingSubmission s + LEFT JOIN FETCH s.results r + LEFT JOIN FETCH r.feedbacks f + WHERE s.participation.id = :participationId + AND s.id = (SELECT sid FROM LatestSubmission) + AND (r.id IS NULL OR r.id = (SELECT rid FROM LatestResult)) + """)
146-155
: Add documentation for the query method.The method lacks documentation explaining its purpose and behavior.
+ /** + * Finds the latest submission for a participation along with its latest result and feedbacks. + * The method uses a complex query to: + * 1. Find the latest submission for the participation + * 2. Find the latest result for that submission + * 3. Eagerly fetch associated feedbacks + * + * @param participationId ID of the participation + * @return Optional containing the latest submission with its latest result and feedbacks, + * or empty if no submission exists + */ @Query("""src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java (2)
203-208
: Improve error handling for repository URL construction.The error handling for URI construction could be more descriptive.
- try { - repoUrl = new VcsRepositoryUri(vcUrl, repoName).toString(); - } - catch (URISyntaxException e) { - throw new BadRequestAlertException("Invalid repository URL", ENTITY_NAME, "invalidRepositoryUrl"); - } + try { + repoUrl = new VcsRepositoryUri(vcUrl, repoName).toString(); + } + catch (URISyntaxException e) { + throw new BadRequestAlertException("Failed to construct repository URL: " + e.getMessage(), ENTITY_NAME, "invalidRepositoryUrl"); + } + catch (IllegalArgumentException e) { + throw new BadRequestAlertException("Invalid repository name format: " + e.getMessage(), ENTITY_NAME, "invalidRepositoryName"); + }
186-195
: Enhance method documentation.The Javadoc should include:
- Response status codes
- Security considerations
- Example repository name format
/** * Get the given student participation with its latest submission, latest result and feedbacks by its repository identifier. * The repository name is the last part of the repository URL. * The repository URL is built as follows: {server.url}/git/{project_key}/{repo-name}.git * + * Example repository name: "PROJ-user123" + * + * Security: + * - Requires STUDENT role or higher + * - Checks if user has access to the participation + * - Filters sensitive information based on user role and exam status + * * @param repoName the URL repository identifier * @return the ResponseEntity with status 200 (OK) and the participation DTO {@link de.tum.cit.aet.artemis.programming.dto.RepoUrlProgrammingStudentParticipationDTO} in body, * or with status 404 (Not Found) if the participation is not found, * or with status 403 (Forbidden) if the user doesn't have access to the participation + * or with status 400 (Bad Request) if the repository name format is invalid */src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java (2)
755-758
: Add input validation to extractRepoName.The method assumes a specific URL format but doesn't validate the input.
String extractRepoName(String repoUrl) { + if (repoUrl == null || !repoUrl.endsWith(".git")) { + throw new IllegalArgumentException("Invalid repository URL format"); + } // <server.url>/git/<project_key>/<repo-name>.git return repoUrl.substring(repoUrl.lastIndexOf("/") + 1, repoUrl.length() - 4); }
656-754
: Group related test methods using @nested.The test methods for repository name functionality should be grouped using @nested for better organization.
+ @Nested + class GetProgrammingExerciseStudentParticipationByRepoNameTests { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void testGetProgrammingExerciseStudentParticipationByRepoName() throws Exception { // ... existing test } // ... other repo name related tests }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/de/tum/cit/aet/artemis/programming/domain/VcsRepositoryUri.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/programming/dto/RepoUrlProgrammingStudentParticipationDTO.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java
(2 hunks)src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
(7 hunks)src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/de/tum/cit/aet/artemis/programming/dto/RepoUrlProgrammingStudentParticipationDTO.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/programming/repository/ProgrammingSubmissionRepository.java
src/main/java/de/tum/cit/aet/artemis/programming/domain/VcsRepositoryUri.java
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.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/programming/ProgrammingExerciseParticipationIntegrationTest.java
🧠 Learnings (1)
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java (1)
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.
⏰ 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-style
- GitHub Check: server-style
- GitHub Check: client-tests
- GitHub Check: server-tests
- GitHub Check: Analyse
src/main/java/de/tum/cit/aet/artemis/programming/domain/VcsRepositoryUri.java
Show resolved
Hide resolved
...in/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for answering questions and integrating my suggestions, code looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with TS6. Reapprove
Checklist
General
Server
Changes affecting Programming Exercises
Motivation
The VSCode extension should be able to display the problem statement corresponding to an open repository by the user. Therefore it should be able to fetch all the information needed for that by the repository url.
Description
Adds an endpoint to fetch a student programming participation by the repo identifier (
<vc.url>/git/<project_key>/<repo_identifier>.git
) with the exercise, course, latest submission, last result with feedbacks. If the participation has at least a submission, the all testcases of the exercise are appended to the exercise.This endpoint will be used to automatically detect an participation from a repository url and display the problem statement to it (therefore course, exercise, testcases, submission, result and feedback are needed).
We could also use multiple endpoints to query each data individually but this would lead to more traffic.
Steps for Testing
Postman testing or code review:
Postman Testing with a student account:
{{base_url}}/api/public/authenticate?tool=SCORPIO
to login{{base_url}}/api/courses/{courseId}/for-dashboard
). The repo url should look like<vc.url>/git/<project_key>/<repo_identifier>.git
repo_identifier
from that url{{base_url}}/api/programming-exercise-participations/repo-identifier/{repo_identifier}
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
Code Review
Manual Tests
Test Coverage
Summary by CodeRabbit
@coderabbitai pause