public ItemizedQuizScore GetMaximumPossibleScorePerCategory()
    {
        // Create the score to return
        ItemizedQuizScore maxScore = new ItemizedQuizScore();
        // Get a list of all categories
        IEnumerable <QuizCategory> categories = GetTestedCategories();

        // Set the max score for each category
        foreach (QuizCategory category in categories)
        {
            maxScore.Set(category, GetMaximumPossibleScoreInCategory(category));
        }
        return(maxScore);
    }
Exemple #2
0
    public static ItemizedQuizScore ComputeItemizedScore(QuizRuntimeTemplate runtimeTemplate, int[] answers)
    {
        ItemizedQuizScore itemizedScore = new ItemizedQuizScore();

        for (int i = 0; i < runtimeTemplate.Questions.Length; i++)
        {
            // Get the current question and answer
            QuizQuestion question = runtimeTemplate.Questions[i];
            int          answer   = answers[i];

            // If the answer is within range of the options
            // then add the option's weight to the total score
            if (answer >= 0 && answer < question.Options.Length)
            {
                QuizOption option       = question.Options[answer];
                int        currentScore = itemizedScore.GetOrElse(question.Category, 0);
                itemizedScore.Set(question.Category, currentScore + option.Weight);
            }
        }

        return(itemizedScore);
    }