Skip to content

Commit

Permalink
#467 Added perpetual support for KIS scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterl committed Jul 17, 2024
1 parent 08e1bdb commit 2e09cfa
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ class KisTaskScorer(
* @return A [Map] of [TeamId] to calculated task score.
*/
override fun calculateScores(submissions: Sequence<Submission>): Map<TeamId, Double> {
val taskDuration = this.scoreable.duration!!.toDouble() * 1000.0
val taskDuration = this.scoreable.duration?.toDouble()?.times(1000.0)
val taskStartTime = this.scoreable.started ?: throw IllegalArgumentException("No task start time specified.")
return this.scoreable.teams.associateWith { teamId ->
val verdicts = submissions.filter { it.teamId == teamId }.sortedBy { it.timestamp }.flatMap { sub ->
sub.answerSets().filter { (it.status() == VerdictStatus.CORRECT) or (it.status() == VerdictStatus.WRONG) }
}.toList()
val firstCorrect = verdicts.indexOfFirst { it.status() == VerdictStatus.CORRECT }
val score = if (firstCorrect > -1) {
val timeFraction = 1.0 - (verdicts[firstCorrect].submission.timestamp - taskStartTime) / taskDuration
val timeFraction = if(taskDuration == null){
1.0
}else{
1.0 - (verdicts[firstCorrect].submission.timestamp - taskStartTime) / taskDuration
}
max(
0.0,
this.maxPointsAtTaskEnd +
Expand Down

0 comments on commit 2e09cfa

Please sign in to comment.