public string GetSummary(ExamProcessContext processContext, ExamInfo examInfo) { int currentIndex = processContext.index; int correctNumber = 0; int totalNumber = 0; int totalScore = 0; int userScore = 0; string error = ""; for (int i = 0; i < currentIndex; i++) { string userAnswer = processContext.collectedUserAnswer[i]; string correctAnswer = examInfo.items[i].answer; int score = examInfo.items[i].score; if (userAnswer.Trim().ToLower() == correctAnswer.Trim().ToLower()) { correctNumber++; userScore += score; } else { string[] tmps = correctAnswer.Trim().ToLower().Split(';'); if (tmps.Length > 1) { Array.Sort(tmps); string correctMultipleAnswer = string.Join("", tmps); tmps = userAnswer.Trim().ToLower().Split(' '); Array.Sort(tmps); string userMultipleAnswer = string.Join("", tmps); if (userMultipleAnswer == correctMultipleAnswer) { correctNumber++; userScore += score; break; } } error += this.info.SingleItemTemplate.Replace("${QUESTION}", examInfo.items[i].question).Replace("${USER_ANSWER}", userAnswer).Replace("${CORRECT_ANSWER}", correctAnswer); //"Questions: " + examInfo.items[i].question + ". Answers: " + userAnswer + ". [X] " + "Correct answers " + correctAnswer + "\r\n"; } totalNumber++; totalScore += score; } string result = this.info.SummeryTemplate.Replace("${TOTAL_NUMBER}", totalNumber.ToString()).Replace("${CORRECT_NUMBER}", correctNumber.ToString()).Replace("${USER_SCORE}", userScore.ToString()).Replace("${TOTAL_SCORE}", totalScore.ToString()); //"Totally " + totalNumber.ToString() + " questions, and " + correctNumber.ToString() + "correct answers, scores(" + userScore.ToString() + "/" + totalScore.ToString() + ").\r\n"; if (examInfo.dispType == ExamItemAnswerDisplayType.AllInSummary) { result += error; } return(result); }
public string GetSummary(ExamProcessContext processContext, ExamInfo examInfo) { string reviewContext = Utils.Utils.ReadEmbeddedResourceFile("Education.Engine.Res.dicsreviews.json"); Dictionary <string, DICSReviewInfo> reviewDict = JsonConvert.DeserializeObject <Dictionary <string, DICSReviewInfo> >(reviewContext); Dictionary <string, int> examResults = new Dictionary <string, int>(); foreach (string key in reviewDict.Keys) { examResults.Add(key, 0); } int index = 0; foreach (string result in processContext.collectedUserAnswer) { Dictionary <string, string> answerDict = GetAnswerDict(examInfo.items[index].answer); if (answerDict != null) { string realResult = answerDict[result.Trim()]; examResults[realResult] += 1; } } int averageNum = examInfo.items.Count / examResults.Count; string resp = "你的答案是:"; string subResp = ""; int featureNum = 0; string featureStr = ""; foreach (string key in examResults.Keys) { int num = examResults[key]; resp += key + " " + num.ToString() + "; "; if (num > averageNum) { featureNum++; featureStr += key + ","; subResp += reviewDict[key].Name + "\r\n" + reviewDict[key].Description + "\r\n"; } } resp += "\r\n你的答案中有" + featureNum.ToString() + "项得分超过" + averageNum.ToString() + "。所以你具备" + featureNum.ToString() + "项特征: \r\n" + subResp; return(resp); }
public string GetSummary(ExamProcessContext context, ExamInfo examInfo) { if (string.IsNullOrWhiteSpace(examInfo.summerizerClassName)) { return(""); } string className = examInfo.summerizerClassName; Type type = Type.GetType(examInfo.summerizerClassName); Object obj = Activator.CreateInstance(type); MethodInfo methodInfo = type.GetMethod("GetSummary"); object[] parametersArray = new object[] { context, examInfo }; string respStr = (string)methodInfo.Invoke(obj, parametersArray); return(respStr); }