Skip to content

Commit

Permalink
add more info
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-christl committed Jun 2, 2024
1 parent 1e4f59d commit 76af83a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -10,23 +11,37 @@
import de.tum.in.www1.artemis.domain.ProgrammingSubmission;
import de.tum.in.www1.artemis.domain.Result;
import de.tum.in.www1.artemis.domain.Submission;
import de.tum.in.www1.artemis.domain.Team;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.domain.enumeration.AssessmentType;
import de.tum.in.www1.artemis.domain.enumeration.InitializationState;
import de.tum.in.www1.artemis.domain.enumeration.SubmissionType;
import de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation;
import de.tum.in.www1.artemis.domain.participation.StudentParticipation;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record ExerciseDetailStudentParticipationDTO(long id, InitializationState initializationState, ZonedDateTime initializationDate, ZonedDateTime individualDueDate,
boolean testRun, String type, Set<ResultDTO> results, Set<SubmissionDTO> submissions) {
boolean testRun, String type, Set<ResultDTO> results, Set<SubmissionDTO> submissions, UserDTO student, TeamDTO team,
// Unique to programming exercises
String repositoryUri) {

public static ExerciseDetailStudentParticipationDTO create(StudentParticipation studentParticipation) {
if (studentParticipation == null) {
return null;
}
Set<ResultDTO> resultsDTOs = studentParticipation.getResults().stream().map(ResultDTO::create).collect(Collectors.toSet());
Set<SubmissionDTO> submissionsDTOs = studentParticipation.getSubmissions().stream().map(SubmissionDTO::create).collect(Collectors.toSet());

if (studentParticipation instanceof ProgrammingExerciseStudentParticipation programmingParticipation) {
return new ExerciseDetailStudentParticipationDTO(studentParticipation.getId(), studentParticipation.getInitializationState(),
studentParticipation.getInitializationDate(), studentParticipation.getIndividualDueDate(), studentParticipation.isTestRun(), studentParticipation.getType(),
resultsDTOs, submissionsDTOs, UserDTO.create(studentParticipation.getStudent()), TeamDTO.create(studentParticipation.getTeam()),
programmingParticipation.getRepositoryUri());
}

return new ExerciseDetailStudentParticipationDTO(studentParticipation.getId(), studentParticipation.getInitializationState(), studentParticipation.getInitializationDate(),
studentParticipation.getIndividualDueDate(), studentParticipation.isTestRun(), studentParticipation.getType(), resultsDTOs, submissionsDTOs);
studentParticipation.getIndividualDueDate(), studentParticipation.isTestRun(), studentParticipation.getType(), resultsDTOs, submissionsDTOs,
UserDTO.create(studentParticipation.getStudent()), TeamDTO.create(studentParticipation.getTeam()), null);
}

private record ResultDTO(long id, ZonedDateTime completionDate, Boolean successful, Double score, Boolean rated, AssessmentType assessmentType, Boolean hasComplaint,
Expand Down Expand Up @@ -54,4 +69,29 @@ public static SubmissionDTO create(Submission submission) {
null);
}
}

private record UserDTO(long id) {

public static UserDTO create(Optional<User> user) {
return user.map(UserDTO::create).orElse(null);
}

public static UserDTO create(User user) {
if (user == null) {
return null;
}
return new UserDTO(user.getId());
}
}

private record TeamDTO(long id, Set<UserDTO> students) {

public static TeamDTO create(Optional<Team> team) {
if (team.isEmpty()) {
return null;
}
Set<UserDTO> students = team.get().getStudents().stream().map(UserDTO::create).collect(Collectors.toSet());
return new TeamDTO(team.get().getId(), students);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public record ExerciseDetailsDTO(long id, String title, String shortName, String

Long studentAssignedTeamId, boolean studentAssignedTeamIdComputed, CourseDTO course, Set<String> categories,
List<ExerciseDetailStudentParticipationDTO> studentParticipations,
// Special for quiz exercises
// Unique to quiz exercises
Set<QuizBatchDTO> quizBatches, Boolean quizStarted, Boolean quizEnded, Boolean isOpenForPractice, Integer allowedNumberOfAttempts, Integer duration, QuizMode quizMode,
// Special for programming exercises
// Unique to programming exercises
SubmissionPolicyDTO submissionPolicy, Boolean allowOnlineEditor, Boolean allowOfflineIde,
// Special for modeling exercises
// Unique to modeling exercises
DiagramType diagramType,
// Special for file upload exercises
// Unique to file upload exercises
String filePattern) {

public static ExerciseDetailsDTO create(@NotNull Exercise exercise, @NotNull List<StudentParticipation> studentParticipations) {
Expand Down Expand Up @@ -100,12 +100,14 @@ private static ExerciseDetailsDTO createDefault(Exercise exercise, List<StudentP
diagramType, filePattern);
}

private record CourseDTO(long id, CourseInformationSharingConfiguration courseInformationSharingConfiguration, Integer maxComplaints, Integer maxTeamComplaints,
int maxComplaintTimeDays, int maxRequestMoreFeedbackTimeDays, Integer presentationScore) {
private record CourseDTO(long id, boolean complaintsEnabled, boolean requestMoreFeedbackEnabled, CourseInformationSharingConfiguration courseInformationSharingConfiguration,
Integer maxComplaints, Integer maxTeamComplaints, Integer maxComplaintTextLimit, int maxComplaintTimeDays, int maxRequestMoreFeedbackTimeDays,
Integer presentationScore) {

public static CourseDTO create(Course course) {
return new CourseDTO(course.getId(), course.getCourseInformationSharingConfiguration(), course.getMaxComplaints(), course.getMaxTeamComplaints(),
course.getMaxComplaintTimeDays(), course.getMaxRequestMoreFeedbackTimeDays(), course.getPresentationScore());
return new CourseDTO(course.getId(), course.getComplaintsEnabled(), course.getRequestMoreFeedbackEnabled(), course.getCourseInformationSharingConfiguration(),
course.getMaxComplaints(), course.getMaxTeamComplaints(), course.getMaxComplaintTextLimit(), course.getMaxComplaintTimeDays(),
course.getMaxRequestMoreFeedbackTimeDays(), course.getPresentationScore());
}
}

Expand Down

0 comments on commit 76af83a

Please sign in to comment.