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: initialize json structure quiz database #8430

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

Conversation

beyzaaltuntas
Copy link
Contributor

@beyzaaltuntas beyzaaltuntas commented Apr 18, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I strictly followed the server coding and design guidelines.
  • I documented the Java code using JavaDoc style.

Motivation and Context

The motivation for this task is serializing quiz questions into JSON format and storing them in a new database field to understand this approach could work and would serve as the basis for further development.

Description

Implement serialization of quiz questions into JSON strings and store them in a newly added database fields.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Student
  1. Log in to Artemis
  2. Navigate to Course Management
  3. Create a quiz and add different types of questions
  4. Check QuizQuestion table's content column if it includes json object of the QuizQuestion

Testserver States

Note

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







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Screenshots

@beyzaaltuntas beyzaaltuntas added feature ready for review server Pull requests that update Java code. (Added Automatically!) component:Quiz labels Apr 18, 2024
@beyzaaltuntas beyzaaltuntas self-assigned this Apr 18, 2024
@beyzaaltuntas beyzaaltuntas requested a review from a team as a code owner April 18, 2024 12:47
@github-actions github-actions bot added the database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. label Apr 18, 2024
coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 18, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 18, 2024
Hialus

This comment was marked as outdated.

@github-actions github-actions bot removed the stale label Apr 28, 2024
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Apr 28, 2024
@beyzaaltuntas beyzaaltuntas marked this pull request as draft April 28, 2024 20:54
coderabbitai[bot]

This comment was marked as outdated.

@krusche krusche mentioned this pull request May 31, 2024
@beyzaaltuntas beyzaaltuntas marked this pull request as ready for review June 5, 2024 08:06
Copy link

coderabbitai bot commented Jun 5, 2024

Warning

Rate limit exceeded

@beyzaaltuntas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 30 minutes and 10 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 27260d5 and 7ba7146.

Walkthrough

The recent changes to the Artemis project primarily focus on refactoring the quiz-related classes to improve serialization, remove unnecessary annotations, and enhance functionality by introducing new parameters and fields. The updates also include modifications to method signatures to support better handling of quiz questions and statistics, as well as adjustments to file handling methods to incorporate the question ID for more precise operations.

Changes

File(s) Change Summary
.../quiz/QuizPointStatistic.java, .../quiz/QuizQuestionStatistic.java Removed persistence annotations, added serialization, introduced new fields for participant ratings, and modified method signatures to include additional parameters for better handling of quiz exercises and questions.
.../quiz/ShortAnswerQuestion.java, .../quiz/ShortAnswerQuestionStatistic.java Removed persistence annotations, added JSON handling annotations, introduced new fields, and updated method signatures to improve handling of short answer questions and statistics.
.../DragAndDropQuizAnswerConversionService.java Updated drawDropLocation method to include a DragAndDropQuestion parameter for determining correctness.
.../FilePathService.java Added questionId parameter to publicPathForActualPathOrThrow and publicPathForActualPath methods to enable more precise file path generation.
.../quiz/QuizExerciseService.java Removed unnecessary imports and repository dependencies, adjusted constructor parameters, and refined file handling methods related to drag and drop questions.
.../web/rest/FileResource.java Removed DragItemRepository dependency, added QuizExerciseRepository dependency, and updated getDragItemFile method to fetch DragAndDropQuestion and DragItem using the questionId and dragItemId parameters.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant FileResource
    participant QuizExerciseRepository
    participant QuizQuestionRepository
    participant DragAndDropQuestion
    participant DragItem

    User->>+FileResource: getDragItemFile(questionId, dragItemId)
    FileResource->>+QuizQuestionRepository: findDnDQuestionByIdOrElseThrow(questionId)
    QuizQuestionRepository-->>-FileResource: DragAndDropQuestion
    FileResource->>+DragAndDropQuestion: getDragItem(dragItemId)
    DragAndDropQuestion-->>-FileResource: DragItem
    FileResource-->>-User: DragItem file

