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

Even More Intelligrade Stuff #112

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>edu.kit.kastel.sdq</groupId>
<artifactId>artemis4j</artifactId>
<version>7.4.2-SNAPSHOT</version>
<version>7.5.0-SNAPSHOT</version>

<name>Artemis4J</name>
<description>Artemis4J is a Java library for interacting with the Artemis teaching system.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public T get() throws ArtemisNetworkException {
// Second synchronized check to avoid double initialization
if (this.value == null) {
this.value = this.supplier.get();
localValue = this.value;
}
localValue = this.value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public final class Annotation {
private final String filePath;
private final int startLine;
private final int endLine;
private final String customMessage;
private final Double customScore;
private final AnnotationSource source;
private String customMessage;
private Double customScore;

/**
* Deserializes an annotation from its metajson format
Expand All @@ -34,9 +34,9 @@ public Annotation(AnnotationDTO dto, MistakeType mistakeType) {
this.filePath = dto.classFilePath();
this.startLine = dto.startLine();
this.endLine = dto.endLine();
this.source = dto.source() != null ? dto.source() : AnnotationSource.UNKNOWN;
this.customMessage = dto.customMessageForJSON();
this.customScore = dto.customPenaltyForJSON();
this.source = dto.source() != null ? dto.source() : AnnotationSource.UNKNOWN;
}

Annotation(
Expand Down Expand Up @@ -126,6 +126,14 @@ public Optional<String> getCustomMessage() {
return Optional.ofNullable(customMessage);
}

public void setCustomMessage(String message) {
if (this.type.isCustomAnnotation() && message == null) {
throw new IllegalArgumentException("A custom message is required for custom annotation types.");
}

this.customMessage = message;
}

/**
* The custom score associated with this message, if any. Is always empty for
* predefined annotations, and never empty for custom annotations.
Expand All @@ -134,6 +142,17 @@ public Optional<Double> getCustomScore() {
return Optional.ofNullable(customScore);
}

public void setCustomScore(Double score) {
if (!this.type.isCustomAnnotation() && score != null) {
throw new IllegalArgumentException("A custom score is not allowed for non-custom annotation types.");
}
if (this.type.isCustomAnnotation() && score == null) {
throw new IllegalArgumentException("A custom score is required for custom annotation types.");
}

this.customScore = score;
}

public AnnotationSource getSource() {
return source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public Points calculatePoints(List<Annotation> annotations) {
}
return new Points(0.0, false);
}

public int getThreshold() {
return threshold;
}
}
Loading