public void TestGetIQTestStandardResults() { IComputingService target = new ComputingService(); IQTestPaperResult paperResult = new IQTestPaperResult(); paperResult.Age = 8; paperResult.QuestionAnswers = new IQTestPaperQuestionAnswer[] { new IQTestPaperQuestionAnswer { QuestionGroup = "A", QuestionCode = 2, Answer = "E" }, new IQTestPaperQuestionAnswer { QuestionGroup = "AB", QuestionCode = 4, Answer = "F" } }; var actual = target.GetIQTestStandardResults(new IQTestPaperResult[] { paperResult }); }
private IQTestStandardResult GetIQTestStandardResult(IQTestPaperResult paperResult, IQTestQuestionsSet questionsSet, IQTestStandardParametersSet standardParametersSet) { int originalValue = 0; foreach (var questionAnswer in paperResult.QuestionAnswers) { var question = questionsSet.Questions.Single(item => item.Group == questionAnswer.QuestionGroup && item.Code == questionAnswer.QuestionCode); if (question.CorrectChoice == questionAnswer.Answer) { originalValue += 1; } } IQTestStandardParameter standardParameter = standardParametersSet.Parameters.Where(item => originalValue >= item.OriginalScore).OrderByDescending(item => item.IQ).FirstOrDefault(); if (standardParameter == null) { standardParameter = standardParametersSet.Parameters.OrderBy(item => item.IQ).First(); } int IQ = standardParameter.IQ; IQLevel Level; if (IQ >= 130) { Level = IQLevel.EXCELLENT; } else if (IQ >= 120) { Level = IQLevel.GREAT; } else if (IQ >= 110) { Level = IQLevel.MEDIUM1; } else if (IQ >= 90) { Level = IQLevel.MEDIUM2; } else if (IQ >= 80) { Level = IQLevel.MEDIUM3; } else if (IQ >= 70) { Level = IQLevel.EDGE; } else if (IQ >= 55) { Level = IQLevel.BAD1; } else if (IQ >= 40) { Level = IQLevel.BAD2; } else if (IQ >= 25) { Level = IQLevel.BAD3; } else { Level = IQLevel.BAD4; } IQTestStandardResult standardResult = new IQTestStandardResult(); standardResult.OriginalValue = originalValue; standardResult.Value = IQ; standardResult.Level = Level; standardResult.RefId = paperResult.RefId; return(standardResult); }