예제 #1
0
        //public Yw_StudentLessonAnswer GetByStudentLesson(int lessonId, int studentId)
        //{
        //    string sql = @"select * from Yw_StudentLessonAnswer
        //                   where Yla_LessonProgressId =
        //                   (select Yle_Id from Yw_StudentLessonProgress where Yle_StudentId = @StudentId and Yle_LessonId = @LessonId and Yle_IsLastest=1)";

        //    Yw_StudentLessonAnswer obj = Query(sql, new { StudentId = studentId, LessonId = lessonId }).FirstOrDefault();
        //    Yw_StudentLessonAnswerExt realObj = TranslatorFactory.Translator<Yw_StudentLessonAnswer, Yw_StudentLessonAnswerExt>(obj);
        //    realObj.EnableAudit();

        //    return realObj;
        //}

        public Yw_StudentLessonAnswer GetStuLesAnswer(int studentId, int lessonProgressId)
        {
            string sql = "select * from Yw_StudentLessonAnswer where Yla_StudentId=@StudentId and Yla_LessonProgressId=@ProgressId";
            Yw_StudentLessonAnswer    obj     = Query(sql, new { StudentId = studentId, ProgressId = lessonProgressId }).FirstOrDefault();
            Yw_StudentLessonAnswerExt realObj = TranslatorFactory.Translator <Yw_StudentLessonAnswer, Yw_StudentLessonAnswerExt>(obj);

            realObj.EnableAudit();

            return(realObj);
        }
