Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(DateTime.Now.ToShortDateString());
            Course_elearnDAO cdao   = new Course_elearnDAO();
            string           id_str = null;

            if (Request.QueryString["id"] != null)
            {
                id_str = Request.QueryString["id"];
                int id_num = int.Parse(id_str);
                current = cdao.get_course_by_id(id_num);
                TestimonialDAO t = new TestimonialDAO();
                testimonials = t.get_testimonials_by_course(current);
            }
            else
            {
                return;
            }

            if (!IsPostBack)
            {
                int id_num = int.Parse(id_str);
                current = cdao.get_course_by_id(id_num);
                lblCourseNameHeader.Text     = current.getCourseName();
                lblBreadcrumbCourseName.Text = current.getCourseName();
                lblCourseName.Text           = current.getCourseName();
                lblCourseDescription.Text    = current.getDescription();
                hoursOutput.Text             = current.getHoursAwarded().ToString();
                if (!current.getTargetAudience().Equals(""))
                {
                    lblTargetAudience.Text = current.getTargetAudience();
                }
                else
                {
                    lblTargetAudience.Text = "-";
                }
                lblCoursePeriodStart.Text = "Start: " + current.getStartDate().ToLongDateString();
                lblCoursePeriodEnd.Text   = "End: " + current.getExpiryDate().ToLongDateString();
                DateTime currentDateTime = DateTime.Now;

                if (current.getStatus().Equals("Inactive") || !(DateTime.Compare(current.getStartDate(), currentDateTime) < 0 && DateTime.Compare(current.getExpiryDate(), currentDateTime) > 0))
                {
                    panelInactive.Visible = true;
                }
                Page.Form.Attributes.Add("enctype", "multipart/form-data");
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        public Course_elearn create_elearnCourse(Course_elearn course)
        {
            SqlConnection conn     = new SqlConnection();
            Course_elearn toReturn = null;

            try
            {
                conn = new SqlConnection();
                string connstr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
                conn.ConnectionString = connstr;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "insert into [Elearn_course] " +
                                   "(elearn_courseName, elearn_courseProvider, entry_date, start_date, expiry_date, status, description, categoryID, courseCreator, hoursAwarded, targetAudience, courseType) OUTPUT INSERTED.elearn_courseID " +
                                   "values (@cName, @provider, Convert(datetime, @entry, 103), convert(datetime,@time,103), Convert(datetime,@expiry,103), @status, @desc, @category, @courseCreator, @hoursAwarded, @targetAudience, @courseType)";
                comm.Parameters.AddWithValue("@cName", course.getCourseName());
                if (course.getCourseProvider() != null)
                {
                    comm.Parameters.AddWithValue("@provider", course.getCourseProvider());
                }
                else
                {
                    comm.Parameters.AddWithValue("@provider", DBNull.Value);
                }

                comm.Parameters.AddWithValue("@entry", course.getEntryDate());
                if (course.getStartDate() == null)
                {
                    comm.Parameters.AddWithValue("@time", DBNull.Value);
                }
                else
                {
                    comm.Parameters.AddWithValue("@time", course.getStartDate());
                }
                if (course.getExpiryDate() == null)
                {
                    comm.Parameters.AddWithValue("@expiry", DBNull.Value);
                }
                else
                {
                    comm.Parameters.AddWithValue("@expiry", course.getExpiryDate());
                }
                comm.Parameters.AddWithValue("@status", course.getStatus());
                comm.Parameters.AddWithValue("@desc", course.getDescription());
                comm.Parameters.AddWithValue("@category", course.getCategoryID());
                comm.Parameters.AddWithValue("@courseCreator", course.getCourseCreator().getUserID());
                comm.Parameters.AddWithValue("@hoursAwarded", course.getHoursAwarded());
                comm.Parameters.AddWithValue("@targetAudience", course.getTargetAudience());
                comm.Parameters.AddWithValue("@courseType", course.getCourseType());
                int a = (Int32)comm.ExecuteScalar();
                //need new method to create pre-requisities here to store in seperate table (pre-req table)
                course.setCourseID(a);
                toReturn = course;
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(toReturn);
        }