Class QuizScoringService

java.lang.Object
fr.paris.lutece.plugins.wiki.modules.quiz.service.QuizScoringService

public final class QuizScoringService extends Object
Service class responsible for scoring quiz questions and calculating results. Supports multiple question types including MCQ, True/False, Matching, and Ordering.
  • 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 score
      strUserAnswer - the user's answer as a string
      Returns:
      a ScoringResult containing whether the answer was correct and points earned
    • calculateTotalPoints

      public static int calculateTotalPoints(List<QuizQuestion> questions)
      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 earned
      nTotalPoints - the total possible points
      Returns:
      the percentage score (0-100), or 0 if total points is zero