Пример #1
0
        public Boolean learnBad(int studentId, int courseId)
        {
            List <ChapterNode>    chapterNodes    = ChapterContentApi.findByCourseID(courseId);
            List <StudentChapter> studentChapters = StudentChapterApi.findByChapterIDBetweenAndStudentIDOrderByChapterIDDesc(chapterNodes[0].id, chapterNodes[chapterNodes.Count - 1].id, studentId);
            int?chapterId1 = 0;
            int?chapterId2 = 0;

            for (int i = 0; i < studentChapters.Count; i++)
            {
                if (studentChapters[i].comment != null)
                {
                    chapterId1 = studentChapters[i].chapterID;
                    chapterId2 = chapterId1;
                    for (int j = i + 1; j < studentChapters.Count; j++)
                    {
                        if (studentChapters[j].comment != null)
                        {
                            chapterId2 = studentChapters[j].chapterID;
                            break;
                        }
                    }
                    break;
                }
            }
            if (chapterId1 == 0)
            {
                return(false);
            }
            List <StudentChapter> temp1   = StudentChapterApi.findByChapterID(chapterId1);
            List <int?>           scores1 = new List <int?>();

            foreach (StudentChapter i in temp1)
            {
                scores1.Add(i.totalScore_2);
            }
            List <StudentChapter> temp2   = StudentChapterApi.findByChapterID(chapterId2);
            List <int?>           scores2 = new List <int?>();

            foreach (StudentChapter i in temp2)
            {
                scores2.Add(i.totalScore_2);
            }
            //fragile
            scores1.Sort();
            scores2.Sort();
            if (scores1[(int)(0.4 * temp1.Count)] > StudentChapterApi.findByChapterIDAndStudentID(chapterId1, studentId).totalScore_2&& scores2[(int)(0.4 * temp2.Count)] > StudentChapterApi.findByChapterIDAndStudentID(chapterId2, studentId).totalScore_2)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
        public ResultEntity rateNumber(int?chapterId)
        {
            ResultEntity resultEntity = new ResultEntity();

            if (chapterId != null)
            {
                List <int?> numbers = new List <int?>();
                for (int i = 1; i <= 5; i++)
                {
                    numbers.Add(StudentChapterApi.countByChapterIDAndRate(chapterId, i));
                }
                resultEntity.setData(numbers);
                resultEntity.setState(1);
            }
            else
            {
                resultEntity.setMessage("传入参数为空!");
                resultEntity.setState(0);
            }
            return(resultEntity);
        }
Пример #3
0
        //fragile
        public Dictionary <String, float?> userLabel(int studentId)
        {
            List <Takes>        takesList  = TakesApi.findByStudentID(studentId);
            List <List <int?> > courseList = new List <List <int?> >();
            List <float?>       scores     = new List <float?>();
            TypeMapper          typeMapper = new TypeMapper();

            for (int i = 0; i < 4; i++)
            {
                courseList.Add(new List <int?>());
            }
            foreach (Takes takes in takesList)
            {
                int?temp        = CourseClassApi.getByID(takes.courseClassID).courseID;
                int anotherTemp = int.Parse(CourseInfoApi.findByCourseID(temp).courseName);
                if (typeMapper.mapper.ContainsKey(anotherTemp))
                {
                    courseList[typeMapper.mapper[anotherTemp].Value - 1].Add(temp);
                }
            }
            for (int i = 0; i < 4; i++)
            {
                if (courseList[i].Count == 0)
                {
                    scores.Add(-1.0f);
                    continue;
                }
                List <int?> chapterList = new List <int?>();
                foreach (int?courseId in courseList[i])
                {
                    List <ChapterNode> chapterNodes = ChapterContentApi.findByCourseID(courseId);
                    foreach (ChapterNode chapterNode in chapterNodes)
                    {
                        chapterList.Add(chapterNode.id);
                    }
                }
                float count = 0;
                float?total = 0;
                foreach (int?integer in chapterList)
                {
                    StudentChapter studentChapter = StudentChapterApi.findByChapterIDAndStudentID(integer, studentId);
                    if (studentChapter != null && studentChapter.scored_2 != null && studentChapter.scored_2 == 1)
                    {
                        count++;
                        total += 100 * studentChapter.totalScore_2 / ChapterContentApi.getByID(integer).exerciseTotal_2;
                    }
                }
                if (count == 0)
                {
                    scores.Add(-1.0f);
                }
                else
                {
                    scores.Add(total / count);
                }
            }
            Dictionary <String, float?> label = new Dictionary <string, float?>();

            label.Add("软件工程理论能力", scores[0]);
            label.Add("基本编程能力", scores[0]);
            label.Add("实践能力", scores[0]);
            label.Add("专业方向能力", scores[0]);
            return(label);
        }
Пример #4
0
        public ResultEntity correctAll(List <int?> scores, int?studentId, int?chapterId, String type)
        {
            ResultEntity resultEntity = new ResultEntity();

            if (studentId != null && chapterId != null && type != null)
            {
                int trueType = 0;
                int type1    = 0;
                int type2    = 0;
                if (type.Equals("preview"))
                {
                    trueType = 3;
                    type1    = 1;
                    type2    = 2;
                }
                else
                {
                    trueType = 6;
                    type1    = 4;
                    type2    = 5;
                }
                List <Exercise> exercises   = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, trueType);
                List <int?>     exerciseIds = new List <int?>();
                foreach (Exercise exercise in exercises)
                {
                    exerciseIds.Add(exercise.exerciseId);
                }
                StudentExerciseScore studentExerciseScore;
                for (int i = 0; i < scores.Count; i++)
                {
                    studentExerciseScore = StudentExerciseScoreApi.findByExerciseIdAndStudentId(exerciseIds[i], studentId);
                    studentExerciseScore.exerciseScore = scores[i].ToString();
                    studentExerciseScore.corrected     = 1;
                    StudentExerciseScoreApi.insert(studentExerciseScore);
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type1);
                foreach (Exercise exercise in exercises)
                {
                    exerciseIds.Add(exercise.exerciseId);
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type2);
                foreach (Exercise exercise in exercises)
                {
                    exerciseIds.Add(exercise.exerciseId);
                }
                int score = 0;
                foreach (int?exerciseId in exerciseIds)
                {
                    score += int.Parse(StudentExerciseScoreApi.findByExerciseIdAndStudentId(exerciseId, studentId).exerciseScore);
                }
                if (type.Equals("preview"))
                {
                    StudentChapter studentChapter = StudentChapterApi.findByChapterIDAndStudentID(chapterId, studentId);
                    studentChapter.totalScore_1 = score;
                    studentChapter.scored_1     = 1;
                    StudentChapterApi.insert(studentChapter);
                }
                else
                {
                    StudentChapter studentChapter = StudentChapterApi.findByChapterIDAndStudentID(chapterId, studentId);
                    studentChapter.totalScore_2 = score;
                    studentChapter.scored_2     = 1;
                    StudentChapterApi.insert(studentChapter);
                }
                resultEntity.setState(1);
                resultEntity.setMessage("批改成功 !");
            }
            else
            {
                resultEntity.setMessage("传入参数为空!");
                resultEntity.setState(0);
            }
            return(resultEntity);
        }
