Class QuizScoringService
java.lang.Object
fr.paris.lutece.plugins.wiki.modules.quiz.service.QuizScoringService
Service class responsible for scoring quiz questions and calculating results. Supports multiple question types including MCQ, True/False, Matching, and
Ordering.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInner class representing the result of scoring a quiz question. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalculatePercentageScore(int nEarnedPoints, int nTotalPoints) Calculates the percentage score from earned points and total points.static intcalculateTotalPoints(List<QuizQuestion> questions) Calculates the total possible points for a list of questions.scoreQuestion(QuizQuestion question, String strUserAnswer) Scores a quiz question based on the user's answer.
-
Method Details
-
scoreQuestion
public static QuizScoringService.ScoringResult scoreQuestion(QuizQuestion question, String strUserAnswer) Scores a quiz question based on the user's answer.- Parameters:
question- the quiz question to scorestrUserAnswer- the user's answer as a string- Returns:
- a ScoringResult containing whether the answer was correct and points earned
-
calculateTotalPoints
Calculates the total possible points for a list of questions.- Parameters:
questions- the list of quiz questions- Returns:
- the sum of all question points
-
calculatePercentageScore
public static int calculatePercentageScore(int nEarnedPoints, int nTotalPoints) Calculates the percentage score from earned points and total points.- Parameters:
nEarnedPoints- the number of points earnednTotalPoints- the total possible points- Returns:
- the percentage score (0-100), or 0 if total points is zero
-