Skip to content

Development: Remove quiz view and switch to DTOs #10571

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

Merged
merged 30 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
45f1a83
Working on migrating away from QuizView to DTOs
KonstiAnon Jan 28, 2025
4e71831
Merge branch 'develop' into chore/quiz-exercises/dto-migration
KonstiAnon Feb 4, 2025
ade0d7a
Remove redundant '{}'
KonstiAnon Feb 4, 2025
c807c7d
Working on DTOs, have implemented DTO for ShortAnswerQuestion
KonstiAnon Feb 4, 2025
9243e3f
Merge remote-tracking branch 'origin/develop' into chore/quiz-exercis…
KonstiAnon Mar 4, 2025
bf8b136
Working on migrating away from QuizView to DTOs
KonstiAnon Mar 4, 2025
1269d57
Continuing work on DTOs
KonstiAnon Mar 11, 2025
1461b4d
Implemented DTOs for QuizQuestion
KonstiAnon Mar 15, 2025
1591159
Working on QuizExercise DTO Migration
KonstiAnon Mar 15, 2025
fbfef10
Implemented DTOs for StudentParticipation
KonstiAnon Mar 18, 2025
ecee3c9
Fixed errors and formatting for all DTOs
KonstiAnon Mar 19, 2025
10c7255
Finishing DTOs for start-participation endpoint
KonstiAnon Mar 19, 2025
3d6f3e3
Finishing work on result dto
KonstiAnon Mar 22, 2025
395cc56
Last commit before JsonView is deleted
KonstiAnon Mar 22, 2025
137e082
Merge branch 'develop' into chore/quiz-exercises/dto-migration
KonstiAnon Mar 22, 2025
336674f
Deleted QuizView and its usages
KonstiAnon Mar 22, 2025
9d96cbb
Made getCourse public to it can be included in Json
KonstiAnon Mar 22, 2025
cf47d36
Fixed annotations
KonstiAnon Mar 22, 2025
93627e9
.... so many hours because of one line
KonstiAnon Mar 23, 2025
7f4f22b
Merge branch 'develop' into chore/quiz-exercises/dto-migration
KonstiAnon Mar 23, 2025
f315b85
Merge branch 'develop' into chore/quiz-exercises/dto-migration
KonstiAnon Mar 23, 2025
6fad826
removed unused DTOs
KonstiAnon Mar 23, 2025
ced9f44
Merge branch 'develop' into chore/quiz-exercises/dto-migration
krusche Mar 24, 2025
2f4451f
Clean up code
krusche Mar 24, 2025
1bd4049
Merge branch 'develop' into chore/quiz-exercises/dto-migration
krusche Mar 24, 2025
b6b4c56
fix check style warnings
krusche Mar 24, 2025
46966ae
Merge branch 'develop' into chore/quiz-exercises/dto-migration
AjayvirS Mar 25, 2025
b2b6b1f
Added integration test and renamed StudentQuizParticipation
KonstiAnon Mar 25, 2025
0eaff4e
Made the Course getter protected again
KonstiAnon Mar 25, 2025
17fa366
Merge branch 'develop' into chore/quiz-exercises/dto-migration
Hialus Mar 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonView;

import de.tum.cit.aet.artemis.assessment.ResultListener;
import de.tum.cit.aet.artemis.core.domain.Course;
Expand All @@ -51,7 +50,6 @@
import de.tum.cit.aet.artemis.exercise.service.ExerciseDateService;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise;
import de.tum.cit.aet.artemis.programming.dto.ResultDTO;
import de.tum.cit.aet.artemis.quiz.config.QuizView;
import de.tum.cit.aet.artemis.quiz.domain.QuizExercise;
import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission;

