Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Feuermagier committed Jul 16, 2024
1 parent 35ec8b0 commit a47d93f
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public static FeedbackDTO newInvisibleManualUnreferenced(double credits, String
public static String fetchLongFeedback(ArtemisClient client, long resultId, long feedbackId) throws ArtemisNetworkException {
return ArtemisRequest.get().path(List.of("results", resultId, "feedbacks", feedbackId, "long-feedback")).executeAndDecode(client, String.class);
}

public FeedbackDTO(String detailText, FeedbackDTO other) {
this(other.type(), other.id(), other.credits(), other.positive(), other.visibility(),
other.text(), other.reference(), detailText, other.hasLongFeedbackText(), other.testCase());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.kit.kastel.sdq.artemis4j.ArtemisNetworkException;

public record ProgrammingExerciseDTO(@JsonProperty long id, @JsonProperty String title, @JsonProperty String shortName, @JsonProperty String testRepositoryUri,
@JsonProperty Boolean secondCorrectionEnabled, @JsonProperty String exerciseType, @JsonProperty String assessmentType, @JsonProperty double maxPoints,
@JsonProperty ZonedDateTime dueDate, @JsonProperty ZonedDateTime startDate) {
public record ProgrammingExerciseDTO(@JsonProperty long id, @JsonProperty String title, @JsonProperty String shortName,
@JsonProperty String testRepositoryUri,
@JsonProperty Boolean secondCorrectionEnabled, @JsonProperty String exerciseType,
@JsonProperty String assessmentType, @JsonProperty double maxPoints,
@JsonProperty ZonedDateTime dueDate, @JsonProperty ZonedDateTime startDate) {

public static List<ProgrammingExerciseDTO> fetchAll(ArtemisClient client, int courseId) throws ArtemisNetworkException {
var exercises = ArtemisRequest.get().path(List.of("courses", courseId, "with-exercises")).executeAndDecode(client, ExerciseWrapperDTO.class);
// Remove all non-programming exercises
return Arrays.stream(exercises.exercises()).filter(e -> e.exerciseType().equals("PROGRAMMING")).toList();
}
public static List<ProgrammingExerciseDTO> fetchAll(ArtemisClient client, int courseId) throws ArtemisNetworkException {
var exercises = ArtemisRequest.get().path(List.of("courses", courseId, "with-exercises")).executeAndDecode(client, ExerciseWrapperDTO.class);
// Remove all non-programming exercises
return Arrays.stream(exercises.exercises()).filter(e -> e.exerciseType().equals("PROGRAMMING")).toList();
}

private record ExerciseWrapperDTO(ProgrammingExerciseDTO[] exercises) {
}
/**
* Artemis doesn't return the list of exercises directly, but only the list a specific course with the exercises attached.
* We don't care about the course here, so this wrapper class exists.
*
* @param exercises
*/
private record ExerciseWrapperDTO(ProgrammingExerciseDTO[] exercises) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ private ProgrammingSubmissionDTO fetchLongFeedback(ArtemisClient client) throws
if (feedback.hasLongFeedbackText()) {
detailText = FeedbackDTO.fetchLongFeedback(client, result.id(), feedback.id());
}
FeedbackDTO newFeedback = new FeedbackDTO(feedback.type(), feedback.id(), feedback.credits(), feedback.positive(), feedback.visibility(),
feedback.text(), feedback.reference(), detailText, feedback.hasLongFeedbackText(), feedback.testCase());
cleanedFeedbacks.add(newFeedback);
cleanedFeedbacks.add(new FeedbackDTO(detailText, feedback));
}

ResultDTO newResult = new ResultDTO(result.id(), result.completionDate(), result.successful(), result.score(), result.rated(), cleanedFeedbacks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Annotation(AnnotationDTO dto, MistakeType mistakeType) {
this.source = dto.source() != null ? dto.source() : AnnotationSource.UNKNOWN;
}

/* package-private */ Annotation(MistakeType mistakeType, String filePath, int startLine, int endLine, String customMessage, Double customScore,
Annotation(MistakeType mistakeType, String filePath, int startLine, int endLine, String customMessage, Double customScore,
AnnotationSource source) {
// Validate custom penalty and message
if (mistakeType.isCustomAnnotation()) {
Expand All @@ -45,10 +45,8 @@ public Annotation(AnnotationDTO dto, MistakeType mistakeType) {
if (customMessage == null) {
throw new IllegalArgumentException("A custom message is required for custom annotation types.");
}
} else {
if (customScore != null) {
throw new IllegalArgumentException("A custom penalty is not allowed for non-custom annotation types.");
}
} else if (customScore != null) {
throw new IllegalArgumentException("A custom penalty is not allowed for non-custom annotation types.");
}

this.uuid = generateUUID();
Expand All @@ -61,7 +59,7 @@ public Annotation(AnnotationDTO dto, MistakeType mistakeType) {
this.source = source;
}

public String getUuid() {
public String getUUID() {
return uuid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ClonedProgrammingSubmission implements AutoCloseable {
private final Path testsPath;
private final Path submissionPath;

/* package-private */ static ClonedProgrammingSubmission cloneSubmission(ProgrammingSubmission submission, Path target, String tokenOverride)
static ClonedProgrammingSubmission cloneSubmission(ProgrammingSubmission submission, Path target, String tokenOverride)
throws ArtemisClientException {
var connection = submission.getConnection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import edu.kit.kastel.sdq.artemis4j.i18n.FormatString;
import edu.kit.kastel.sdq.artemis4j.i18n.TranslatableString;

/* package-private*/ final class FeedbackSplitter {
final class FeedbackSplitter {
private static final String LINE_SEPARATOR = "\n";
private static final int SAFETY_MARGIN = 50;
private static final FormatString HEADER_FEEDBACK_ID = new FormatString(new MessageFormat(" (feedback {0,number}/{1,number})"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private Stream<MistakeType> streamMistakeTypes() {
return ratingGroups.stream().map(RatingGroup::getMistakeTypes).flatMap(List::stream);
}

/* package-private */ record GradingConfigDTO(String shortName, @JsonProperty(defaultValue = "true") boolean positiveFeedbackAllowed,
record GradingConfigDTO(String shortName, @JsonProperty(defaultValue = "true") boolean positiveFeedbackAllowed,
List<Long> allowedExercises, List<RatingGroup.RatingGroupDTO> ratingGroups, List<MistakeType.MistakeTypeDTO> mistakeTypes) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public int hashCode() {
return Objects.hashCode(id);
}

/* package-private */ record MistakeTypeDTO(String shortName, String message, String button, PenaltyRule penaltyRule, String appliesTo,
record MistakeTypeDTO(String shortName, String message, String button, PenaltyRule penaltyRule, String appliesTo,
String enabledForExercises, String enabledPenaltyForExercises, Map<String, String> additionalButtonTexts, Map<String, String> additionalMessages,
List<String> autograderProblemTypes) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public final class RatingGroup {
private final double maxPenalty;
private final List<MistakeType> mistakeTypes;

/* package-private */ RatingGroup(RatingGroupDTO dto) {
RatingGroup(RatingGroupDTO dto) {
double negativeLimit = dto.negativeLimit() != null ? dto.negativeLimit() : Double.NEGATIVE_INFINITY;
double positiveLimit = dto.positiveLimit() != null ? dto.positiveLimit() : Double.POSITIVE_INFINITY;

Expand Down Expand Up @@ -62,7 +62,7 @@ public boolean isScoringGroup() {
*
* @param mistakeType
*/
/* package-private */ void addMistakeType(MistakeType mistakeType) {
void addMistakeType(MistakeType mistakeType) {
this.mistakeTypes.add(mistakeType);
}

Expand All @@ -87,7 +87,7 @@ public String toString() {
+ ", " + "mistakeTypes=" + mistakeTypes + ']';
}

/* package-private */ record RatingGroupDTO(String shortName, String displayName, Double positiveLimit, Double negativeLimit,
record RatingGroupDTO(String shortName, String displayName, Double positiveLimit, Double negativeLimit,
Map<String, String> additionalDisplayNames) {
}
}

0 comments on commit a47d93f

Please sign in to comment.