Exemplo n.º 1
0
 public StudentChapterEntity(StudentChapter studentChapter, String chapterName)
 {
     this.studentChapter = studentChapter;
     this.chapterName    = chapterName;
 }
Exemplo n.º 2
0
        public string CreateReport()
        {
            sd.Value();
            Document doc = null;
            PdfWriter writer = null;
            const string filePath = "F://1/";
            const string fileName = "F:/1/Test.pdf";

            //try
            //{
                doc = new Document(PageSize.A4, 25, 25, 50, 40);//定义pdf大小,设置上下左右边距

                if (false == Directory.Exists(filePath))
                    Directory.CreateDirectory(filePath);
                if (File.Exists(fileName))
                    File.Delete(fileName);

                writer = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create));//生成pdf路径,创建文件流

                doc.Open();
                writer.PageEvent = new HeaderAndFooterEvent();

                HeaderAndFooterEvent.PageNumber = -1;
                First(doc, writer);
                doc.NewPage();

                var chapterOne = new StudentChapter();

                Header(doc, writer);//标头
                HeaderAndFooterEvent.PageNumber = 1;

                doc.Add(chapterOne.SectionOne(sd));
                doc.Add(ExamAnalysiseReportFormat.InsertBlankParagraph(3));
                doc.Add(chapterOne.SectionTwo(sd));
                doc.Add(ExamAnalysiseReportFormat.InsertBlankParagraph(3));
                doc.Add(chapterOne.SectionThree(sd));
                doc.Add(ExamAnalysiseReportFormat.InsertBlankParagraph(3));
                doc.Add(chapterOne.SectionFour(sd));
                doc.Add(ExamAnalysiseReportFormat.InsertBlankParagraph(3));
                doc.Add(chapterOne.SectionFive(sd));
                doc.Add(ExamAnalysiseReportFormat.InsertBlankParagraph(3));
                doc.Add(chapterOne.SectionSeven(sd));
                doc.Add(ExamAnalysiseReportFormat.InsertBlankParagraph(3));

                writer.Flush();
                writer.CloseStream = true;
                doc.Close();

                return fileName;
            //}
            //catch (Exception ex)
            //{
            //    if (doc != null && doc.IsOpen())
            //    {
            //        if (writer != null)
            //        {
            //            doc.Add(ExamAnalysiseReportFormat.InsertTitleContent("生成报表出错!"));
            //            writer.Flush();
            //            writer.CloseStream = true;
            //        }
            //        doc.Close();
            //    }
            //    //LogHelper.Error("CreateReport", ex);
            //    throw new Exception(ex.Message);
            //}
            //finally
            //{
            //    //手动回收垃圾
            //    GC.Collect();
            //    GC.WaitForFullGCComplete();
            //}
        }
Exemplo n.º 3
0
 public static int?update(StudentChapter studentChapter)
 {
     return(Global.db.Updateable(studentChapter).ExecuteCommand());
 }
Exemplo n.º 4
0
 public static int?insert(StudentChapter studentChapter)
 {
     return(studentChapter.id != null?Global.db.Saveable(studentChapter).ExecuteCommand() : Global.db.Insertable(studentChapter).ExecuteCommand());
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }