Ejemplo n.º 1
0
        public void setTotalScore(int?chapterId, String type)
        {
            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;
            }
            //fragile
            List <Exercise> exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type1);
            List <Exercise> temp      = new List <Exercise>();

            temp.AddRange(exercises);
            exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type3);
            temp.AddRange(exercises);
            exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type2);
            temp.AddRange(exercises);
            int?total = 0;

            foreach (Exercise exercise in temp)
            {
                total += exercise.exercisePoint;
            }
            if (type.Equals("preview"))
            {
                //fragile
                ChapterNode chapterNode = ChapterContentApi.getByID(chapterId);
                chapterNode.exerciseTotal_1 = total;
                ChapterContentApi.insert(chapterNode);
            }
            else
            {
                ChapterNode chapterNode = ChapterContentApi.getByID(chapterId);
                chapterNode.exerciseTotal_2 = total;
                ChapterContentApi.insert(chapterNode);
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public ResultEntity viewExercise(int?chapterId, String type)
        {
            ResultEntity resultEntity = new ResultEntity();

            if (chapterId != 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 <Exercise> exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type1);
                foreach (Exercise exercise in exercises)
                {
                    exerciseSets.Add(new ExerciseSet(exercise, ExerciseChoiceApi.findByExerciseIdOrderByExerciceChoiceId(exercise.exerciseId)));
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type3);
                foreach (Exercise exercise in exercises)
                {
                    exerciseSets.Add(new ExerciseSet(exercise, ExerciseChoiceApi.findByExerciseIdOrderByExerciceChoiceId(exercise.exerciseId)));
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type2);
                foreach (Exercise exercise in exercises)
                {
                    exerciseSets.Add(new ExerciseSet(exercise));
                }
                resultEntity.setData(exerciseSets);
                if (resultEntity.getData() != null)
                {
                    if (type.Equals("preview"))
                    {
                        //fragile
                        if (ChapterContentApi.getByID(chapterId).exerciseVisible_1 != null && ChapterContentApi.getByID(chapterId).exerciseVisible_1)
                        {
                            DateTime now = DateTime.Now;
                            if (ChapterContentApi.getByID(chapterId).exerciseDeadline_1 != null && now > ChapterContentApi.getByID(chapterId).exerciseDeadline_1)
                            {
                                resultEntity.setState(4);
                                resultEntity.setMessage("习题已过deadline!");
                            }
                            else
                            {
                                resultEntity.setState(1);
                                resultEntity.setMessage("查看成功!");
                            }
                        }
                        else
                        {
                            resultEntity.setState(2);
                            resultEntity.setMessage("习题当前设置为不可见!");
                        }
                    }
                    else
                    {
                        if (ChapterContentApi.getByID(chapterId).exerciseDeadline_2 != null && ChapterContentApi.getByID(chapterId).exerciseVisible_2)
                        {
                            DateTime now = DateTime.Now;
                            if (ChapterContentApi.getByID(chapterId).exerciseDeadline_2 != null && now > ChapterContentApi.getByID(chapterId).exerciseDeadline_2)
                            {
                                resultEntity.setState(4);
                                resultEntity.setMessage("习题已过deadline!");
                            }
                            else
                            {
                                resultEntity.setState(1);
                                resultEntity.setMessage("查看成功!");
                            }
                        }
                        else
                        {
                            resultEntity.setState(2);
                            resultEntity.setMessage("习题当前设置为不可见!");
                        }
                    }
                }
                else
                {
                    resultEntity.setMessage("无题目!");
                    resultEntity.setState(3);
                }
            }
            else
            {
                resultEntity.setMessage("传入参数为空!");
                resultEntity.setState(0);
            }
            return(resultEntity);
        }