/// <summary>
 /// What happens when the user clicks the View Previous button.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ViewPreviousBtn_Click(object sender, EventArgs e)
 {
     PreviousCourseView.Show();
     EnrolledCourseView.Hide();
     EnrolledCourseView.Refresh();
     PreviousCourseView.Refresh();
 }
        /// <summary>
        /// Used to reset the view to the default state
        /// </summary>
        public void ResetToDefault()
        {
            EnrolledCourseView.Show();
            PreviousCourseView.Hide();

            List <Course> courses = HttpRequester.Default.GetEnrolledCourses();

            EnrolledCourseView.SetCourses(courses);

            List <PreviousCourse> pCourses = HttpRequester.Default.GetPreviousCourses();

            PreviousCourseView.SetCourses(pCourses);

            CourseNameTxt.Text       = "";
            PreviousCourseIdTxt.Text = "";
            CreditsUpDown.Value      = 3;
        }
 /// <summary>
 /// What happens when the previous course list. Forwards click to the EnrolledCourseView.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EnrolledCourseView_Click(object sender, EventArgs e)
 {
     EnrolledCourseView.OnClickEvent(e);
 }
Exemple #4
0
        public ActionResult Details(int Cid, int sectionNum, int LectureNum)
        {
            string fromEnroll = (string)TempData["messageEnrollSucess"];

            if (fromEnroll == null)
            {
                ViewBag.message = "";
            }
            else if (fromEnroll.CompareTo("Sucess") == 0)
            {
                ViewBag.message = "Sucessfully Enrolled";
            }
            else if (fromEnroll.CompareTo("failure") == 0)
            {
                ViewBag.message = "You have already Enrolled";
            }
            var userId = User.Identity.GetUserId();

            /*Enrollment enroll = (Enrollment) (from e in db.Enrollments
             *           where e.CourseID == id && e.StudentID == userId
             *           select new Enrollment { EnrollmentID=e.EnrollmentID,
             *           CourseID=e.CourseID,
             *           StudentID=e.StudentID,
             *           EnrollmentDate=e.EnrollmentDate,
             *           Progress=e.Progress,
             *           pointsEarned=e.pointsEarned});*/
            Enrollment enroll = db.Enrollments
                                .Where(i => i.StudentID == userId)
                                .Where(i => i.CourseID == Cid).Single();
            var reminders = (from r in db.Reminders
                             where r.EnrollmentID == enroll.EnrollmentID
                             select r).ToList();
            Course     course     = db.Course.Find(Cid);
            Instructor instructor = db.Instructors.Find(course.InstructorID);
            string     userName   = instructor.Email;
            //get number of lectures in each section and section names
            ArrayList LecCount     = new ArrayList();
            ArrayList sectionNames = new ArrayList();

            for (int i = 1; i <= course.TotalSections; i++)
            {
                string        sPath       = course.CoursePath + "/section" + i;
                DirectoryInfo dInfo       = new DirectoryInfo(Server.MapPath(sPath));
                var           str         = dInfo.GetDirectories();
                int           totLectures = str.Count();
                //get count of lectures in each section
                LecCount.Add(totLectures);
                var secName = System.IO.File.ReadAllText(Server.MapPath(sPath) + @"/SectionName.txt");
                sectionNames.Add((string)secName);
            }
            string path    = course.CoursePath;
            string secPath = path + "/section" + sectionNum;
            //get section Name from "secPath"+/SectionName.txt

            string LecPath = secPath + "/Lecture" + LectureNum;
            var    notes   = (from n in db.Notes
                              where n.EnrollmentID == enroll.EnrollmentID && n.LecturePath == LecPath
                              select n).ToList();
            //get list of filenames in the LecturePath
            //check for video file withname "Lecture"+LectureNum
            string        LecVideo = "";
            DirectoryInfo dirInfo  = new DirectoryInfo(Server.MapPath(LecPath));

            foreach (FileInfo l in dirInfo.GetFiles("Lecture" + LectureNum + ".*"))
            {
                LecVideo = LecPath + "/" + l.Name;
            }
            //check for additional document with name "AddDoc"+LectureNum
            //temp
            string AddDoc = "";

            try {
                foreach (FileInfo l in dirInfo.GetFiles("AddDoc" + LectureNum + ".*"))
                {
                    ViewBag.AddDoc = "true";
                    AddDoc         = LecPath + "/" + l.Name;
                }
            }
            catch (DirectoryNotFoundException e)
            {
                ViewBag.AddDoc = "false";
            }


            //get lecture description from file "LectureDesc"+ LectureNum+".txt"

            var lecDesc = System.IO.File.ReadAllText(Server.MapPath(LecPath) + @"/LectureDesc" + LectureNum + ".txt");

            ArrayList quizSecs = new ArrayList((from q in db.Quiz
                                                where q.CourseID == Cid
                                                orderby q.sectionNum
                                                select q.sectionNum).Distinct().ToList());

            EnrolledCourseView courseView = new EnrolledCourseView
            {
                enrollment        = enroll,
                course            = course,
                QuizSecNums       = quizSecs,
                notes             = notes,
                reminders         = reminders,
                LectureVideoPath  = LecVideo,
                AddDocPath        = AddDoc,
                LectureDesc       = (string)lecDesc,
                LecturesInSection = LecCount,
                sectionNames      = sectionNames,
                sectionNum        = sectionNum,
                lecNum            = LectureNum
            };

            return(View(courseView));
        }