-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decouple programmingsubmission & correction round
- Loading branch information
1 parent
b6e792f
commit 65ea569
Showing
6 changed files
with
212 additions
and
153 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
src/main/java/edu/kit/kastel/sdq/artemis4j/grading/PackedAssessment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package edu.kit.kastel.sdq.artemis4j.grading; | ||
|
||
import edu.kit.kastel.sdq.artemis4j.ArtemisNetworkException; | ||
import edu.kit.kastel.sdq.artemis4j.client.ProgrammingSubmissionDTO; | ||
import edu.kit.kastel.sdq.artemis4j.client.ResultDTO; | ||
import edu.kit.kastel.sdq.artemis4j.grading.metajson.AnnotationMappingException; | ||
import edu.kit.kastel.sdq.artemis4j.grading.penalty.GradingConfig; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* For API users, this is used in place of an assessment whenever we don't want to do | ||
* the (expensive) deserialization of the assessment. | ||
* The only semantic difference to an assessment is that this class does *not* imply a lock. | ||
* <p> | ||
* Internally, this is just a glorified ResultDTO wrapper because we need a place | ||
* to store the submission | ||
* @param result | ||
* @param submission | ||
*/ | ||
public record PackedAssessment(ResultDTO result, CorrectionRound round, ProgrammingSubmission submission) { | ||
public boolean isSubmitted() { | ||
return result.completionDate() != null; | ||
} | ||
|
||
public User getAssessor() { | ||
return new User(result.assessor()); | ||
} | ||
|
||
/** | ||
* Locks and opens the assessment for this submission. | ||
* <p> | ||
* If the submission has not been assessed by you, this might not be possible. | ||
* | ||
* @param config the config for the exercise | ||
* @return the assessment if there are results for this submission | ||
* @throws AnnotationMappingException If the annotations that were already | ||
* present could not be mapped given the | ||
* gradingConfig | ||
*/ | ||
public Optional<Assessment> open(GradingConfig config) throws MoreRecentSubmissionException, ArtemisNetworkException, AnnotationMappingException { | ||
return this.submission.getExercise().tryLockSubmission(this.submission.getId(), this.round, config); | ||
} | ||
|
||
/** | ||
* Opens the assessment for this submission without locking it. | ||
* <p> | ||
* If the submission has not been assessed by you, you might not be able to | ||
* change the assessment. | ||
* | ||
* @param config the config for the exercise | ||
* @return the assessment if there are results for this submission | ||
* @throws AnnotationMappingException If the annotations that were already | ||
* present could not be mapped given the | ||
* gradingConfig | ||
*/ | ||
public Assessment openWithoutLock(GradingConfig config) throws ArtemisNetworkException, AnnotationMappingException { | ||
return new Assessment(this.result, config, this.submission, this.round); | ||
} | ||
|
||
public void cancel() throws ArtemisNetworkException { | ||
ProgrammingSubmissionDTO.cancelAssessment(this.getConnection().getClient(), this.submission.getId()); | ||
} | ||
|
||
private ArtemisConnection getConnection() { | ||
return this.submission.getConnection(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.