/// <summary> /// 批阅试题 记录积分 并返回分数 /// </summary> /// <param name="option"></param> /// <returns></returns> public int CheckAnswer(List <SubmitAnswerDetail> options, string user_identify, out int core) { List <Bane_QuestionInfo> info = DBSession.IBane_QuestionInfoDAL.GetAnswerByOptions(options); //1. 历史答题详细记录 List <Bane_HistoryScoreDetial> scoreDetial = new List <Bane_HistoryScoreDetial>(); int count_num = 0; foreach (var item in options) { var query = info.Where(s => s.sub_id == item.sub_id).FirstOrDefault(); if (item.score_option.ToLower() == query.sub_value.ToLower()) { count_num += query.sub_score; } scoreDetial.Add(new Bane_HistoryScoreDetial { hs_id = 0, sub_id = item.sub_id, hd_value = item.score_option, sub_value = query.sub_value }); } //2. 判断用户分数>90 是否获得积分,一周内只能第一次获得积分 string hs_title = "答题获得积分"; int mark = HCQ2UI_Helper.OperateContext.Current.bllSession.Bane_HistoryScore.GetAnswerNums(user_identify), jifen = 1; if (mark > 0 || count_num < 90) { hs_title = ""; jifen = 0; } core = jifen; //3. 添加 历史答题分数记录 Bane_HistoryScore hScore = new Bane_HistoryScore { user_identify = user_identify, hs_time = DateTime.Now, hs_score = count_num, hs_title = hs_title, hs_total = jifen }; DBSession.IBane_HistoryScoreDAL.Add(hScore); //4. 添加 历史答题详细记录 foreach (var item in scoreDetial) { item.hs_id = hScore.hs_id; DBSession.IBane_HistoryScoreDetialDAL.Add(item); } //5. 是否记录积分库 if (jifen > 0) { DBSession.IBane_IntegralScoreDetialDAL.Add(new Bane_IntegralScoreDetial { user_identify = user_identify, his_title = hs_title, his_time = DateTime.Now, his_total = jifen }); } return(count_num);//分数 }
/// <summary> /// 根据答题历史记录ID 获取详细的答题记录 /// </summary> /// <param name="answer_id"></param> /// <returns></returns> public AnswerResultModel GetAnswerHistoryDetial(int answer_id) { AnswerResultModel model = new AnswerResultModel(); //1. 历史答题分数记录 Bane_HistoryScore hscore = Select(s => s.hs_id == answer_id).FirstOrDefault(); if (hscore == null) { return(null); } model.answer_date = hscore.hs_time.ToString("D"); model.answer_score = hscore.hs_score; model.answer_total = hscore.hs_total; //2. 历史答题详细记录 List <Bane_HistoryScoreDetial> sDetial = DBSession.IBane_HistoryScoreDetialDAL.Select(s => s.hs_id == answer_id); List <int> sub_ids = sDetial.Select(s => s.sub_id).ToList(); //3. 试题库 List <Bane_QuestionInfo> qInfo = DBSession.IBane_QuestionInfoDAL.GetAnswerByOptions(sub_ids); //4. 选项库 List <HCQ2_Model.Bane_QuestionValue> qValue = DBSession.IBane_QuestionValueDAL.GetOptionsById(sub_ids); List <AnswerResultDetial> issue = new List <AnswerResultDetial>(); foreach (var item in qInfo) { //4.1 选择项 List <HCQ2_Model.BaneUser.APP.Result.Bane_QuestionValue> option = new List <HCQ2_Model.BaneUser.APP.Result.Bane_QuestionValue>(); var valueTemp = qValue.Where(s => s.sub_id == item.sub_id).ToList(); foreach (var obj in valueTemp) { option.Add(new HCQ2_Model.BaneUser.APP.Result.Bane_QuestionValue { score_option = obj.score_option, score_value = obj.score_value }); } //4.2 试题 var query = sDetial.Where(s => s.sub_id == item.sub_id).FirstOrDefault(); issue.Add(new AnswerResultDetial { issue_title = item.sub_title, correct_option = query.sub_value, user_option = query.hd_value, option = option }); } model.issue = issue; return(model); }