public JsonResult SavePracticeResult(string dataStr, StudyTaskTypeEnum taskType)
        {
            try
            {
                JObject data = JsonConvert.DeserializeObject(dataStr) as JObject;

                int studyTaskId = data["id"].Value <int>();
                int useTime     = data["useTime"].Value <int>();
                List <StudentAnswerBase> answers = new List <StudentAnswerBase>();

                JArray jAnswers = data["answers"] as JArray;
                foreach (var jAnswer in jAnswers)
                {
                    var answer = SubjectAnswerObjectBuilder.TranslateAnswer(jAnswer.ToString());
                    answers.Add(answer);
                }

                StudentPracticeBll bll = new StudentPracticeBll();
                bll.SaveResult(
                    GetCurrentUser().StudentId,
                    studyTaskId,
                    useTime,
                    answers,
                    taskType);
                return(Json(new SuccessJsonResponse()));
            }
            catch (AbhsException ex)
            {
                if (ex.ErrorCode == (int)ErrorCodeEnum.StudentTaskStatusInvalid)
                {
                    JsonSimpleResponse res = new JsonSimpleResponse();
                    res.State    = false;
                    res.ErrorMsg = "你已经完成该练习";
                    return(Json(res));
                }
                else
                {
                    throw;
                }
            }
        }
        public JsonResult SubmintProcressData(string dataStr)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"学生id:{GetCurrentUser().StudentId},操作时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")};");
            sb.AppendLine($"接收数据:{dataStr}");
            DtoStudnetUnitSubmit info = new DtoStudnetUnitSubmit();

            #region json字符串填充数据
            try
            {
                JObject data = JsonConvert.DeserializeObject(dataStr) as JObject;
                info.StudnetId = GetCurrentUser().StudentId;
                info.CoruseId  = Convert.ToInt32(data["courseId"]);                         //课程id
                info.LessonId  = Convert.ToInt32(data["lessonId"]);                         //课时id
                info.LessonNum = Convert.ToInt32(data["lessonNum"]);                        //课时序号
                info.UnitID    = Convert.ToInt32(data["unitId"]);                           //单元(讲义页)id
                string   coinKey = Encrypt.DecryptQueryString(data["coinsKey"].ToString()); //金币加密字符串
                string[] check   = coinKey.Split('_');
                //验证金币加密串是否可用
                //这个验证方式要与GetLessonPage方法中加密字符串对应
                if (check.Length == 4 && check[1] == info.UnitID.ToString() && check[2] == info.LessonId.ToString() && check[3] == info.CoruseId.ToString())
                {
                    info.AllCoin      = Convert.ToInt32(check[0]);             //本页最大金币数
                    info.UnitNum      = Convert.ToInt32(data["unitNum"]);      //单元(讲义页)序号
                    info.UseTime      = Convert.ToInt32(data["useTime"]);      //学习时长(秒)
                    info.ProgressID   = Convert.ToInt32(data["progressId"]);   //学习进度id
                    info.ProgressKey  = data["progressKey"].ToString();        //学习进度key
                    info.TotalUnitNum = Convert.ToInt32(data["totalUnitNum"]); //最大学习数
                    #region 填充答题结果
                    JArray answers = JsonConvert.DeserializeObject(data["answers"].ToString()) as JArray;
                    foreach (var a in answers)
                    {
                        info.Answers.Add(SubjectAnswerObjectBuilder.TranslateAnswer(a.ToString()));
                    }
                    #endregion
                    #region 填充金币记录
                    JArray coins = JsonConvert.DeserializeObject(data["coins"].ToString()) as JArray;
                    foreach (var c in coins)
                    {
                        JObject o = JsonConvert.DeserializeObject(c.ToString()) as JObject;
                        info.Coins.Add(new StuLessonCoinItem
                        {
                            ActionId    = o["acid"].ToString(),
                            ActionCoins = Convert.ToInt32(o["acin"]),
                            ActionType  = o["type"].ToString(),
                            GetCoins    = Convert.ToInt32(o["gcin"])
                        });
                    }
                    #endregion
                }
                else
                {
                    sb.AppendLine("回复数据:金币加密串解析错误");
                    LogHelper.ErrorLog(sb.ToString(), new Exception("金币加密串解析错误"));
                    return(Json(new JsonResponse <object>
                    {
                        State = false,
                        ErrorCode = -100,
                        ErrorMsg = "金币加密串解析错误"
                    }));
                }
            }
            catch (Exception ex)
            {
                sb.AppendLine("回复数据:json数据结构错误");
                LogHelper.ErrorLog(sb.ToString(), ex);
                return(Json(new JsonResponse <object>
                {
                    State = false,
                    ErrorCode = -200,
                    ErrorMsg = "json数据结构错误"
                }));
            }
            #endregion
            StudentStudyBll bll    = new StudentStudyBll();
            int             result = bll.SubmitStudyProgress(info);//提交数据结果
            var             r      = new JsonResponse <object>();
            #region 根据结果填充返回数据
            switch (result)
            {
            case 0:    //成功
                r.State    = true;
                r.ErrorMsg = "成功";
                break;

            case -1:    //课时进度秘钥错误
                r.State     = false;
                r.ErrorCode = result;
                r.ErrorMsg  = "课时进度秘钥错误";
                break;

            case -2:    //数据重复提交
                r.State     = false;
                r.ErrorCode = result;
                r.ErrorMsg  = "数据重复提交";
                break;

            case -3:    //金币数目错误
                r.State     = false;
                r.ErrorCode = result;
                r.ErrorMsg  = "金币数目错误";
                break;

            default:
                r.State     = false;
                r.ErrorCode = result;
                r.ErrorMsg  = "未知错误";
                break;
            }
            #endregion
            if (!r.State)
            {
                sb.AppendLine($"回复数据:{r.ErrorMsg}");
                LogHelper.ErrorLog(sb.ToString(), new Exception(r.ErrorMsg));
            }
            return(Json(r));
        }