public ActionResult LearnOnLineEvaluateShowView(int ClassId, int UId) { var stbSqlWhere = new StringBuilder(); var stbSqlWhere_Question = new StringBuilder(); stbSqlWhere.AppendFormat(@" AnswerResult = {0}", UId); var AnswerBll = new Class_TraningCommentAnswerBLL(); var ResultBll = new Class_TraningCommentResultBLL(); var List_Class_TraningCommentAnswer = AnswerBll.GetListModel(stbSqlWhere.ToString()); var Model_Class_TraningCommentResult = ResultBll.GetModel(UId); #region [课程评价]题目信息 var List_Class_TraningCommentQuestion = new List<Class_TraningCommentQuestion>(); var TraningCommentBll = new Class_TraningCommentQuestionBLL(); stbSqlWhere_Question.Append(" Display = 1 AND Delflag = 0 AND Verson = " + Model_Class_TraningCommentResult.Verson);//根据版本号区分题目批次问题 List_Class_TraningCommentQuestion = TraningCommentBll.GetListModel(stbSqlWhere_Question.ToString()); ViewBag.List_Class_TraningCommentQuestion = List_Class_TraningCommentQuestion; #endregion ViewBag.Model_Class_TraningCommentResult = Model_Class_TraningCommentResult; ViewBag.List_Class_TraningCommentAnswer = List_Class_TraningCommentAnswer; return View(); }
/// <summary> /// 在线学习 - 课程评价 提交 /// </summary> /// <returns></returns> public ActionResult LearnOnLineEvaluateEdit(List<Class_TraningCommentAnswerOther> listOther) { string strVerson = string.Empty; int iClassId = 0, iAccountId = 0, iResultId = 0, iTrainingId = 0; double dblScoreTotal = 0; iAccountId = Code.SiteCache.Instance.LoginInfo.UserId; //将用户的[课程评价]答案保存 var CommentAnswerBll = new Class_TraningCommentAnswerBLL(); //获取[课程评价]总得分 foreach (var item in listOther) { if (!string.IsNullOrEmpty(item.Credits)) { double dblCre = 0; var strArr = item.Credits.Split(','); for (int i = 0; i < strArr.Length; i++) { var strItem = strArr[i]; double.TryParse(strItem, out dblCre); dblScoreTotal += dblCre;//获取所有题目的答案的总得分 } strVerson = item.Verson;//题目版本号,一批题目的版本号都一样 } iClassId = item.ClassId; iTrainingId = item.TrainingId; } //若课程已结束禁止操作 if (this.GetCourseIsOver(iClassId, iTrainingId, iAccountId)) return Json(new { Result = true, Msg = "提交失败.当前课程已结束,不能执行该操作!" }, JsonRequestBehavior.AllowGet); var ResultModel = new Class_TraningCommentResult(); ResultModel.AccountId = iAccountId; ResultModel.ClassId = iClassId; ResultModel.Score = int.Parse(dblScoreTotal.ToString());//fusygoto 是否应该是double ResultModel.Verson = strVerson; ResultModel.Delflag = false; ResultModel.CreateDate = DateTime.Now; //将数据插入到总分表 bool bolRes = this.InsertClass_TraningCommentResult(ResultModel, out iResultId); if (bolRes) { foreach (var itemQues in listOther) { double dblScoreQues = 0;//答案的分值 if (!string.IsNullOrEmpty(itemQues.Credits)) { var strArr = itemQues.Credits.Split(','); for (int i = 0; i < strArr.Length; i++) { double dblCre = 0; var strItem = strArr[i]; double.TryParse(strItem, out dblCre); dblScoreQues += dblCre;//获取这道题答案的分数 } } //将用户的[课程评价]答案保存 Class_TraningCommentAnswer Model_CommAnswer = new Class_TraningCommentAnswer(); Model_CommAnswer.AnswerResult = iResultId; Model_CommAnswer.Question = itemQues.Id; Model_CommAnswer.Credit = int.Parse(dblScoreQues.ToString());//fusygoto 是否应该是double Model_CommAnswer.Chose = itemQues.Answer; Model_CommAnswer.AccountId = iAccountId; Model_CommAnswer.Delflag = false; Model_CommAnswer.CreateDate = DateTime.Now; //将数据插入到学员答题内容表 bolRes = CommentAnswerBll.Add(Model_CommAnswer) > 0; } } if (bolRes) { ScoreSetHelper.commentTraningOper(iClassId, iAccountId);//[课程评价]保存时记录学时 return Json(new { Result = true, Msg = "课程评价提交成功!" }, JsonRequestBehavior.AllowGet); } else { return Json(new { Result = true, Msg = "课程评价提交失败!" }, JsonRequestBehavior.AllowGet); } }