Beispiel #1
0
        public List <List <String> > getPrecourse(String courseName)
        {
            List <List <String> > preCourseSet = new List <List <String> >();

            if (!CourseNameApi.existsByCourseName(courseName))
            {
                return(null);
            }
            else
            {
                List <String> temp  = getPrecouseName(courseName);
                List <String> temp1 = new List <String>();
                List <String> temp2 = new List <String>();
                preCourseSet.Add(temp);
                foreach (String i in temp)
                {
                    temp1 = getPrecouseName(i);
                    foreach (String j in temp1)
                    {
                        if (!temp2.Contains(j))
                        {
                            temp2.Add(j);
                        }
                    }
                }
                preCourseSet.Add(temp2);
            }
            return(preCourseSet);
        }
Beispiel #2
0
        public List <String> getCoursesName(List <CourseRelation> courseRelations)
        {
            List <String> temp = new List <String>();

            foreach (CourseRelation courseRelation in courseRelations)
            {
                temp.Add(CourseNameApi.findByCourseNameID(courseRelation.preCourseNameID).courseName);
            }
            return(temp);
        }
Beispiel #3
0
 public List <String> getPrecouseName(String courseName)
 {
     if (!CourseNameApi.existsByCourseName(courseName))
     {
         return(null);
     }
     else
     {
         int?couseId = CourseNameApi.findByCourseName(courseName).courseNameID;
         List <CourseRelation> courseRelations = CourseRelationApi.findByCourseNameID(couseId);
         return(getCoursesName(courseRelations));
     }
 }
Beispiel #4
0
 public String getCourseName(int courseId)
 {
     //fragile
     return(CourseNameApi.findByCourseNameID(int.Parse(CourseInfoApi.findByCourseID(courseId).courseName)).courseName);
 }
Beispiel #5
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);
        }
Beispiel #6
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);
        }