Skip to content

Commit

Permalink
add gradings in schema and entities
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlxs committed Oct 10, 2024
1 parent 39d9ef6 commit 85c16cc
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.unistuttgart.iste.meitrex.assignment_service.persistence.entity;

import jakarta.persistence.*;
import lombok.*;

import java.io.Serializable;
import java.util.List;
import java.util.UUID;

@Entity(name = "ExerciseGrading")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExerciseGradingEntity {

@EmbeddedId
private PrimaryKey primaryKey;

@Column(nullable = false)
private double achievedCredits;

@Column(nullable = false)
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parentExerciseGrading")
private List<SubexerciseGradingEntity> subexerciseGradings;

@ManyToOne
@EqualsAndHashCode.Exclude
@ToString.Exclude
private GradingEntity parentGrading;

@Data
@Embeddable
@NoArgsConstructor
@AllArgsConstructor
public static class PrimaryKey implements Serializable {
private UUID assessmentId;
private UUID userId;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package de.unistuttgart.iste.meitrex.assignment_service.persistence.entity;


import de.unistuttgart.iste.meitrex.generated.dto.ExerciseGrading;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.UUID;

@Entity(name = "Grading")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GradingEntity {

@EmbeddedId
private PrimaryKey primaryKey;

@Column(nullable = false)
private OffsetDateTime date;

@Column(nullable = false)
private double achievedCredits;

@Column(nullable = false)
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parentGrading")
private List<ExerciseGradingEntity> exerciseGradings;

@Data
@Embeddable
@NoArgsConstructor
@AllArgsConstructor
public static class PrimaryKey implements Serializable {
private UUID assessmentId;
private UUID userId;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package de.unistuttgart.iste.meitrex.assignment_service.persistence.entity;

import jakarta.persistence.*;
import lombok.*;

import java.io.Serializable;
import java.util.UUID;

@Entity(name = "SubexerciseGrading")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SubexerciseGradingEntity {

@EmbeddedId
private PrimaryKey primaryKey;

@Column(nullable = false)
private double achievedCredits;

@ManyToOne
@EqualsAndHashCode.Exclude
@ToString.Exclude
private GradingEntity parentExerciseGrading;

@Data
@Embeddable
@NoArgsConstructor
@AllArgsConstructor
public static class PrimaryKey implements Serializable {
private UUID assessmentId;
private UUID userId;

}
}
68 changes: 68 additions & 0 deletions src/main/resources/graphql/service/grading.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
A grading contains a user's achieved credits on an assignment and its exercises and subexercises.
"""
type Grading {
"""
ID of the assignment.
"""
assessmentId: UUID!

"""
ID of the user the grading belongs to.
"""
userId: UUID!

"""
The date and time of when the tutor corrected the assignment.
"""
date: DateTime!

"""
The absolute number of achieved credits on the assignment.
"""
achievedCredits: Float!

"""
List of exercise-gradings for each exercise in the assignment. Can be empty, if there are no exercises within the assignment.
"""
exerciseGradings: [ExerciseGrading]!
}

type ExerciseGrading {
"""
ID of the exercise.
"""
itemId: UUID!

"""
ID of the user the exercise-grading belongs to.
"""
userId: UUID!

"""
The absolute number of achieved credits on the exercise.
"""
achievedCredits: Float!

"""
List of subexercise-gradings for each subexercise in the exercise. Can be empty, if there are no subexercises within the exercise.
"""
subexerciseGradings: [SubexerciseGrading]!
}

type SubexerciseGrading {
"""
ID of the subexercise.
"""
itemId: UUID!

"""
ID of the user the subexercise-grading belongs to.
"""
userId: UUID!

"""
The absolute number of achieved credits on the subexercise.
"""
achievedCredits: Float!
}
8 changes: 8 additions & 0 deletions src/main/resources/graphql/service/query.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ type Query {
an assignment if the user has no access to it.
"""
findAssignmentsByAssessmentIds(assessmentIds: [UUID!]!): [Assignment]!


"""
Get a grading for one assignment for one student
🔒 The user must be enrolled in the course the assignment belong to to access them. Otherwise null is returned for
an assignment if the user has no access to it.
"""
getGradingForAssignmentForStudent(assessmentId: UUID!, userId: UUID!): Grading!
}

0 comments on commit 85c16cc

Please sign in to comment.