Implement exam scoring service
This commit is contained in:
1 parent
995e69e302
commit
d8ef029bef
1 file changed
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.example.questionbank.service.quiz;
|
||||||
|
|
||||||
|
import com.example.questionbank.domain.enumeration.OptionKey;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ExamScoringService {
|
||||||
|
|
||||||
|
public ScoringResult score(OptionKey correctOption, OptionKey selectedOption) {
|
||||||
|
boolean correct = selectedOption != null && selectedOption == correctOption;
|
||||||
|
return new ScoringResult(correct, correct ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ScoringResult(boolean correct, int awardedPoints) {}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user