예제 #1
0
        //Get tag wise result of the given quiz and save it in UserResult Table
        public void getTagWiseResult(UserQuizDetail quiz, List <TagWiseResult> tagWiseResult)
        {
            List <QuestionAttempted>    questions        = quiz.QuestionsAttempted;
            HashSet <string>            labels           = new HashSet <string>();
            Dictionary <string, int>    totalTagCount    = new Dictionary <string, int>();
            Dictionary <string, int>    correctTagCount  = new Dictionary <string, int>();
            Dictionary <int, int>       questionTagCount = new Dictionary <int, int>();
            Dictionary <string, double> tagRatingList    = new Dictionary <string, double>();

            foreach (var item in questions)
            {
                labels.UnionWith(new HashSet <string>(item.ConceptTags));
            }

            foreach (var item in labels)
            {
                totalTagCount.Add(item, 0);
                correctTagCount.Add(item, 0);
                tagRatingList.Add(item, 0);
                foreach (var question in questions)
                {
                    if (question.ConceptTags.Contains(item))
                    {
                        totalTagCount[item] += 1;
                        if (question.IsCorrect)
                        {
                            correctTagCount[item] += 1;
                            tagRatingList[item]   += 1 / (float)(question.ConceptTags.Length);
                        }
                    }
                }

                tagRatingList[item] /= totalTagCount[item];
                tagRatingList[item]  = Math.Round(tagRatingList[item], 2);

                double tagCorrectPercentage = ((double)correctTagCount[item] / (double)totalTagCount[item]) * 100;
                tagCorrectPercentage = Math.Round(tagCorrectPercentage, 2);

                TagWiseResult tag = new TagWiseResult();
                tag.TagName              = item;
                tag.TagTotalQuestCount   = totalTagCount[item];
                tag.TagCorrectAnsCount   = correctTagCount[item];
                tag.TagCorrectPercentage = tagCorrectPercentage;
                tag.TagRating            = tagRatingList[item];
                tagWiseResult.Add(tag);
            }
        }
        //Get tag wise result of the given quiz and save it in UserResult Table
        public void getTagWiseResult(UserQuizDetail quiz, List <TagWiseResult> tagWiseResult)
        {
            List <QuestionAttempted>    questions          = quiz.QuestionsAttempted;
            HashSet <string>            labels             = new HashSet <string>();
            Dictionary <string, int>    totalTagCount      = new Dictionary <string, int>();
            Dictionary <string, int>    correctTagCount    = new Dictionary <string, int>();
            Dictionary <int, int>       questionTagCount   = new Dictionary <int, int>();
            Dictionary <string, double> tagRatingList      = new Dictionary <string, double>();
            Dictionary <string, double> taxonomyTotalScore = new Dictionary <string, double>();
            Dictionary <string, double> totalDenCount      = new Dictionary <string, double>();
            Dictionary <string, int>    taxScoreNumber     = new Dictionary <string, int>();


            string[] taxonomyLevels = { "Remember", "Understand", "Apply", "Analyze", "Evaluate", "Create" };

            foreach (var item in questions)
            {
                labels.UnionWith(new HashSet <string>(item.ConceptTags));
            }

            foreach (var item in labels)
            {
                totalTagCount.Add(item, 0);
                correctTagCount.Add(item, 0);
                tagRatingList.Add(item, 0);
                taxonomyTotalScore.Add(item, 0);
                totalDenCount.Add(item, 0);

                foreach (var tax in taxonomyLevels)
                {
                    taxScoreNumber[tax + "-" + item] = 0;
                }



                foreach (var question in questions)
                {
                    if (question.ConceptTags.Contains(item))
                    {
                        totalTagCount[item] += 1;
                        totalDenCount[item] += question.DifficultyLevel / (float)(question.ConceptTags.Length);
                        if (question.IsCorrect)
                        {
                            correctTagCount[item] += 1;
                            tagRatingList[item]   += question.DifficultyLevel / (float)(question.ConceptTags.Length);
                            if (taxonomyTotalScore.ContainsKey(item))
                            {
                                taxonomyTotalScore[item] += Array.IndexOf(taxonomyLevels, question.Taxonomy) + 1;
                            }
                            else
                            {
                                taxonomyTotalScore.Add(item, Array.IndexOf(taxonomyLevels, question.Taxonomy) + 1);
                            }
                            taxScoreNumber[question.Taxonomy + "-" + item] += question.DifficultyLevel;
                            Console.WriteLine(taxScoreNumber[question.Taxonomy + "-" + item]);
                        }
                    }
                }



                tagRatingList[item] /= totalDenCount[item];
                tagRatingList[item]  = Math.Round(tagRatingList[item], 2);

                double tagCorrectPercentage = ((double)correctTagCount[item] / (double)totalTagCount[item]) * 100;
                tagCorrectPercentage = Math.Round(tagCorrectPercentage, 2);

                TagWiseResult tag = new TagWiseResult();
                tag.TagName              = item;
                tag.TagTotalQuestCount   = totalTagCount[item];
                tag.TagCorrectAnsCount   = correctTagCount[item];
                tag.TagCorrectPercentage = tagCorrectPercentage;
                tag.TagRating            = tagRatingList[item];
                tag.TaxonomyLevel        = getTaxonomyLevel(item, questions);
                tag.TaxonomyScore        = taxonomyTotalScore[item];

                List <TaxonomyListAndScore> taxonomyListAndScores = new List <TaxonomyListAndScore>();

                foreach (var tax in taxonomyLevels)
                {
                    TaxonomyListAndScore taxonomy = new TaxonomyListAndScore();
                    taxonomy.TaxonomyName        = tax;
                    taxonomy.TaxonomyScoreNumber = taxScoreNumber[tax + "-" + item];
                    taxonomyListAndScores.Add(taxonomy);
                }
                tag.TaxonomyListAndScores = taxonomyListAndScores;
                tagWiseResult.Add(tag);
            }
        }