Exemple #1
0
        public List <int?> exerciseScore(int?studentId, 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;
            }

            List <Exercise> exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type1);
            List <int?>     scores    = new List <int?>();

            foreach (Exercise exercise in exercises)
            {
                if (!StudentExerciseScoreApi.existsByExerciseIdAndStudentId(exercise.exerciseId, studentId))
                {
                    return(null);
                }
                scores.Add(int.Parse(StudentExerciseScoreApi.findByExerciseIdAndStudentId(exercise.exerciseId, studentId).exerciseScore));
            }
            exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type3);
            foreach (Exercise exercise in exercises)
            {
                scores.Add(int.Parse(StudentExerciseScoreApi.findByExerciseIdAndStudentId(exercise.exerciseId, studentId).exerciseScore));
            }
            exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type2);
            foreach (Exercise exercise in exercises)
            {
                if (StudentExerciseScoreApi.findByExerciseIdAndStudentId(exercise.exerciseId, studentId).corrected != 0)
                {
                    scores.Add(int.Parse(StudentExerciseScoreApi.findByExerciseIdAndStudentId(exercise.exerciseId, studentId).exerciseScore));
                }
            }
            return(scores);
        }
Exemple #2
0
        public ResultEntity viewSomeAnswer(int?chapterId, int?studentId, String type)
        {
            ResultEntity resultEntity = new ResultEntity();

            if (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;
                    type2 = 3;
                    type3 = 2;
                }
                else
                {
                    type1 = 4;
                    type2 = 6;
                    type3 = 5;
                }
                List <Exercise> exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type1);
                foreach (Exercise exercise in exercises)
                {
                    if (StudentExerciseScoreApi.existsByExerciseIdAndStudentId(exercise.exerciseId, studentId) == false)
                    {
                        resultEntity.setMessage("学生未答题!");
                        resultEntity.setState(0);
                        return(resultEntity);
                    }
                    exerciseSets.Add(new ExerciseSet(exercise, ExerciseChoiceApi.findByExerciseIdOrderByExerciceChoiceId(exercise.exerciseId), StudentExerciseScoreApi.findByExerciseIdAndStudentId(exercise.exerciseId, studentId).studentAnswer));
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type3);
                foreach (Exercise exercise in exercises)
                {
                    if (StudentExerciseScoreApi.existsByExerciseIdAndStudentId(exercise.exerciseId, studentId) == false)
                    {
                        resultEntity.setMessage("学生未答题!");
                        resultEntity.setState(0);
                        return(resultEntity);
                    }
                    exerciseSets.Add(new ExerciseSet(exercise, ExerciseChoiceApi.findByExerciseIdOrderByExerciceChoiceId(exercise.exerciseId), StudentExerciseScoreApi.findByExerciseIdAndStudentId(exercise.exerciseId, studentId).studentAnswer));
                }
                exercises = ExerciseApi.findByChapterIdAndExerciseTypeOrderByExerciseNumber(chapterId, type2);
                foreach (Exercise exercise in exercises)
                {
                    if (StudentExerciseScoreApi.existsByExerciseIdAndStudentId(exercise.exerciseId, studentId) == false)
                    {
                        resultEntity.setMessage("学生未答题!");
                        resultEntity.setState(0);
                        return(resultEntity);
                    }
                    exerciseSets.Add(new ExerciseSet(exercise, StudentExerciseScoreApi.findByExerciseIdAndStudentId(exercise.exerciseId, studentId).studentAnswer));
                }
                List <int?> scores = exerciseScore(studentId, chapterId, type);
                resultEntity.setData(new ExerciseSetsDetails(exerciseSets, scores));
                if (resultEntity.getData() != null)
                {
                    resultEntity.setState(1);
                    resultEntity.setMessage("查看成功!");
                }
                else
                {
                    resultEntity.setMessage("查看失败!");
                    resultEntity.setState(0);
                }
            }
            else
            {
                resultEntity.setMessage("传入参数为空!");
                resultEntity.setState(0);
            }
            return(resultEntity);
        }