private string GetQuestionEntityForJson(int questionId) { StringBuilder sbText = new StringBuilder("{"); ExamQuestion examQuestion = ExamQuestionRepository.GetExamQuestionByQuestionId(questionId); if (examQuestion != null) { sbText.AppendFormat("\"questionid\":{0},", examQuestion.QuestionID); sbText.AppendFormat("\"clickcount\":{0},", examQuestion.ClickCount); sbText.AppendFormat("\"questiontype\":{0},", (int)examQuestion.QuestionType); sbText.Append("\"questionphoto\":\""); Utils.SerializeString(examQuestion.QuestionPhoto, sbText); sbText.Append("\","); sbText.Append("\"questionremark\":\""); if (string.IsNullOrEmpty(examQuestion.QuestionRemark)) { Utils.SerializeString("Sorry!该题暂时没有说明!<br />我们会尽快对该题说明补充完整。", sbText); } else { Utils.SerializeString(examQuestion.QuestionRemark, sbText); } sbText.Append("\","); sbText.Append("\"rightanswerstring\":\""); Utils.SerializeString(examQuestion.RightAnswerString, sbText); sbText.Append("\","); sbText.AppendFormat("\"wrongcount\":{0},", examQuestion.WrongCount); if (examQuestion.QuestionType == QuestionType.Judgmeng) { sbText.Append("\"questionname\":\""); Utils.SerializeString(examQuestion.QuestionName, sbText); sbText.Append("\""); } if (examQuestion.QuestionType == QuestionType.Choice) { sbText.Append("\"questionname\":\""); Utils.SerializeString(examQuestion.QuestionName, sbText); sbText.Append("\u003C\u0062\u0072\u0020\u002F\u003E"); IList <ExamAnswer> examAnswerList = examQuestion.AnswerList; foreach (ExamAnswer item in examAnswerList) { Utils.SerializeString(item.AnswerName, sbText); sbText.Append("\u003C\u0062\u0072\u0020\u002F\u003E"); } sbText.Append("\""); } } else { sbText.Append(ErrorJson); //没有问题,返回错误,代码为-1 } sbText.Append("}"); return(sbText.ToString()); }
//模拟考试 public string Mnks(int driverId, int provinceId) { StringBuilder sbText = new StringBuilder("{"); IList <ExamQuestion> examQuestionList = ExamQuestionRepository.GetExamQuestionListForMnks(driverId, provinceId); int _questionCount = examQuestionList.Count; sbText.AppendFormat("\"examquestioncount\":{0},", _questionCount); sbText.AppendFormat("\"examquestions\":["); int _step = 0; foreach (ExamQuestion item in examQuestionList) { _step++; sbText.Append(GetQuestionEntityForJson(item.QuestionID)); if (_step != _questionCount) { sbText.Append(","); } } sbText.Append("]"); sbText.Append("}"); return(sbText.ToString()); }
//强化练习 public string Qhlx(int totalCount, int exerciseType) { IList <ExamQuestion> examQuestionList = ExamQuestionRepository.GetExamQuestionListForQhlx(totalCount, exerciseType); return(GetQuestionListForJson(examQuestionList)); }
//随机练习 public string Sjlx(int driverId, string categories) { IList <ExamQuestion> examQuestionList = ExamQuestionRepository.GetExamQuestionListForSjlx(driverId, categories, QuestionType.All); return(GetQuestionListForJson(examQuestionList)); }
public void UpdateExamQuestionErrorCount(int questionId) { ExamQuestionRepository.UpdateExamQuestionErrorCount(questionId); }