Пример #5
0
        public ResultEntity answerAll(List <String> answers, int?studentId, int?chapterId, String type, String comment, int?rate)
        {
            ResultEntity resultEntity = new ResultEntity();

            if (answers != null && type != null && chapterId != null && studentId != null)
            {
                List <ExerciseSet> exerciseSets = new List <ExerciseSet>();
                int type1 = 0;
                int type2 = 0;
                int type3 = 0;
                if (type.Equals("preview"))
                {
                    type1 = 1;
                    type3 = 2;
                    type2 = 3;
                }
                else
                {
                    type1 = 4;
                    type3 = 5;
                    type2 = 6;
                }
                List <int?>     exerciseIds = new List <int?>();
                List <Exercise> exercises   = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type1);
                foreach (Exercise exercise in exercises)
                {
                    exerciseSets.Add(new ExerciseSet(exercise, ExerciseChoiceApi.findByExerciseIdOrderByExerciceChoiceId(exercise.exerciseId)));
                    exerciseIds.Add(exercise.exerciseId);
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type3);
                foreach (Exercise exercise in exercises)
                {
                    exerciseSets.Add(new ExerciseSet(exercise, ExerciseChoiceApi.findByExerciseIdOrderByExerciceChoiceId(exercise.exerciseId)));
                    exerciseIds.Add(exercise.exerciseId);
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type2);
                foreach (Exercise exercise in exercises)
                {
                    exerciseSets.Add(new ExerciseSet(exercise));
                }
                for (int i = 0; i < answers.Count; i++)
                {
                    answerOne(answers[i], exerciseSets[i].getExercise().exerciseId, studentId);
                }
                int score = 0;
                foreach (int?exerciseId in exerciseIds)
                {
                    score += int.Parse(StudentExerciseScoreApi.findByExerciseIdAndStudentId(exerciseId, studentId).exerciseScore);
                }
                StudentChapter studentChapter;
                if (!StudentChapterApi.existsByChapterIDAndStudentID(chapterId, studentId))
                {
                    studentChapter           = new StudentChapter();
                    studentChapter.chapterID = chapterId;
                    studentChapter.studentID = studentId;
                    StudentChapterApi.insert(studentChapter);
                }
                if (!type.Equals("preview"))
                {
                    studentChapter              = StudentChapterApi.findByChapterIDAndStudentID(chapterId, studentId);
                    studentChapter.rate         = rate;
                    studentChapter.comment      = comment;
                    studentChapter.totalScore_2 = score;
                    studentChapter.scored_2     = 0;
                    StudentChapterApi.insert(studentChapter);
                    //LaterImplementation
                    //new NLPUtil().setCommentNLPRate(comment, chapterId, studentId);
                }
                else
                {
                    studentChapter = StudentChapterApi.findByChapterIDAndStudentID(chapterId, studentId);
                    studentChapter.totalScore_1 = score;
                    studentChapter.scored_1     = 0;
                    StudentChapterApi.insert(studentChapter);
                }
                resultEntity.setState(1);
                resultEntity.setMessage("答题成功 !");
            }
            else
            {
                resultEntity.setMessage("传入参数有空值!");
                resultEntity.setState(0);
            }
            return(resultEntity);
        }