Skip to content

Commit

Permalink
Some minor fixes (#139)
Browse files Browse the repository at this point in the history
* expose assessor for a submission

* fix crash when there are no exercises in a course

* fix crash in `GradingConfig#toString`

* apply spotless
  • Loading branch information
Luro02 authored Oct 28, 2024
1 parent 7f5f113 commit da9875e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ public static List<ProgrammingExerciseDTO> fetchAll(ArtemisClient client, int co
*
* @param exercises
*/
private record ExerciseWrapperDTO(List<ProgrammingExerciseDTO> exercises) {}
private record ExerciseWrapperDTO(List<ProgrammingExerciseDTO> exercises) {
private ExerciseWrapperDTO {
if (exercises == null) {
exercises = List.of();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ public static List<TextExerciseDTO> fetchAll(ArtemisClient client, int courseId)
* specific course with the exercises attached. We don't care about the course
* here, so this wrapper class exists.
*/
private record ExerciseWrapperDTO(List<TextExerciseDTO> exercises) {}
private record ExerciseWrapperDTO(List<TextExerciseDTO> exercises) {
private ExerciseWrapperDTO {
if (exercises == null) {
exercises = List.of();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ public Optional<ResultDTO> getLatestResult() {
}
}

/**
* Get the assessor of this assessment.
* <p>
* This is the user who has locked the submission.
*
* @return the assessor or empty if the submission has not been assessed
*/
public Optional<User> getAssessor() {
return this.getRelevantResult().map(ResultDTO::assessor).map(User::new);
}

/**
* Clones the submission, including the test repository, into the given path,
* and checks out the submitted commit. This method uses the user's VCS access token, potentially creating a new one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ public int hashCode() {
return Objects.hashCode(id);
}

@Override
public String toString() {
return "MistakeType{" + "id='"
+ id + '\'' + ", rule="
+ rule + ", ratingGroup="
+ ratingGroup + ", message="
+ message.getDefaultTranslationPattern() + ", buttonTexts="
+ buttonTexts.getDefaultTranslationPattern() + ", reporting="
+ reporting + ", autograderProblemTypes="
+ autograderProblemTypes + '}';
}

record MistakeTypeDTO(
String shortName,
String message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public int hashCode() {

@Override
public String toString() {
return "RatingGroup[" + "id=" + id + ", " + "displayName=" + displayName + ", " + "minPenalty=" + minPenalty
+ ", " + "getMaxPenalty=" + maxPenalty + ", " + "mistakeTypes=" + mistakeTypes + ']';
return "RatingGroup[" + "id=" + id + ", " + "displayName=" + displayName.getDefaultTranslationPattern() + ", "
+ "minPenalty=" + minPenalty + ", " + "getMaxPenalty=" + maxPenalty + ", " + "mistakeTypes="
+ mistakeTypes + ']';
}

record RatingGroupDTO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ String translateTo(Locale locale, Object... args) {
}
}

/**
* The default pattern used by the format string.
* @return the default pattern
*/
public String getDefaultTranslationPattern() {
return this.defaultTranslation.toPattern();
}

@Override
public String toString() {
throw new IllegalStateException("Format & translate this string before using it.");
Expand Down

0 comments on commit da9875e

Please sign in to comment.