예제 #1
0
    public static int ComputeScoreInImportantCategories(QuizRuntimeTemplate runtimeTemplate, int[] answers)
    {
        // Get the score itemized by category
        ItemizedQuizScore itemizedScore = ComputeItemizedScore(runtimeTemplate, answers);
        int score = 0;

        // Add up the scores in the important categories
        foreach (QuizCategory category in runtimeTemplate.Template.ImportantCategories)
        {
            score += itemizedScore.GetOrElse(category, 0);
        }
        return(score);
    }
예제 #2
0
    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);
    }
예제 #3
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);
    }