Expand All @@ -66,18 +64,15 @@
public class Result extends DomainObject implements Comparable<Result> {

@Column(name = "completion_date")
@JsonView(QuizView.Before.class)
private ZonedDateTime completionDate;

@Column(name = "jhi_successful")
@JsonView(QuizView.After.class)
private Boolean successful;

/**
* Relative score in % (typically between 0 ... 100, can also be larger if bonus points are available)
*/
@Column(name = "score")
@JsonView(QuizView.After.class)
private Double score;

/**
Expand All @@ -89,26 +84,22 @@ public class Result extends DomainObject implements Comparable<Result> {
* be rated=true, then the result with the last completionDate counts towards the total score of a student - results are rated=false when students submit after the due date
*/
@Column(name = "rated")
@JsonView(QuizView.Before.class)
private Boolean rated;

@ManyToOne(fetch = FetchType.LAZY)
@JsonView(QuizView.Before.class)
@JsonIgnoreProperties({ "results", "participation" })
private Submission submission;

@OneToMany(mappedBy = "result", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderColumn
@JsonIgnoreProperties(value = "result", allowSetters = true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JsonView(QuizView.Before.class)
private List<Feedback> feedbacks = new ArrayList<>();

/**
* @deprecated: Will be removed for 8.0, please use submission.participation instead
*/
@ManyToOne
@JsonView(QuizView.Before.class)
@Deprecated(since = "7.7", forRemoval = true)
private Participation participation;

Expand All @@ -118,7 +109,6 @@ public class Result extends DomainObject implements Comparable<Result> {

@Enumerated(EnumType.STRING)
@Column(name = "assessment_type")
@JsonView(QuizView.After.class)
private AssessmentType assessmentType;

@Column(name = "has_complaint")
Expand Down
27 changes: 0 additions & 27 deletions src/main/java/de/tum/cit/aet/artemis/core/domain/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonView;

import de.tum.cit.aet.artemis.atlas.domain.competency.Competency;
import de.tum.cit.aet.artemis.atlas.domain.competency.LearningPath;
Expand All @@ -45,7 +44,6 @@
import de.tum.cit.aet.artemis.lecture.domain.Lecture;
import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage;
import de.tum.cit.aet.artemis.quiz.config.QuizView;
import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup;
import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupsConfiguration;

Expand All @@ -63,73 +61,56 @@ public class Course extends DomainObject {
private static final int DEFAULT_COMPLAINT_TEXT_LIMIT = 2000;

@Column(name = "title")
@JsonView(QuizView.Before.class)
private String title;

@Column(name = "description")
@JsonView(QuizView.Before.class)
private String description;

@Column(name = "short_name", unique = true)
@JsonView(QuizView.Before.class)
private String shortName;

@Column(name = "student_group_name")
@JsonView(QuizView.Before.class)
private String studentGroupName;

@Column(name = "teaching_assistant_group_name")
@JsonView(QuizView.Before.class)
private String teachingAssistantGroupName;

@Column(name = "editor_group_name")
@JsonView(QuizView.Before.class)
private String editorGroupName;

@Column(name = "instructor_group_name")
@JsonView(QuizView.Before.class)
private String instructorGroupName;

@Column(name = "start_date")
@JsonView(QuizView.Before.class)
private ZonedDateTime startDate;

@Column(name = "end_date")
@JsonView(QuizView.Before.class)
private ZonedDateTime endDate;

@Column(name = "enrollment_start_date")
@JsonView(QuizView.Before.class)
private ZonedDateTime enrollmentStartDate;

@Column(name = "enrollment_end_date")
@JsonView(QuizView.Before.class)
private ZonedDateTime enrollmentEndDate;

@Column(name = "unenrollment_end_date")
@JsonView(QuizView.Before.class)
private ZonedDateTime unenrollmentEndDate;

@Column(name = "semester")
@JsonView(QuizView.Before.class)
private String semester;

@Column(name = "test_course", nullable = false)
@JsonView({ QuizView.Before.class })
private boolean testCourse = false;

@Enumerated(EnumType.STRING)
@Column(name = "language")
@JsonView(QuizView.Before.class)
private Language language;

@Enumerated(EnumType.STRING)
@Column(name = "default_programming_language")
@JsonView(QuizView.Before.class)
private ProgrammingLanguage defaultProgrammingLanguage;

@Column(name = "online_course")
@JsonView(QuizView.Before.class)
private Boolean onlineCourse = false;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
Expand All @@ -138,34 +119,27 @@ public class Course extends DomainObject {

@Enumerated(EnumType.ORDINAL)
@Column(name = "info_sharing_config", nullable = false)
@JsonView(QuizView.Before.class)
private CourseInformationSharingConfiguration courseInformationSharingConfiguration = CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING; // default value

@Column(name = "info_sharing_messaging_code_of_conduct")
private String courseInformationSharingMessagingCodeOfConduct;

@Column(name = "max_complaints", nullable = false)
@JsonView(QuizView.Before.class)
private Integer maxComplaints = 3; // default value

@Column(name = "max_team_complaints", nullable = false)
@JsonView(QuizView.Before.class)
private Integer maxTeamComplaints = 3; // default value

@Column(name = "max_complaint_time_days", nullable = false)
@JsonView(QuizView.Before.class)
private int maxComplaintTimeDays = 7; // default value

@Column(name = "max_request_more_feedback_time_days", nullable = false)
@JsonView(QuizView.Before.class)
private int maxRequestMoreFeedbackTimeDays = 7; // default value

@Column(name = "max_complaint_text_limit")
@JsonView(QuizView.Before.class)
private int maxComplaintTextLimit = DEFAULT_COMPLAINT_TEXT_LIMIT;

@Column(name = "max_complaint_response_text_limit")
@JsonView(QuizView.Before.class)
private int maxComplaintResponseTextLimit = DEFAULT_COMPLAINT_TEXT_LIMIT;

@OneToMany(mappedBy = "course", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
Expand Down Expand Up @@ -201,7 +175,6 @@ public class Course extends DomainObject {
private Integer maxPoints;

@Column(name = "accuracy_of_scores", nullable = false)
@JsonView(QuizView.Before.class)
private Integer accuracyOfScores = 1; // default value

@Column(name = "restricted_athena_modules_access", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
import jakarta.persistence.MappedSuperclass;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonView;

import de.tum.cit.aet.artemis.quiz.config.QuizView;

/**
* Base abstract class for entities which have an id that is generated automatically (basically all domain objects).
Expand All @@ -28,7 +25,6 @@ public abstract class DomainObject implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonView(QuizView.Before.class)
private Long id;

public Long getId() {
Expand Down
Copy link
Member

Choose a reason for hiding this comment

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

This file is specific to quiz exercises and should therefore be within the quiz module

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.tum.cit.aet.artemis.core.dto;

import java.time.ZonedDateTime;

import com.fasterxml.jackson.annotation.JsonInclude;

import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration;
import de.tum.cit.aet.artemis.core.domain.Language;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
// TODO: we should reduce the amount of information here, not all fields are needed for the quiz exercise
public record CourseForQuizExerciseDTO(Long id, String title, String description, String shortName, String studentGroupName, String teachingAssistantGroupName,
String editorGroupName, String instructorGroupName, ZonedDateTime startDate, ZonedDateTime endDate, ZonedDateTime enrollmentStartDate, ZonedDateTime enrollmentEndDate,
ZonedDateTime unenrollmentEndDate, String semester, boolean testCourse, Language language, ProgrammingLanguage defaultProgrammingLanguage, Boolean onlineCourse,
CourseInformationSharingConfiguration courseInformationSharingConfiguration, Integer maxComplaints, Integer maxTeamComplaints, int maxComplaintTimeDays,
int maxRequestMoreFeedbackTimeDays, int maxComplaintTextLimit, int maxComplaintResponseTextLimit, Integer accuracyOfScores) {

/**
* Create a CourseForQuizExerciseDTO from a Course
*
* @param course the course to convert
* @return the converted CourseForQuizExerciseDTO
*/
public static CourseForQuizExerciseDTO of(final Course course) {
return new CourseForQuizExerciseDTO(course.getId(), course.getTitle(), course.getDescription(), course.getShortName(), course.getStudentGroupName(),
course.getTeachingAssistantGroupName(), course.getEditorGroupName(), course.getInstructorGroupName(), course.getStartDate(), course.getEndDate(),
course.getEnrollmentStartDate(), course.getEnrollmentEndDate(), course.getUnenrollmentEndDate(), course.getSemester(), course.isTestCourse(), course.getLanguage(),
course.getDefaultProgrammingLanguage(), course.isOnlineCourse(), course.getCourseInformationSharingConfiguration(), course.getMaxComplaints(),
course.getMaxTeamComplaints(), course.getMaxComplaintTimeDays(), course.getMaxRequestMoreFeedbackTimeDays(), course.getMaxComplaintTextLimit(),
course.getMaxComplaintResponseTextLimit(), course.getAccuracyOfScores());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.tum.cit.aet.artemis.core.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import de.tum.cit.aet.artemis.core.domain.DomainObject;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record DomainObjectDTO(Long id) {

public static DomainObjectDTO of(DomainObject domainObject) {
return new DomainObjectDTO(domainObject.getId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@
import jakarta.persistence.MappedSuperclass;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView;

import de.tum.cit.aet.artemis.assessment.domain.AssessmentType;
import de.tum.cit.aet.artemis.core.domain.DomainObject;
import de.tum.cit.aet.artemis.core.util.StringUtil;
import de.tum.cit.aet.artemis.quiz.config.QuizView;

@MappedSuperclass
public abstract class BaseExercise extends DomainObject {

@Column(name = "title")
@JsonView(QuizView.Before.class)
private String title;

@Column(name = "short_name")
@JsonView(QuizView.Before.class)
private String shortName;

@Column(name = "max_points", nullable = false)
Expand All @@ -38,23 +34,19 @@ public abstract class BaseExercise extends DomainObject {
private AssessmentType assessmentType;

@Column(name = "release_date")
@JsonView(QuizView.Before.class)
@Nullable
private ZonedDateTime releaseDate;

// TODO: Also use for quiz exercises
@Column(name = "start_date")
@JsonView(QuizView.Before.class)
@Nullable
private ZonedDateTime startDate;

@Column(name = "due_date")
@JsonView(QuizView.Before.class)
@Nullable
private ZonedDateTime dueDate;

@Column(name = "assessment_due_date")
@JsonView(QuizView.Before.class)
@Nullable
private ZonedDateTime assessmentDueDate;

Expand All @@ -64,7 +56,6 @@ public abstract class BaseExercise extends DomainObject {

@Enumerated(EnumType.STRING)
@Column(name = "difficulty")
@JsonView(QuizView.Before.class)
private DifficultyLevel difficulty;

@Enumerated(EnumType.STRING)
Expand Down Expand Up @@ -189,7 +180,6 @@ public void setExampleSolutionPublicationDate(@Nullable ZonedDateTime exampleSol
*
* @return true, if students are allowed to see this exercise, otherwise false
*/
@JsonView(QuizView.Before.class)
public boolean isVisibleToStudents() {
if (isExamExercise()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonView;

import de.tum.cit.aet.artemis.assessment.domain.AssessmentType;
import de.tum.cit.aet.artemis.assessment.domain.ExampleSubmission;
Expand All @@ -66,7 +66,6 @@
import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase;
import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismDetectionConfig;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise;
import de.tum.cit.aet.artemis.quiz.config.QuizView;
import de.tum.cit.aet.artemis.quiz.domain.QuizExercise;
import de.tum.cit.aet.artemis.text.domain.TextExercise;

Expand Down Expand Up @@ -112,13 +111,11 @@ public abstract class Exercise extends BaseExercise implements LearningObject {

@OneToMany(mappedBy = "exercise", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnoreProperties("exercise")
@JsonView(QuizView.Before.class)
private Set<CompetencyExerciseLink> competencyLinks = new HashSet<>();

@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "exercise_categories", joinColumns = @JoinColumn(name = "exercise_id"))
@Column(name = "categories")
@JsonView(QuizView.Before.class)
private Set<String> categories = new HashSet<>();

@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
Expand All @@ -143,11 +140,9 @@ public abstract class Exercise extends BaseExercise implements LearningObject {
private String feedbackSuggestionModule;

@ManyToOne
@JsonView(QuizView.Before.class)
private Course course;

@ManyToOne
@JsonView(QuizView.Before.class)
private ExerciseGroup exerciseGroup;

@OneToMany(mappedBy = "exercise", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
Expand Down Expand Up @@ -338,7 +333,7 @@ public void setTestRunParticipationsExist(Boolean testRunParticipationsExistTran
*
* @return the course class member
*/
@JsonInclude
@JsonProperty
protected Course getCourse() {
return course;
}
Expand Down
Loading
Loading