Beispiel #1
0
        /// <summary>
        /// 根据学生id课程id及课时id,分页查询课时单元信息
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List <DtoLessonUnit> SelectUnitByNext(DtoLessonUnitSearch search)
        {
            StudentStudyBll bll = new StudentStudyBll();

            //如果学生有这个课程进度
            if (bll.GetProgressByStudentCourse(search.StudentID, search.CourseID) != null)
            {
                //获取课时单元信息数据并转换成动作对象
                var list = UnitServer.SelectUnitsByNext(search).Select(u => (Yw_LessonUnitStepActions)UnitStepFactory.Create(u)).ToList();
                //将数据转换成为dto模型
                return(list.Select(u => new DtoLessonUnit()
                {
                    CourseId = u.Yls_CourseId,
                    LessonId = u.Yls_LessonId,
                    Id = u.Yls_UnitId,
                    Index = u.Yls_UnitIndex,
                    Coins = u.Yls_Coins,
                    Steps = u.Steps,
                    Status = u.Yls_Status,
                    CreateTime = u.Yls_CreateTime,
                    UpdateTime = u.Yls_UpdateTime
                }).ToList());
            }
            return(new List <DtoLessonUnit>());
        }
        //获取学习报告课程信息部分
        public DtoStudentReportList GetStuCourseReportById(int lessonProcessId)
        {
            StudentStudyBll studentStudyBll = new StudentStudyBll();
            var             info            = studentStudyBll.StuLesProgressRepository.GetStuCourseReportById(lessonProcessId);

            return(info);
        }
        /// <summary>
        /// 学生完成课时学习后,创建课后任务
        /// </summary>
        public Yw_StudentTask CreateTaskAutoAfterStudy(int studentId, int lesProgressId)
        {
            StudentStudyBll          studyBll    = new StudentStudyBll();
            Yw_StudentLessonProgress lesProgress = studyBll.GetStuLessonProgressById(lesProgressId);

            if (lesProgress.Yle_Percent < 100 && lesProgress.Yle_SubjectCount > 0)//学生课时学习中,如果题目全部作对,就不创建课后任务
            {
                Yw_StudentCourseProgress progress = studyBll.GetProgressByStudentCourse(studentId, lesProgress.Yle_CourseId);
                return(CreateStudyPractice(progress, studentId, lesProgress.Yle_LessonId, lesProgress.Yle_LessonIndex, lesProgressId, null, StudyTaskTypeEnum.系统课后任务));
            }
            return(null);
        }
        /// <summary>
        /// 生成课后练习,根据学生已学的课程的课时,随机组题排除最近学生已经练习的题目
        /// </summary>
        public Yw_StudentTask GeneratePractice(int studentId, int courseId, int returnCount)
        {
            SubjectBll      subjectBll = new SubjectBll();
            StudentStudyBll studyBll   = new StudentStudyBll();

            Yw_StudentCourseProgress progress = studyBll.GetProgressByStudentCourse(studentId, courseId);

            if (progress != null && progress.Yps_NextLessonIndex > 1)
            {
                List <Yw_Subject> subjects = subjectBll.GetSubjectForPractice(studentId, courseId, progress.Yps_NextLessonIndex, returnCount);
                if (subjects.Count > 0)
                {
                    var task = CreateStudyPractice(progress, studentId, 0, progress.Yps_NextLessonIndex, 0, subjects.OrderBy(x => x.Ysj_SubjectType).Select(x => x.Ysj_Id).ToList(), StudyTaskTypeEnum.课后练习);
                    return(task);
                }
            }
            return(null);
        }
        /// <summary>
        /// 查询学生全部报告
        /// </summary>
        /// <param name="paging"></param>
        /// <param name="studentId"></param>
        /// <returns></returns>
        public List <DtoStudentReportList> GetStudentReport(PagingObject paging, int studentId, int reportType)
        {
            List <DtoStudentReportList> reportList      = new List <DtoStudentReportList>();
            StudentStudyBll             studentStudyBll = new StudentStudyBll();

            if (reportType == 0)
            {
                reportList = studentStudyBll.StuLesProgressRepository.GetStudentReport(paging, studentId);
            }
            else if (reportType == (int)CourseReportEnum.练习报告 || reportType == (int)CourseReportEnum.任务报告)
            {
                StudentPracticeBll studentPracticeBll = new StudentPracticeBll();
                reportList = studentPracticeBll.StudentTaskRepository.GetStuTaskReport(paging, studentId, reportType);
            }
            else if (reportType == (int)CourseReportEnum.学习报告)
            {
                reportList = studentStudyBll.StuLesProgressRepository.GetStuCourseReport(paging, studentId);
            }
            return(reportList);
        }
Beispiel #6
0
        public bool SaveWrongBook(List <StudentAnswerCard> answerCard, DtoStudentWrongBook wrongBook)
        {
            bool result       = false;
            var  studyProcess = StudentStudyBll.GetProgressByStudentCourse(wrongBook.StudentId, wrongBook.CourseId);
            int  schoolId     = studyProcess == null ? 0 : studyProcess.Yps_SchoolId;
            int  classId      = studyProcess == null ? 0 : studyProcess.Yps_ClassId;
            List <StudentAnswerBase>      answers     = answerCard.SelectMany(s => s.AnswerCollection).ToList();
            List <Yw_StudentWrongSubject> listSubject = new List <Yw_StudentWrongSubject>();

            if (answers.Any(s => s.SubjectId <= 0))
            {
                throw new AbhsException(ErrorCodeEnum.ParameterInvalid, AbhsErrorMsg.ConstParameterInvalid);
            }
            answers.ForEach(a =>
            {
                if (CheckAnswerNeedRecordWorng(a))
                {
                    Yw_StudentWrongSubjectExt tmp = new Yw_StudentWrongSubjectExt();
                    tmp.Yws_CourseId       = wrongBook.CourseId;
                    tmp.Yws_CreateTime     = DateTime.Now;
                    tmp.Yws_KnowledgeId    = a.KnowledgeId;
                    tmp.Yws_LessonId       = wrongBook.LessonId;
                    tmp.Yws_RemoveTryCount = 0;
                    tmp.Yws_Source         = (int)wrongBook.Source;
                    tmp.Yws_Status         = (int)StudyWrongStatusEnum.未消除;
                    tmp.Yws_Answer_Obj     = a;
                    tmp.Yws_StudentId      = wrongBook.StudentId;
                    tmp.Yws_SubjectType    = a.Type;
                    tmp.Yws_UpdateTime     = DateTime.Now;
                    tmp.Yws_WrongBookId    = 0;
                    tmp.Yws_WrongSubjectId = a.SubjectId;

                    listSubject.Add(tmp);
                }
            });
            if (listSubject.Count == 0)
            {
                return(true);
            }
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    Yw_StudentWrongBook bookModel = GetBookByStudentAndStudy(wrongBook.StudentId, wrongBook.CourseId, wrongBook.LessonId, wrongBook.LessonProgressId, wrongBook.StudyTaskId);
                    bool saveSubject         = false;
                    bool saveBook            = false;
                    int  WrongCount          = 0;
                    int  WrongKnowledgeCount = 0;

                    #region 获取要插入的错题及错题数的计算
                    if (bookModel != null)
                    {
                        List <Yw_StudentWrongSubject> oldSubjectList = GetSubjectByBookId(bookModel.Ywb_Id);
                        listSubject = listSubject.ExceptExt(oldSubjectList, l => l.Yws_WrongSubjectId)
                                      //.Where(s =>
                                      // {
                                      //     return !oldSubjectList.Exists(o => o.Yws_WrongSubjectId == s.Yws_WrongSubjectId);
                                      // })
                                      .Select(s => s)
                                      .ToList();
                        WrongCount          = bookModel.Yws_WrongCount + listSubject.Select(s => s.Yws_WrongSubjectId).Distinct().Count();
                        WrongKnowledgeCount = (from o in oldSubjectList
                                               where o.Yws_Status == (int)StudyWrongStatusEnum.未消除 && o.Yws_KnowledgeId > 0
                                               select o.Yws_KnowledgeId)
                                              .Concat(from n in listSubject where n.Yws_KnowledgeId > 0 select n.Yws_KnowledgeId)
                                              .Distinct().Count();
                    }
                    else
                    {
                        WrongCount          = listSubject.Select(s => s.Yws_WrongSubjectId).Distinct().Count();
                        WrongKnowledgeCount = listSubject.Where(s => s.Yws_KnowledgeId > 0).Select(s => s.Yws_KnowledgeId).Distinct().Count();
                    }
                    #endregion

                    #region save错题本
                    if (bookModel != null)
                    {
                        bookModel.Yws_WrongCount          = WrongCount;
                        bookModel.Yws_WrongKnowledgeCount = WrongKnowledgeCount;
                        bookModel.Yws_UpdateTime          = DateTime.Now;
                        saveBook = StudentWrongBookRepository.Update(bookModel);
                    }
                    else
                    {
                        bookModel = new Yw_StudentWrongBook();
                        bookModel.Ywb_CourseId            = wrongBook.CourseId;
                        bookModel.Ywb_LessonId            = wrongBook.LessonId;
                        bookModel.Ywb_LessonProgressId    = wrongBook.LessonProgressId;
                        bookModel.Ywb_StudentId           = wrongBook.StudentId;
                        bookModel.Ywb_StudyTaskId         = wrongBook.StudyTaskId;
                        bookModel.Yws_ClassId             = classId;
                        bookModel.Yws_CreateTime          = DateTime.Now;
                        bookModel.Yws_RemoveCount         = 0;
                        bookModel.Yws_SchoolId            = schoolId;
                        bookModel.Yws_Source              = (int)wrongBook.Source;
                        bookModel.Yws_Status              = (int)StudyWrongStatusEnum.未消除;
                        bookModel.Yws_UpdateTime          = DateTime.Now;
                        bookModel.Yws_WrongCount          = WrongCount;
                        bookModel.Yws_WrongKnowledgeCount = WrongKnowledgeCount;
                        bookModel.Ywb_Id = StudentWrongBookRepository.Insert(bookModel);
                        saveBook         = bookModel.Ywb_Id > 0;
                    }
                    listSubject.ForEach(s => s.Yws_WrongBookId = bookModel.Ywb_Id);
                    #endregion

                    #region save错题详情
                    saveSubject = InsertSubjectList(listSubject);
                    #endregion
                    result = saveBook && saveSubject;
                    if (result)
                    {
                        scope.Complete();
                    }
                    else
                    {
                        RollbackTran();
                    }
                }
                catch (Exception)
                {
                    RollbackTran();
                    throw;
                }
            }

            return(result);
        }
        /// <summary>
        /// 学生开始课后任务,生成题目
        /// </summary>
        public void GenerateTaskSubjectsAutoAfterStudy(int studyTaskId, int studentId)
        {
            StudentStudyBll studyBll   = new StudentStudyBll();
            SubjectBll      subjectBll = new SubjectBll();

            Yw_StudyTask   task    = StudyTaskRepository.Get(studyTaskId);
            Yw_StudentTask stuTask = StudentTaskRepository.GetByStudentTask(studentId, studyTaskId);

            if (task == null || stuTask == null)
            {
                return;
            }

            Yw_StudentLessonAnswerExt answer = studyBll.GetLessonAnswer(task.Ysk_LessonProgressId) as Yw_StudentLessonAnswerExt;

            if (answer == null)
            {
                return;
            }

            List <StudentAnswerBase> problemAnswers = answer.Yla_Answer_Obj.SelectMany(x => x.AnswerCollection).Where(x => x.ResultStars < 5).ToList();
            List <Tuple <int, int> > errorSubjects  = problemAnswers.GroupBy(x => x.SubjectId).
                                                      Select(x => new Tuple <int, int>(x.Key, x.Min(y => y.ResultStars))).ToList();

            List <DtoLesTaskSubject> subjects = subjectBll.GetLessonTaskSubject(task.Ysk_LessonId, errorSubjects);

            var groups = subjects.OrderBy(x => x.Number)
                         .GroupBy(x => new { ErrorSubjectId = x.ErrorSubjectId, Score = x.Score })
                         .OrderBy(x => x.Key.Score);

            Dictionary <int, DtoLesTaskSubject> subjectSelected = new Dictionary <int, DtoLesTaskSubject>();

            List <WrapSubjectGroup> wrapGroups = new List <WrapSubjectGroup>();

            foreach (IGrouping <dynamic, DtoLesTaskSubject> group in groups)
            {
                wrapGroups.Add(new WrapSubjectGroup(group.Key.Score, group.ToList()));
            }

            bool hasSubject      = false;
            bool reachMax        = false;
            int  maxSubjectCount = groups.Count() > 50 ? groups.Count() : 50;//每个错题至少推一个关联题目
            int  loopTime        = 0;

            while (loopTime < maxSubjectCount)
            {
                hasSubject = false;
                foreach (WrapSubjectGroup group in wrapGroups)
                {
                    bool result = group.TakeSubject(subjectSelected);
                    if (result)
                    {
                        if (subjectSelected.Count >= maxSubjectCount)
                        {
                            reachMax = true;
                            break;
                        }
                        hasSubject = true;
                    }
                }
                if (!hasSubject || reachMax)
                {
                    break;
                }
                loopTime++;
            }

            if (subjectSelected.Count > 0)
            {
                task.Ysk_SubjectIds   = string.Join(",", subjectSelected.OrderBy(x => x.Value.SubjectType).Select(x => x.Value.SubjectId));
                task.Ysk_SubjectCount = subjectSelected.Count;
                task.Ysk_Score        = 5 * subjectSelected.Count;
                StudyTaskRepository.Update(task);

                stuTask.Yuk_SubjectCount = subjectSelected.Count;
                StudentTaskRepository.Update(stuTask);
            }
        }
        /// <summary>
        /// 提交学生学习进度数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns>0:添加成功,-1:课时进度秘钥错误,-2:数据重复提交,-3:金币数目错误</returns>
        public int SubmitStudyProgress(DtoStudnetUnitSubmit info)
        {
            ///注:这里考虑如何使用事务

            DateTime submitTime = DateTime.Now;
            //获取最后一次学习进度
            var progress = StuLesProgressRepository.GetLastProgress(info.StudnetId, info.LessonId);

            //判断课时进度秘钥是否正确
            if (progress.Yle_key == info.ProgressKey)
            {
                //如果当前进度中的当前学习单元页大于提交的单元
                if (progress.Yle_UnitIndex > info.UnitNum)
                {
                    return(-2);//表示数据已经提交过,不能重复提交
                }
                else
                {
                    //创建答题卡对象
                    StudentAnswerCard card = null;
                    #region 填充答题卡数据
                    if (info.Answers != null && info.Answers.Count > 0)
                    {
                        card = new StudentAnswerCard();
                        card.AnswerCollection = info.Answers;                         //填充答案
                        card.TotalStars       = info.Answers.Sum(s => s.ResultStars); //填充总星数
                        card.TotalCoins       = info.Answers.Sum(s => s.ResultCoins); //填充总金币数

                        card.Part       = info.UnitID;                                //填充单元(页码)id
                        card.SubmitTime = submitTime.ToString("yyyy-MM-dd HH:mm:ss"); //填充提交时间
                        card.UseTime    = info.UseTime;                               //填充用户学习时间
                    }
                    #endregion

                    //创建金币记录对象
                    StuLessonCoinRecord coinRecord = null;
                    #region 更新金币记录对象及答题卡部分数据
                    if (info.Coins != null && info.Coins.Count > 0)
                    {
                        coinRecord = new StuLessonCoinRecord();
                        coinRecord.CoinCollection = info.Coins;                                 //填充金币记录
                        coinRecord.TotalCoins     = info.Coins.Sum(s => s.GetCoins);            //填充总金币数
                        coinRecord.Part           = info.UnitID;                                //填充单元(页码)id
                        coinRecord.SubmitTime     = submitTime.ToString("yyyy-MM-dd HH:mm:ss"); //填充提交时间
                        coinRecord.UseTime        = info.UseTime;                               //填充用户学习时间
                    }
                    #endregion

                    if (coinRecord != null && coinRecord.TotalCoins > info.AllCoin) //如果得到的金币数大于本页总金币数
                    {
                        return(-3);                                                 //表示金币和大于总金币数
                    }
                    else
                    {
                        #region 修改课时进度表数据
                        progress.Yle_UnitIndex          = info.UnitNum + 1;                                                                                                                    //更新开始页
                        progress.Yle_IsFinished         = info.UnitNum >= info.TotalUnitNum;                                                                                                   //更新是否结束
                        progress.Yle_LastStudyTime      = DateTime.Now;                                                                                                                        //更新最后学习时间
                        progress.Yle_SubjectCount      += info.Answers.Count;                                                                                                                  //更新总题目数
                        progress.Yle_RightSubjectCount += info.Answers.Where(s => s.IsRight).Count();                                                                                          //更新正确题目数
                        progress.Yle_GainCoins         += info.Coins.Sum(s => s.GetCoins);                                                                                                     //更新获取金币数量
                        progress.Yle_Percent            = (int)(Math.Round(progress.Yle_RightSubjectCount * 1.0 / (progress.Yle_SubjectCount == 0 ? 1 : progress.Yle_SubjectCount), 2) * 100); //重新计算题目正确率
                        progress.Yle_StudySeconds      += info.UseTime;                                                                                                                        //增加课时进度学习时长
                        #endregion

                        #region 事务提交
                        using (TransactionScope scope = new TransactionScope())
                        {
                            try
                            {
                                #region 提交

                                //如果学习完成,更新学生课程进度表
                                if (progress.Yle_IsFinished)
                                {
                                    progress.Yle_FinishStudyTime = DateTime.Now;//修改课时完成完成时间
                                    //获取完成的课时id
                                    var finisheds = StuLesProgressRepository.GetFinishedByLesson(info.StudnetId, info.CoruseId);
                                    if (!finisheds.Contains(info.LessonId))//如果课时没有学完过,修改课程进度表数据
                                    {
                                        LessonBll bll            = new LessonBll();
                                        int       lessonCount    = bll.GetLessonsCountByCourse(info.CoruseId);                                                                                  //课程的课时数
                                        var       courseProgress = ScpRepository.GetByStudentCourse(info.StudnetId, info.CoruseId);                                                             //获取课程完成进度.

                                        courseProgress.Yps_LessonFinishedCount = finisheds.Count() + 1;                                                                                         //完成的课时数+1(自身)
                                        courseProgress.Yps_IsFinished          = courseProgress.Yps_LessonFinishedCount >= lessonCount;                                                         //如果完成的课时数大于等于总课时数,则表示完成.
                                        courseProgress.Yps_NextLessonIndex     = courseProgress.Yps_NextLessonIndex > info.LessonNum ? courseProgress.Yps_NextLessonIndex : info.LessonNum + 1; //如果下一课时数大于当前课时,则不更改.否则改为当前课时的下一课时序号
                                        if (courseProgress.Yps_IsFinished && courseProgress.Yps_FinishStudyTime == new DateTime(1900, 1, 1))                                                    //如果课程进度完成,且完成时间不为初始值,则修改此时间
                                        {
                                            courseProgress.Yps_FinishStudyTime = DateTime.Now;
                                        }
                                        courseProgress.Yps_UpdateTime = DateTime.Now; //更新时间
                                        ScpRepository.Update(courseProgress);         //更新课程进度
                                    }
                                }
                                StuLesProgressRepository.Update(progress);//更新课时数据

                                string cardJson = "", coinJson = "";
                                //添加错题数据
                                if (card != null)
                                {
                                    cardJson = $",{JsonConvert.SerializeObject(card)}";
                                    new StudentWrongBookBll().SaveWrongBook(new List <StudentAnswerCard> {
                                        card
                                    }, new DtoStudentWrongBook {
                                        CourseId = progress.Yle_CourseId, LessonId = progress.Yle_LessonId, LessonProgressId = progress.Yle_Id, Source = StudyWrongSourceEnum.课程学习, StudentId = progress.Yle_StudentId, StudyTaskId = 0
                                    });
                                }
                                //需要修改学生金币数量及经验
                                if (coinRecord != null)
                                {
                                    coinJson = $",{JsonConvert.SerializeObject(coinRecord)}";
                                    new StudentInfoBll().AddCoins(info.StudnetId, coinRecord.TotalCoins);
                                }

                                //更新学生课时答题结果表
                                if (card != null || coinRecord != null)
                                {
                                    StuLessonAnsRepository.Update(info.ProgressID, cardJson, coinJson);
                                }
                                #endregion
                                scope.Complete();
                            }
                            catch (Exception ex)
                            {
                                RollbackTran();
                                throw ex;
                            }
                        }
                        #endregion

                        StudentStudyBll ssbll = new StudentStudyBll();
                        ssbll.PublishStudyMessage(progress.Yle_CourseId, progress.Yle_LessonId, progress.Yle_StudentId, info.UseTime, progress.Yle_SubjectCount, progress.Yle_GainCoins);
                        if (progress.Yle_IsFinished)
                        {
                            ssbll.PublishLessonFinishMessage(progress.Yle_StudentId, progress.Yle_Id);
                        }


                        return(0);//表示成功
                    }
                }
            }
            else
            {
                return(-1);//表示课时进度秘钥错误,及在其他地方打开了这个课程学习
            }
        }
        /// <summary>
        /// 学习报告数量
        /// </summary>
        /// <param name="studentId"></param>
        /// <returns></returns>
        public int StuCourseReportCount(int studentId)
        {
            StudentStudyBll studentStudyBll = new StudentStudyBll();

            return(studentStudyBll.StuLesProgressRepository.StuCourseReportCount(studentId));
        }
        /// <summary>
        /// 获取学习报告的统计部分
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public DtoStudentReport GetByStuLesAnswer(int studentId, int lessonProgressId)
        {
            StudentStudyBll studentStudyBll = new StudentStudyBll();
            //var result = studentStudyBll.StuLesProgressRepository.IsHasStudy(lessonProgressId, studentId);
            //if (!result)
            //{
            //    throw new AbhsException(ErrorCodeEnum.NotStudyReport, AbhsErrorMsg.ConstNotStudyReport + " LessonProgressId:" + lessonProgressId);
            //}

            //演示异常使用,正式上线删除
            var lesProgress = studentStudyBll.StuLesProgressRepository.IsHasStudys(lessonProgressId, studentId);

            if (lesProgress == null)
            {
                throw new AbhsException(ErrorCodeEnum.NotStudyReport, AbhsErrorMsg.ConstNotStudyReport + " LessonProgressId:" + lessonProgressId);
            }
            if (!lesProgress.Yle_IsFinished)
            {
                var errorlog = $"操作者:{studentId},操作时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},课程进度Id:{lessonProgressId},原因:课程状态未完成,开始学习时间:{lesProgress.Yle_StartStudyTime.ToString("yyyy-MM-dd HH:mm:ss")},结束学习时间:{lesProgress.Yle_FinishStudyTime.ToString("yyyy-MM-dd HH:mm:ss")},学习时长:{lesProgress.Yle_StudySeconds},已答题目数:{lesProgress.Yle_SubjectCount},数据创建时间:{lesProgress.Yle_CreateTime.ToString("yyyy-MM-dd HH:mm:ss")},数据修改时间:{lesProgress.Yle_UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}";
                LogHelper.WriteLog(errorlog);

                //查询学习时长
                Yw_StudentLessonProgress lessonProgress = studentStudyBll.StuLesProgressRepository.GetProgressByID(lessonProgressId);
                var studyTime = Convert.ToInt32(Math.Ceiling(lessonProgress.Yle_StudySeconds * 1.0 / 60));
                //病句  选择题
                if (lesProgress.Yle_LessonId == 10000)
                {
                    return(GetSelect(studyTime));
                }
                //断句
                else if (lesProgress.Yle_LessonId == 10001)
                {
                    return(GetMarkCut(studyTime));
                }
                //阅读理解 填空
                else if (lesProgress.Yle_LessonId == 10002)
                {
                    return(GetFillBlank(studyTime));
                }
            }
            //演示结束

            //获取学生答案
            Yw_StudentLessonAnswerExt lessonAnswer  = studentStudyBll.StuLessonAnsRepository.GetStuLesAnswer(studentId, lessonProgressId) as Yw_StudentLessonAnswerExt;
            List <StudentAnswerCard>  answerCard    = lessonAnswer.Yla_Answer_Obj;
            DtoStudentReport          studentReport = new DtoStudentReport();

            if (answerCard != null)
            {
                //查询学习时长
                Yw_StudentLessonProgress lessonProgress = studentStudyBll.StuLesProgressRepository.GetProgressByID(lessonProgressId);
                studentReport.StudyTime = Convert.ToInt32(Math.Ceiling(lessonProgress.Yle_StudySeconds * 1.0 / 60));

                studentReport.StudyDate      = answerCard.OrderBy(s => s.SubmitTime).FirstOrDefault().SubmitTime;
                studentReport.TotalStars     = answerCard.Sum(s => s.TotalStars);
                studentReport.ResultCoins    = answerCard.Sum(s => s.AnswerCollection.Sum(x => x.ResultCoins));
                studentReport.TotalCoins     = answerCard.Sum(s => s.TotalCoins);
                studentReport.TotalScore     = Convert.ToInt32(Math.Round((answerCard.Sum(s => s.TotalStars) * 1.0 / (answerCard.Sum(s => s.AnswerCollection.Count) * 5.0) * 5), MidpointRounding.AwayFromZero));
                studentReport.SubjectCount   = answerCard.Sum(s => s.AnswerCollection.Count());
                studentReport.KnowledgeRates = answerCard.Sum(s => s.TotalStars) * 1.0 / (answerCard.Sum(s => s.AnswerCollection.Count) * 5.0);

                double rates = Math.Round((double)(answerCard.Sum(s => s.AnswerCollection.Where(x => x.ResultStars == 5).Count())) / answerCard.Sum(s => s.AnswerCollection.Count()), 2) * 100;
                studentReport.ExcellentRates = rates;
                var answers = answerCard.Select(s => s.AnswerCollection).ToList();
                List <StudentAnswerBase> answerBase = new List <StudentAnswerBase>();
                foreach (var item in answers)
                {
                    answerBase.AddRange(item.Where(x => x.KnowledgeId != 0).ToList());
                }
                var knowledgeShow = answerBase.GroupBy(s => s.KnowledgeId);
                studentReport.Knowledge = GetKnowledge(knowledgeShow);
            }
            return(studentReport);
        }