예제 #2
0
        public Yw_StudentLessonAnswer GetByProgressId(int lessonProgressId)
        {
            string sql = "select * from Yw_StudentLessonAnswer where Yla_LessonProgressId=@ProgressId";
            Yw_StudentLessonAnswer obj = Query(sql, new { ProgressId = lessonProgressId }).FirstOrDefault();

            if (obj != null)
            {
                Yw_StudentLessonAnswerExt realObj = TranslatorFactory.Translator <Yw_StudentLessonAnswer, Yw_StudentLessonAnswerExt>(obj);
                realObj.EnableAudit();
                return(realObj);
            }
            return(null);
        }
        public void GenerateTaskSubjectsAutoAfterStudy()
        {
            Yw_StudentLessonAnswerExt answer = new Yw_StudentLessonAnswerExt();

            answer.Yla_Answer_Obj = new List <Domain.JsonEntity.Answer.StudentAnswerCard>();

            StudentAnswerCard card = new StudentAnswerCard();

            card.Part             = 1;
            card.SubmitTime       = DateTime.Now.ToString();
            card.AnswerCollection = new List <StudentAnswerBase>();

            BlankAnswerItem item = new BlankAnswerItem();

            item.Index = 0;
            item.Score = 0.8;
            item.Text  = "ce shi";

            BlankAnswerItem item1 = new BlankAnswerItem();

            item1.Index = 1;
            item1.Score = 0.8;
            item1.Text  = "ce shi1";

            card.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item, item1
                }, KnowledgeId = 10000, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10000, Type = (int)SubjectTypeEnum.填空题
            });
            card.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item, item1
                }, KnowledgeId = 10000, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10001, Type = (int)SubjectTypeEnum.填空题
            });
            card.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item, item1
                }, KnowledgeId = 10000, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10002, Type = (int)SubjectTypeEnum.填空题
            });
            card.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item, item1
                }, KnowledgeId = 10000, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10003, Type = (int)SubjectTypeEnum.填空题
            });
            card.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item, item1
                }, KnowledgeId = 10000, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10004, Type = (int)SubjectTypeEnum.填空题
            });
            card.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item, item1
                }, KnowledgeId = 10000, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10005, Type = (int)SubjectTypeEnum.填空题
            });

            StudentAnswerCard card1 = new StudentAnswerCard();

            card1.Part             = 1;
            card1.SubmitTime       = DateTime.Now.ToString();
            card1.AnswerCollection = new List <StudentAnswerBase>();

            BlankAnswerItem item2 = new BlankAnswerItem();

            item2.Index = 0;
            item2.Score = 0.8;
            item2.Text  = "ce shi";

            BlankAnswerItem item3 = new BlankAnswerItem();

            item3.Index = 1;
            item3.Score = 0.8;
            item3.Text  = "ce shi1";

            card1.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item2, item3
                }, KnowledgeId = 10000, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10010, Type = (int)SubjectTypeEnum.填空题
            });
            card1.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item2, item3
                }, KnowledgeId = 10001, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10011, Type = (int)SubjectTypeEnum.填空题
            });
            card1.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item2, item3
                }, KnowledgeId = 10002, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10012, Type = (int)SubjectTypeEnum.填空题
            });
            card1.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item2, item3
                }, KnowledgeId = 10003, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10013, Type = (int)SubjectTypeEnum.填空题
            });
            card1.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item2, item3
                }, KnowledgeId = 10004, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10014, Type = (int)SubjectTypeEnum.填空题
            });
            card1.AnswerCollection.Add(new StuBlankAnswer()
            {
                Answers = new List <StuBlankAnswer.BlankAnswerItem>()
                {
                    item2, item3
                }, KnowledgeId = 10005, ResultCoins = 3, ResultStars = 3, SubjectCoins = 5, SubjectId = 10015, Type = (int)SubjectTypeEnum.填空题
            });

            answer.Yla_Answer_Obj.Add(card);
            answer.Yla_Answer_Obj.Add(card1);


            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 = new List <DtoLesTaskSubject>();

            subjects.Add(new DtoLesTaskSubject()
            {
                ErrorSubjectId = 10000, Number = 3, Score = 1, SubjectId = 11000, SubjectType = (int)SubjectTypeEnum.判断题
            });
            subjects.Add(new DtoLesTaskSubject()
            {
                ErrorSubjectId = 10000, Number = 2, Score = 1, SubjectId = 11001, SubjectType = (int)SubjectTypeEnum.择题
            });
            subjects.Add(new DtoLesTaskSubject()
            {
                ErrorSubjectId = 10000, Number = 1, Score = 1, SubjectId = 11002, SubjectType = (int)SubjectTypeEnum.判断题
            });
            subjects.Add(new DtoLesTaskSubject()
            {
                ErrorSubjectId = 10001, Number = 1, Score = 2, SubjectId = 11002, SubjectType = (int)SubjectTypeEnum.判断题
            });
            subjects.Add(new DtoLesTaskSubject()
            {
                ErrorSubjectId = 10001, Number = 2, Score = 2, SubjectId = 11001, SubjectType = (int)SubjectTypeEnum.判断题
            });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10001, Number = 3, Score = 2, SubjectId = 11003, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10001, Number = 3, Score = 2, SubjectId = 11004, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10001, Number = 3, Score = 2, SubjectId = 11005, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10002, Number = 3, Score = 2, SubjectId = 11202, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10003, Number = 3, Score = 2, SubjectId = 11203, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10004, Number = 3, Score = 2, SubjectId = 11204, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10005, Number = 3, Score = 2, SubjectId = 11205, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10006, Number = 3, Score = 2, SubjectId = 11006, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10007, Number = 3, Score = 2, SubjectId = 11007, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10008, Number = 3, Score = 2, SubjectId = 11008, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10009, Number = 3, Score = 2, SubjectId = 11009, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10010, Number = 3, Score = 2, SubjectId = 11010, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10011, Number = 3, Score = 2, SubjectId = 11011, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10012, Number = 3, Score = 2, SubjectId = 11012, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10013, Number = 3, Score = 2, SubjectId = 11013, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10014, Number = 3, Score = 2, SubjectId = 11014, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10015, Number = 3, Score = 2, SubjectId = 11015, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10016, Number = 3, Score = 2, SubjectId = 11016, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10017, Number = 3, Score = 2, SubjectId = 11017, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10018, Number = 3, Score = 2, SubjectId = 11018, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10019, Number = 3, Score = 2, SubjectId = 11019, SubjectType = (int)SubjectTypeEnum.选择题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10010, Number = 1, Score = 3, SubjectId = 12000, SubjectType = (int)SubjectTypeEnum.连线题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10011, Number = 1, Score = 3, SubjectId = 12001, SubjectType = (int)SubjectTypeEnum.连线题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10012, Number = 1, Score = 3, SubjectId = 12002, SubjectType = (int)SubjectTypeEnum.连线题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10013, Number = 1, Score = 3, SubjectId = 12003, SubjectType = (int)SubjectTypeEnum.连线题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10014, Number = 1, Score = 3, SubjectId = 12004, SubjectType = (int)SubjectTypeEnum.连线题 });
            //subjects.Add(new DtoLesTaskSubject() { ErrorSubjectId = 10015, Number = 1, Score = 3, SubjectId = 12005, SubjectType = (int)SubjectTypeEnum.连线题 });

            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)
            {
                string str = string.Join(",", subjectSelected.OrderBy(x => x.Value.SubjectType).Select(x => x.Value.SubjectId));
            }
        }
예제 #4
0
        /// <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);
            }
        }
예제 #5
0
        /// <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);
        }