コード例 #1
0
ファイル: quiz.aspx.cs プロジェクト: eugenetan2015/PlusMinus
        protected Boolean checkIfCompletedAllPrerequisite(string userID, int quizID)
        {
            QuizDAO          quizDAO       = new QuizDAO();
            QuizResultDAO    qrDAO         = new QuizResultDAO();
            Course_elearnDAO ceDAO         = new Course_elearnDAO();
            Quiz             currentQuiz   = quizDAO.getQuizByID(quizID);
            Course_elearn    currentCourse = currentQuiz.getMainCourse();

            //check user completed all prereq course's quizzes
            ArrayList allPrereqCourses = ceDAO.getPrereqOfCourse(currentCourse.getCourseID());

            if (allPrereqCourses.Count > 0)
            {
                foreach (Course_elearn ce in allPrereqCourses)
                {
                    if (ce.getStatus().Equals("active") && (ce.getStartDate() <= DateTime.Now.Date && ce.getExpiryDate() >= DateTime.Now.Date))
                    {
                        List <Quiz> allQuizzes = quizDAO.getAllQuizByCourseID(ce.getCourseID());
                        foreach (Quiz innerQuiz in allQuizzes)
                        {
                            if (!qrDAO.getQuizResultByUserIDandQuizID(userID, innerQuiz.getQuizID()))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            //if all prereq courses cleared, to check current quiz's prereqs
            ArrayList allPrerequisites = quizDAO.getPrereqOfQuiz(quizID);

            foreach (Quiz prereq in allPrerequisites)
            {
                if (currentCourse.getStatus().Equals("active") && (currentCourse.getStartDate() <= DateTime.Now.Date && currentCourse.getExpiryDate() >= DateTime.Now.Date))
                {
                    if (!qrDAO.getQuizResultByUserIDandQuizID(userID, prereq.getQuizID()))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        protected ArrayList getAllPrerequisites(int courseID)
        {
            ArrayList        toReturn      = new ArrayList();
            Course_elearnDAO ceDAO         = new Course_elearnDAO();
            ArrayList        coursePrereqs = ceDAO.getPrereqOfCourse(courseID);

            foreach (Course_elearn prerequisite in coursePrereqs)
            {
                toReturn.Add(prerequisite.getCourseID());
                ArrayList morePrereq = getAllPrerequisites(prerequisite.getCourseID());
                if (morePrereq.Count > 0)
                {
                    foreach (int prerequisitesID in morePrereq)
                    {
                        toReturn.Add(prerequisitesID);
                    }
                }
            }
            return(toReturn);
        }