Exemple #1
0
        /*public List<UnratedChapter> getUnratedChapters(int classId)
         *  {
         *      List<UserInfo> userInfos = CourseService.getStudentsByClassID(classId);
         *      List<ChapterNode> chapterNodes = ChapterContentApi.findByCourseID(CourseClassApi.getByID(classId).courseID);
         *      List<ChapterNode> chapterNodeList = new List<ChapterNode>();
         *      foreach (ChapterNode chapterNode in chapterNodes)
         *      {
         *          if (chapterNode.exerciseTitle != null)
         *              chapterNodeList.Add(chapterNode);
         *      }
         *      List<UnratedChapter> unratedChapters = new List<UnratedChapter>();
         *      foreach (ChapterNode chapterNode in chapterNodeList)
         *      {
         *          foreach (UserInfo userInfo in userInfos)
         *          {
         *              StudentChapter studentChapter = StudentChapterApi.findByChapterIDAndStudentID(chapterNode.id, userInfo.userID);
         *              if (studentChapter != null)
         *              {
         *                  int? temp = studentChapter.scored_2;
         *                  if (temp != null)
         *                  {
         *                      if (temp == 0)
         *                      {
         *                          unratedChapters.Add(new UnratedChapter(chapterNode, userInfo.userID));
         *                          break;
         *                      }
         *                  }
         *              }
         *          }
         *      }
         *      return unratedChapters;
         *  }
         *
         */

        public List <CourseAndClassList> currentCourseByTeacherId(int teacherId)
        {
            //fragile
            int month = DateTime.Now.Month + 1;
            int year  = DateTime.Now.Year;

            if (month <= 2)
            {
                year--;
            }
            String semester = "";

            if (month >= 3 && month <= 8)
            {
                semester = "春季";
            }
            else
            {
                semester = "秋季";
            }
            List <CourseInfo>         courseInfos         = CourseInfoApi.findByTeacherIDAndCourseYearAndCourseSemester(teacherId, year, semester);
            List <CourseAndClassList> courseAndClassLists = new List <CourseAndClassList>();

            foreach (CourseInfo courseInfo in courseInfos)
            {
                courseAndClassLists.Add(new CourseAndClassList(courseInfo, CourseClassApi.findByCourseID(courseInfo.courseID), CourseNameApi.findByCourseNameID(int.Parse(courseInfo.courseName)).courseName));
            }
            return(courseAndClassLists);
        }
Exemple #2
0
        public List <CourseAndClassList> currentCourseByStudentId(int studentId)
        {
            //fragile
            int month = DateTime.Now.Month + 1;
            int year  = DateTime.Now.Year;

            if (month <= 2)
            {
                year--;
            }
            String semester = "";

            if (month >= 3 && month <= 8)
            {
                semester = "春季";
            }
            else
            {
                semester = "秋季";
            }
            List <Takes>       takesList     = TakesApi.findByStudentID(studentId);
            List <CourseClass> courseClasses = new List <CourseClass>();

            foreach (Takes takes in takesList)
            {
                courseClasses.Add(CourseClassApi.getByID(takes.courseClassID));
            }
            List <CourseAndClassList> courseAndClassLists = new List <CourseAndClassList>();

            foreach (CourseClass courseClass in courseClasses)
            {
                CourseInfo courseInfo = CourseInfoApi.findByCourseID(courseClass.courseID);
                if (courseInfo.courseYear.Equals(year) && courseInfo.courseSemester.Equals(semester))
                {
                    courseAndClassLists.Add(new CourseAndClassList(courseInfo, courseClass, CourseNameApi.findByCourseNameID(int.Parse(courseInfo.courseName)).courseName));
                }
            }
            return(courseAndClassLists);
        }
Exemple #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);
        }