This diagram illustrates the updated control flow for fetching a drag item file, highlighting the interaction between FileResource, QuizQuestionRepository, and DragAndDropQuestion components.


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

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (invoked as PR comments)

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

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -36,7 +36,9 @@ public Jdk8Module jdk8TimeModule() {
*/
@Bean
public Hibernate6Module hibernate6Module() {
return new Hibernate6Module();
Hibernate6Module module = new Hibernate6Module();
module.disable(Hibernate6Module.Feature.USE_TRANSIENT_ANNOTATION);
Copy link
Member

Choose a reason for hiding this comment

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

please remove this change

Comment on lines +100 to +103
@Override
public void setQuestion(DragAndDropQuestion quizQuestion) {

}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this empty method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be removed in second iteration of the implementation(in a different branch).

Copy link
Member

@Hialus Hialus left a comment

Choose a reason for hiding this comment

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

Went through the (non-test) code and left a few comments. Let me know what you think.

General stuff:

  • Why is every JSON object that is stored in the DB also now Serializable? This is not needed for Jackson and only needed if you want to store it in binary form, which we should not do.
  • You use a lot of wrapper types (Integer, Double, etc.) but assign default values. So these should just be primitives, as they seem to be non null.
  • You specify a separate field for the JSON content to be stored in the DB and then separate fields for the content of that object. Personally I'd like to see you do the following to ensure better code quality.
    • Remove the separate fields and their setting in the PostLoad/PostUpdate
    • Change the getters/setters of those fields to to e.g. return this.content.getXYZ()
  • Please combine your changelog and changesets into a single changelog/changeset. Also please use a correct id as "00000000000002" is not correct. Instead you should use the date here as well.

import java.util.ArrayList;
import java.util.List;

public class DragAndDropDAO implements Serializable {
Copy link
Member

Choose a reason for hiding this comment

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

So far we did not use the term of "Data Access Object"s in Artemis. Is this really needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DAOs abstract and encapsulate all access to the data source. They separate the low-level data access logic from the high-level business logic, making the codebase more modular and easier to manage. I think there is no reason to not to use them.

@@ -64,38 +53,30 @@ public T save(T quizConfiguration) {

if (quizQuestion instanceof MultipleChoiceQuestion multipleChoiceQuestion) {
fixReferenceMultipleChoice(multipleChoiceQuestion);
QuizIdAssigner.assignIds(multipleChoiceQuestion.getAnswerOptions());
QuizIdAssigner.assignIds(((MultipleChoiceQuestionStatistic) multipleChoiceQuestion.getQuizQuestionStatistic()).getAnswerCounters());
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to use generics or something here, so that we do not have to cast here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

assignIds already use generics, here we need to know getQuizQuestionStatistic() returns MultipleChoiceQuestionStatistic object.

}

/**
* Fix references of Multiple Choice Question before saving to database
*
* @param multipleChoiceQuestion the MultipleChoiceQuestion which references are to be fixed
*/
private void fixReferenceMultipleChoice(MultipleChoiceQuestion multipleChoiceQuestion) {
public void fixReferenceMultipleChoice(MultipleChoiceQuestion multipleChoiceQuestion) {
Copy link
Member

Choose a reason for hiding this comment

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

Why are all these methods now public? As far as I can see they are only used in this class and in the tests. Making something public jsut so you can use it in the tests is not good style.

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: 16

Outside diff range comments (6)
src/test/java/de/tum/in/www1/artemis/exam/StudentExamIntegrationTest.java (6)

Line range hint 1-1: Consider adding a class-level Javadoc to provide an overview of the test class's purpose and scope.


Line range hint 1-1: Consider adding timeout assertions to ensure that tests complete within a reasonable time frame, enhancing the test suite's performance.


Line range hint 1-1: Consider using @DisplayName to provide descriptive names for test methods, enhancing readability and maintainability of the test suite.


[!TIP]
Codebase Verification

The extracted code snippets show that exceptions are being caught and handled, but there is a lack of assertions to verify the expected outcomes when exceptions are thrown. Specifically, the catch block logs the exception but does not assert the expected behavior.

  • The catch block for JsonProcessingException | JSONException uses fail to indicate an error but does not assert the expected outcome.
  • There is no use of assertThrows to verify that specific exceptions are thrown under expected conditions.

To improve the test methods, you should include assertions that verify the expected outcomes when exceptions are thrown. This can be done using assertThrows to ensure that the correct exceptions are thrown and handled appropriately.

Recommendations:

  • Use assertThrows to verify that specific exceptions are thrown.
  • Add assertions within the catch blocks to verify the expected state or outcome after an exception is caught.

Example:

assertThrows(JsonProcessingException.class, () -> {
    // code that is expected to throw JsonProcessingException
});

Locations to update:

  • src/test/java/de/tum/in/www1/artemis/exam/StudentExamIntegrationTest.java

Please update the test methods to include these assertions to ensure robust exception handling.

Analysis chain

Line range hint 1-1: Check that exception handling in the test methods is adequate, using assertions to verify expected outcomes when exceptions are thrown.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify exception handling in test methods.

# Test: Search for try-catch blocks and assertions related to exceptions. Expect: Adequate handling and assertions.
rg --type java 'try|catch|assertThrows' src/test/java/de/tum/in/www1/artemis/exam/StudentExamIntegrationTest.java

Length of output: 269



Script:

#!/bin/bash
# Description: Extract code snippets around try, catch, and assertThrows to verify exception handling and assertions.

# Extract 5 lines before and after the occurrences of try, catch, and assertThrows.
rg --type java -A 5 -B 5 'try|catch|assertThrows' src/test/java/de/tum/in/www1/artemis/exam/StudentExamIntegrationTest.java

Length of output: 1970


[!TIP]
Codebase Verification

The StudentExamIntegrationTest class does not use the @SpringBootTest or @AutoConfigureMockMvc annotations, nor does it use other common Spring test annotations like @ExtendWith, @ContextConfiguration, or @TestConfiguration. The annotations found are primarily @Autowired, @BeforeEach, @AfterEach, @Test, @WithMockUser, and @ParameterizedTest.

This suggests that the class might not be properly integrated with the Spring context as expected for an integration test. It would be beneficial to review the test setup to ensure it is correctly configured to use the Spring context.

  • Consider adding @SpringBootTest to the class to ensure it loads the full application context.
  • If specific configurations are needed, @ContextConfiguration or @TestConfiguration might be appropriate.

Please review the test class and ensure it is correctly set up to integrate with the Spring context.

  • Add @SpringBootTest or other appropriate Spring test annotations to the StudentExamIntegrationTest class.
Analysis chain

Line range hint 1-1: Verify that the test class uses the appropriate annotations to integrate with the Spring context, such as @SpringBootTest and @AutoConfigureMockMvc.


Let's verify if there are any other relevant Spring test annotations or configurations in the StudentExamIntegrationTest class. We will search for additional annotations such as @ExtendWith, @ContextConfiguration, and @TestConfiguration.


Let's search for any annotations present in the StudentExamIntegrationTest class to identify if there are any custom or less common configurations being used.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the use of Spring Boot test annotations.

# Test: Search for Spring Boot test annotations. Expect: At least one occurrence of `@SpringBootTest` or `@AutoConfigureMockMvc`.
rg --type java "@SpringBootTest|@AutoConfigureMockMvc" src/test/java/de/tum/in/www1/artemis/exam/StudentExamIntegrationTest.java

Length of output: 130



Script:

#!/bin/bash
# Description: Verify the use of other Spring test annotations.

# Test: Search for other common Spring test annotations.
rg --type java "@ExtendWith|@ContextConfiguration|@TestConfiguration" src/test/java/de/tum/in/www1/artemis/exam/StudentExamIntegrationTest.java

Length of output: 145



Script:

#!/bin/bash
# Description: Search for any annotations in the StudentExamIntegrationTest class.

# Test: Search for any annotations in the specified test class.
rg --type java "@.*" src/test/java/de/tum/in/www1/artemis/exam/StudentExamIntegrationTest.java

Length of output: 9458


[!TIP]
Codebase Verification

The verification script output indicates that several methods in the identified files are not annotated with @Test. This confirms the concern that some test methods are missing the @Test annotation.

Here are the files and methods that need attention:

  • src/test/java/de/tum/in/www1/artemis/user/UserTestService.java

    • tearDown()
    • deleteUser_isSuccessful()
    • updateUser_asAdmin_isSuccessful()
    • updateUserWithEmptyRoles()
    • updateUser_withNullPassword_oldPasswordNotChanged()
    • updateUserLogin()
    • updateUserInvalidId()
    • updateUserExistingEmail()
    • updateUser_withExternalUserManagement()
    • updateUserGroups()
    • createExternalUser_asAdmin_withVcsToken_isSuccessful()
    • createInternalUser_asAdmin_isSuccessful()
    • createInternalUserWithoutRoles_asAdmin_isSuccessful()
    • createUser_asAdmin_hasId()
    • createUser_asAdmin_existingLogin()
    • createUser_asAdmin_existingEmail()
    • createUserAsAdminExistsInCi()
    • createUser_asAdmin_illegalLogin_internalError()
    • createUser_asAdmin_failInExternalCiUserManagement_internalError()
    • createUser_asAdmin_failInExternalCiUserManagement_cannotGetCiUser_internalError()
    • createUser_asAdmin_failInExternalVcsUserManagement_internalError()
    • createUser_withNullAsPassword_generatesRandomPassword()
    • createUser_withExternalUserManagement()
    • createUserWithGroups()
    • getUsers_asAdmin_isSuccessful()
    • searchUsers_asInstructor_isSuccessful()
    • searchUsers_asAdmin_badRequest()
    • searchUsers_asTutor_forbidden()
    • getUserViaFilter_asAdmin_isSuccessful()
    • getAuthorities_asAdmin_isSuccessful()
    • getUsersOrAuthorities_asInstructor_forbidden()
    • getUsersOrAuthorities_asTutor_forbidden()
    • getUsersOrAuthorities_asStudent_forbidden()
    • getUser_asAdmin_isSuccessful()
    • updateUserNotificationDate_asStudent_isSuccessful()
    • updateUserNotificationVisibilityShowAllAsStudentIsSuccessful()
    • updateUserNotificationVisibilityHideUntilAsStudentIsSuccessful()
    • initializeUserWithoutFlag()
    • initializeUserNonLTI()
    • initializeUserExternal()
    • testUser()
    • testUserWithoutGroups()
    • testUserWithActivatedStatus()
    • testUserWithDeactivatedStatus()
    • testUserWithInternalStatus()
    • testUserWithExternalStatus()
    • testUserWithExternalAndInternalStatus()
    • testUserWithRegistrationNumber()
    • testUserWithoutRegistrationNumber()
  • src/test/java/de/tum/in/www1/artemis/util/RequestUtilService.java

    • restoreSecurityContext()
  • src/test/java/de/tum/in/www1/artemis/util/HibernateQueryInterceptor.java

    • startQueryCount()
  • src/test/java/de/tum/in/www1/artemis/util/LocalRepository.java

    • resetLocalRepo()
  • src/test/java/de/tum/in/www1/artemis/util/GitUtilService.java

    • initRepo()
    • reinitializeLocalRepository()
    • reinitializeRemoteRepository()
    • deleteRepos()
  • src/test/java/de/tum/in/www1/artemis/tutorialgroups/TutorialGroupUtilService.java

    • addTutorialCourse()
  • src/test/java/de/tum/in/www1/artemis/service/FileServiceTest.java

    • someMethod()
  • src/test/java/de/tum/in/www1/artemis/service/ConsistencyCheckTestService.java

    • testCheckConsistencyOfProgrammingExercise_noErrors()
    • testCheckConsistencyOfProgrammingExercise_missingVCSProject()
    • testCheckConsistencyOfProgrammingExercise_missingVCSRepos()
    • testCheckConsistencyOfProgrammingExercise_buildPlansMissing()
    • testCheckConsistencyOfProgrammingExercise_forbidden()
  • src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211216_231800.java

    • execute()
  • src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211215_231800.java

    • execute()
  • src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211214_231800.java

    • execute()
  • src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseUtilService.java

    • createGitRepository()
  • src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTestService.java

    • tearDown()
    • importFromFile_exception_DirectoryDeleted()
    • importProgrammingExerciseAsPartOfExamImport()
  • src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseResultTestService.java

    • tearDown()
  • src/test/java/de/tum/in/www1/artemis/exercise/programming/ContinuousIntegrationTestService.java

    • tearDown()
    • testGetBuildStatusNotFound()
    • testGetBuildStatusInactive1()
    • testGetBuildStatusInactive2()
    • testGetBuildStatusQueued()
    • testGetBuildStatusBuilding()
    • testGetBuildStatusFails()
    • testHealthRunning()
    • testHealthNotRunning()
    • testHealthException()
    • testConfigureBuildPlan()
  • src/test/java/de/tum/in/www1/artemis/course/CourseTestService.java

    • adjustUserGroupsToCustomGroups()
    • testCreateCourseWithPermission()
    • testCreateCourseWithSameShortName()
    • testCreateCourseWithNegativeMaxComplainNumber()
    • testCreateCourseWithNegativeMaxComplainTimeDays()
    • testCreateCourseWithNegativeMaxTeamComplainNumber()
    • testCreateCourseWithNegativeMaxComplaintTextLimit()
    • testCreateCourseWithNegativeMaxComplaintResponseTextLimit()
    • testCreateCourseWithModifiedMaxComplainTimeDaysAndMaxComplains()
    • testCreateCourseWithCustomNonExistingGroupNames()
    • testCreateCourseWithOptions()
    • testDeleteCourseWithPermission()
    • testDeleteNotExistingCourse()
    • testCreateCourseWithoutPermission()
    • testCreateCourseWithWrongShortName()
    • testCreateCourseWithDefaultChannels()
    • testUpdateCourseIsEmpty()
    • testEditCourseWithPermission()
    • testEditCourseShouldPreserveAssociations()
    • testUpdateCourseGroups()
    • testCreateAndUpdateCourseWithCourseImage()
    • testCreateAndUpdateCourseWithPersistentCourseImageOnUpdate()
    • testCreateAndUpdateCourseWithRemoveCourseImageOnUpdate()
    • testCreateAndUpdateCourseWithSetNewImageDespiteRemoval()
    • testUpdateCourseGroups_InExternalCiUserManagement_failToRemoveUser()
    • testUpdateCourseGroups_InExternalCiUserManagement_failToAddUser()
    • testGetCourseWithoutPermission()
    • testGetCourse_tutorNotInCourse()
    • testGetCoursesWithPermission()
    • testGetCoursesWithQuizExercises()
    • testGetCourseForDashboardForbiddenWithEnrollmentPossible()
    • testGetCourseForEnrollment()
    • testGetCourseForEnrollmentAccessDenied()
    • testGetCoursesForDashboardPracticeRepositories()
    • testGetAllCoursesForDashboard()
    • testGetCoursesWithoutActiveExercises()
    • testGetCoursesAccurateTimezoneEvaluation()
    • testGetCourseWithOrganizations()
    • testGetAllCoursesWithUserStats()
    • testGetCoursesForEnrollmentAndAccurateTimeZoneEvaluation()
    • testGetCourseForAssessmentDashboardWithStats()
    • testGetCourseForAssessmentDashboard_averageRatingComputedCorrectly()
    • testGetCourseForInstructorDashboardWithStats_instructorNotInCourse()
    • testGetCourseForAssessmentDashboardWithStats_tutorNotInCourse()
    • testGetAllGroupsForAllCourses()
    • testGetAssessmentDashboardStats_withoutAssessments()
    • testGetAssessmentDashboardStats_withAssessments()
    • testGetAssessmentDashboardStats_withAssessmentsAndComplaints()
    • testGetAssessmentDashboardStats_withAssessmentsAndFeedbackRequests()
    • testGetAssessmentDashboardStats_withAssessmentsAndComplaintsAndResponses()
    • testGetAssessmentDashboardStats_withAssessmentsAndFeedBackRequestsAndResponses()
    • testGetAssessmentDashboardStats_withAssessmentsAndComplaintsAndResponses_Large()
    • testGetCourse()
    • testGetCategoriesInCourse()
    • testGetCategoriesInCourse_instructorNotInCourse()
    • testEnrollInCourse()
    • testEnrollInCourse_notMeetsDate()
    • testUnenrollFromCourse()
    • testUpdateCourse_instructorNotInCourse()
    • testGetAllStudentsOrTutorsOrInstructorsInCourse()
    • testSearchStudentsAndTutorsAndInstructorsInCourse()
    • testSearchStudentsAndTutorsAndInstructorsInOtherCourseForbidden()
    • testGetAllEditorsInCourse()
    • testGetAllStudentsOrTutorsOrInstructorsInCourse_AsInstructorOfOtherCourse_forbidden()
    • testGetAllStudentsOrTutorsOrInstructorsInCourse_AsTutor_forbidden()
    • testAddStudentOrTutorOrEditorOrInstructorToCourse()
    • testAddStudentOrTutorOrInstructorToCourse_AsInstructorOfOtherCourse_forbidden()
    • testAddStudentOrTutorOrInstructorToCourse_AsTutor_forbidden()
    • testAddStudentOrTutorOrInstructorToCourse_WithNonExistingUser()
    • testRemoveTutorFromCourse_failsToRemoveUserFromGroup()
    • testRemoveStudentOrTutorOrInstructorFromCourse()
    • testRemoveStudentOrTutorOrEditorOrInstructorFromCourse_WithNonExistingUser()
    • testRemoveStudentOrTutorOrInstructorFromCourse_AsInstructorOfOtherCourse_forbidden()
    • testRemoveStudentOrTutorOrInstructorFromCourse_AsTutor_forbidden()
    • testGetLockedSubmissionsForCourseAsTutor()
    • testGetLockedSubmissionsForCourseAsStudent()
    • testArchiveCourseAsStudent_forbidden()
    • testArchiveCourseAsTutor_forbidden()
    • testArchiveCourseWithQuizExerciseCannotExportExerciseDetails()
    • testArchiveCourseWithQuizExerciseCannotExportDragAndDropSubmission()
    • testArchiveCourseWithQuizExerciseCannotCreateParticipationDirectory()
    • searchStudentsInCourse()
    • searchUsersInCourse_searchForAllTutors_shouldReturnAllTutorsAndEditors()
    • searchUsersInCourse_searchForAllInstructor_shouldReturnAllInstructors()
    • searchUsersInCourse_searchForAllStudents_shouldReturnBadRequest()
    • searchUsersInCourse_searchForStudentsAndTooShortSearchTerm_shouldReturnBadRequest()
    • searchUsersInCourse_searchForStudents_shouldReturnUsersMatchingSearchTerm()
    • searchUsersInCourse_searchForAllTutorsAndInstructors_shouldReturnAllTutorsEditorsAndInstructors()
    • searchUsersInCourse_searchForTutorsAndInstructors_shouldReturnUsersMatchingSearchTerm()
    • searchUsersInCourse_searchForStudentsTutorsAndInstructorsAndTooShortSearchTerm_shouldReturnBadRequest()
    • searchUsersInCourse_searchForStudentsTutorsEditorsAndInstructors_shouldReturnUsersMatchingSearchTerm()
    • testSearchMembersForUserMentionsSearchTermFilteringCorrect()
    • testSearchMembersForUserMentionsSearchResultLimit()
    • testSearchMembersForUserMentionsNoSearchTerm()
    • testArchiveCourseWithTestModelingAndFileUploadExercisesFailToExportModelingExercise()
    • testArchiveCourseWithTestModelingAndFileUploadExercisesFailToExportTextExercise()
    • testArchiveCourseWithTestModelingAndFileUploadExercisesFailToExportFileUploadExercise()
    • testExportCourse_cannotCreateTmpDir()
    • testExportCourse_cannotCreateCourseExercisesDir()
    • testExportCourseExam_cannotCreateTmpDir()
    • testExportCourseExam_cannotCreateExamsDir()
    • testDownloadCourseArchiveAsStudent_forbidden()
    • testDownloadCourseArchiveAsTutor_forbidden()
    • testDownloadCourseArchiveAsInstructor_not_found()
    • testDownloadCourseArchiveAsInstructor()
    • testCleanupCourseAsStudent_forbidden()
    • testCleanupCourseAsTutor_forbidden()
    • testCleanupCourseAsInstructor_no_Archive()
    • testCleanupCourseAsInstructor()
    • testGetCourseTitle()
    • testGetCourseTitleForNonExistingCourse()
    • testGetAllCoursesForManagementOverview()
    • testGetExercisesForCourseOverview()
    • testGetExerciseStatsForCourseOverview()
    • testGetExerciseStatsForCourseOverviewWithPastExercises()
    • testGetCourseManagementDetailDataForFutureCourse()
    • testGetCourseManagementDetailData()
    • testCreateCourseWithValidStartAndEndDate()
    • testCreateCourseWithInvalidStartAndEndDate()
    • testCreateInvalidOnlineCourse()
    • testCreateValidOnlineCourse()
    • testUpdateToOnlineCourse()
    • testOnlineCourseConfigurationIsLazyLoaded()
    • testUpdateOnlineCourseConfiguration()
    • testUpdateCourseRemoveOnlineCourseConfiguration()
    • testDeleteCourseDeletesOnlineConfiguration()
    • testUpdateInvalidOnlineCourseConfiguration()
    • testUpdateValidOnlineCourseConfigurationAsStudent_forbidden()
    • testUpdateValidOnlineCourseConfigurationNotOnlineCourse()
    • testUpdateValidOnlineCourseConfiguration_IdMismatch()
    • testUpdateValidOnlineCourseConfiguration()
    • testFindAllOnlineCoursesForLtiDashboard()
    • testEditCourseRemoveExistingIcon()
    • testUpdateCourseEnableLearningPaths()
    • testGetCoursesForImportWithoutPermission()
    • testGetCoursesForImport()
  • src/test/java/de/tum/in/www1/artemis/connector/apollon/ApollonRequestMockProvider.java

    • enableMockingOfRequests()
    • reset()
  • src/test/java/de/tum/in/www1/artemis/connector/JenkinsRequestMockProvider.java

    • reset()
    • verifyMocks()
  • src/test/java/de/tum/in/www1/artemis/connector/IrisRequestMockProvider.java

    • enableMockingOfRequests()
    • reset()
    • mockModelsResponse()
    • mockStatusResponse()
    • mockModelsError()
  • src/test/java/de/tum/in/www1/artemis/connector/GitlabRequestMockProvider.java

    • enableMockingOfRequests()
    • reset()
    • verifyMocks()
    • mockGetUserApi()
    • mockGetUserID()
    • mockUpdateUser()
    • mockAddAuthenticatedWebHook()
    • mockCreatePersonalAccessTokenError()
  • src/test/java/de/tum/in/www1/artemis/connector/AthenaRequestMockProvider.java

    • enableMockingOfRequests()
    • reset()
    • mockGetAvailableModulesSuccessEmptyModulesList()
    • mockGetAvailableModulesSuccess()
    • mockHealthStatusFailure()
    • verify()
  • src/test/java/de/tum/in/www1/artemis/connector/AeolusRequestMockProvider.java

    • enableMockingOfRequests()
    • reset()
  • src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationLocalCILocalVCTest.java

    • resetMockProvider()
    • verifyMocks()
  • src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationIndependentTest.java

    • resetMockProvider()
    • verifyMocks()
  • src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationJenkinsGitlabTest.java

    • resetMockProvider()
    • verifyMocks()
  • src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java

    • resetMockProvider()
    • verifyMocks()

Please ensure that these methods are properly annotated with @Test to follow the naming conventions for test methods.

Analysis chain

Line range hint 1-1: Ensure that the test methods are properly annotated with @Test and that they follow the naming conventions for test methods.


The verification script did not produce any output, which suggests that the identified methods might not have the @Test annotation. However, to ensure thorough verification, we need to check for the presence of @Test annotations in these files more comprehensively.

Let's run a script to list all methods in the identified files and check if they are annotated with @Test.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the use of `@Test` annotations and naming conventions.

# Test: Search for test methods without `@Test` annotation or with non-standard names. Expect: No such methods.
rg --type java 'public void [a-z][a-zA-Z0-9_]*\(\)' -g "src/test/java/**/*.java"

Length of output: 37764



Script:

#!/bin/bash
# Description: Verify the presence of `@Test` annotations for the identified methods.

# List of files with methods that need verification for `@Test` annotations.
files=(
  "src/test/java/de/tum/in/www1/artemis/user/UserTestService.java"
  "src/test/java/de/tum/in/www1/artemis/util/RequestUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/util/HibernateQueryInterceptor.java"
  "src/test/java/de/tum/in/www1/artemis/util/LocalRepository.java"
  "src/test/java/de/tum/in/www1/artemis/util/GitUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/tutorialgroups/TutorialGroupUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/service/FileServiceTest.java"
  "src/test/java/de/tum/in/www1/artemis/service/ConsistencyCheckTestService.java"
  "src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211216_231800.java"
  "src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211215_231800.java"
  "src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211214_231800.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/quiz/QuizIdAssignerTest.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTestService.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseResultTestService.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ContinuousIntegrationTestService.java"
  "src/test/java/de/tum/in/www1/artemis/hestia/StructuralTestCaseServiceTest.java"
  "src/test/java/de/tum/in/www1/artemis/course/CourseTestService.java"
  "src/test/java/de/tum/in/www1/artemis/connector/apollon/ApollonRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/JenkinsRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/IrisRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/GitlabRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/AthenaRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/AeolusRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationLocalCILocalVCTest.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationIndependentTest.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationJenkinsGitlabTest.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java"
)

# Check for `@Test` annotations in the identified files.
for file in "${files[@]}"; do
  echo "Checking file: $file"
  rg --pcre2 --multiline '@Test\s+public void [a-z][a-zA-Z0-9_]*\(\)' "$file"
done

Length of output: 13145



Script:

#!/bin/bash
# Description: List all methods in the identified files and check for `@Test` annotations.

# List of files with methods that need verification for `@Test` annotations.
files=(
  "src/test/java/de/tum/in/www1/artemis/user/UserTestService.java"
  "src/test/java/de/tum/in/www1/artemis/util/RequestUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/util/HibernateQueryInterceptor.java"
  "src/test/java/de/tum/in/www1/artemis/util/LocalRepository.java"
  "src/test/java/de/tum/in/www1/artemis/util/GitUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/tutorialgroups/TutorialGroupUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/service/FileServiceTest.java"
  "src/test/java/de/tum/in/www1/artemis/service/ConsistencyCheckTestService.java"
  "src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211216_231800.java"
  "src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211215_231800.java"
  "src/test/java/de/tum/in/www1/artemis/migration/entries/TestChangeEntry20211214_231800.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/quiz/QuizIdAssignerTest.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseUtilService.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTestService.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseResultTestService.java"
  "src/test/java/de/tum/in/www1/artemis/exercise/programming/ContinuousIntegrationTestService.java"
  "src/test/java/de/tum/in/www1/artemis/hestia/StructuralTestCaseServiceTest.java"
  "src/test/java/de/tum/in/www1/artemis/course/CourseTestService.java"
  "src/test/java/de/tum/in/www1/artemis/connector/apollon/ApollonRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/JenkinsRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/IrisRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/GitlabRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/AthenaRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/connector/AeolusRequestMockProvider.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationLocalCILocalVCTest.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationIndependentTest.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationJenkinsGitlabTest.java"
  "src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java"
)

# Check for methods and their annotations in the identified files.
for file in "${files[@]}"; do
  echo "Checking file: $file"
  rg --pcre2 --multiline '(?P<annotation>@Test)?\s*public void [a-z][a-zA-Z0-9_]*\(\)' "$file"
done

Length of output: 35855

@@ -36,7 +36,9 @@ public Jdk8Module jdk8TimeModule() {
*/
@Bean
public Hibernate6Module hibernate6Module() {
return new Hibernate6Module();
Hibernate6Module module = new Hibernate6Module();
module.disable(Hibernate6Module.Feature.USE_TRANSIENT_ANNOTATION);
Copy link

Choose a reason for hiding this comment

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

Please revert the change unless there's a specific reason for disabling USE_TRANSIENT_ANNOTATION.

This change might affect the serialization behavior of transient fields. If this is intentional and necessary, please provide a justification in the comments to maintain clarity for future maintenance.

Comment on lines 137 to 142
if (submittedAnswer instanceof MultipleChoiceSubmittedAnswer) {
QuizIdAssigner.assignIds(((MultipleChoiceSubmittedAnswer) submittedAnswer).getSelectedOptions());
}
else if (submittedAnswer instanceof DragAndDropSubmittedAnswer) {
QuizIdAssigner.assignIds(((DragAndDropSubmittedAnswer) submittedAnswer).getMappings());
}
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The assignIds method in QuizIdAssigner does not explicitly handle null inputs for the items parameter. This could potentially lead to a NullPointerException if items is null.

  • Location: src/main/java/de/tum/in/www1/artemis/service/quiz/QuizIdAssigner.java

Please ensure that the assignIds method includes a null check for the items parameter to handle null inputs gracefully.

Analysis chain

Ensure that the QuizIdAssigner.assignIds method is robust against null or invalid inputs.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `QuizIdAssigner.assignIds` method handles null or invalid inputs gracefully.

# Test: Search for method implementation. Expect: Proper null checks and error handling.
rg --type java $'QuizIdAssigner.assignIds'

Length of output: 7960



Script:

#!/bin/bash
# Description: Locate and inspect the implementation of the `assignIds` method in the `QuizIdAssigner` class.

# Search for the implementation of the `assignIds` method in the `QuizIdAssigner` class.
ast-grep --lang java --pattern $'class QuizIdAssigner {
  $$$
  void assignIds($_) {
    $$$
  }
  $$$
}'

Length of output: 232



Script:

#!/bin/bash
# Description: Locate the `QuizIdAssigner` class and inspect the implementation of the `assignIds` method.

# Search for the `QuizIdAssigner` class definition.
rg --type java 'class QuizIdAssigner' -l | xargs rg --type java 'void assignIds'

Length of output: 233



Script:

#!/bin/bash
# Description: Extract and inspect the implementation of the `assignIds` method in `QuizIdAssigner.java`.

# Extract the implementation of the `assignIds` method.
rg --type java -A 20 'public static <T extends TempIdObject> void assignIds' src/main/java/de/tum/in/www1/artemis/service/quiz/QuizIdAssigner.java

Length of output: 552

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Copy link
Contributor

@sarpsahinalp sarpsahinalp left a comment

Choose a reason for hiding this comment

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

.

@@ -109,7 +90,7 @@ private void fixReferenceMultipleChoice(MultipleChoiceQuestion multipleChoiceQue
*
* @param dragAndDropQuestion the DragAndDropQuestion which references are to be fixed
*/
private void fixReferenceDragAndDrop(DragAndDropQuestion dragAndDropQuestion) {
public void fixReferenceDragAndDrop(DragAndDropQuestion dragAndDropQuestion) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As Timor pointed out, private methods should not be made public just for testing purposes in the test code. Consider testing them indirectly through the public method that calls them

Copy link
Contributor

@sarpsahinalp sarpsahinalp left a comment

Choose a reason for hiding this comment

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

Please take a look at the server tests there are 353 new test failures

@ls1intum ls1intum deleted a comment from Hialus Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) component:Quiz database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. feature ready for review server Pull requests that update Java code. (Added Automatically!) tests too-long-open !!! This is an antipattern, we should aim for small PRs that are only open for a short time !!!
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

None yet

5 participants