Exemple #1
0
        public ActionResult CreateSections([Bind(Include = "CourseName,Category,Totalpoints,CourseSummary,TotalSections")] Course course)
        {    //string CName, string CCategory, string totPoints,string CSummary,int TotalSec)
            ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
            //ApplicationUser user = new ApplicationUser();
            string uname      = user.UserName;
            string coursePath = "~/Content/CourseContents/" + uname.Replace('@', '-');

            Directory.CreateDirectory(Server.MapPath(coursePath));
            ViewBag.sectionsTobeAdded = course.TotalSections;
            ViewBag.totSec            = course.TotalSections;
            TempData["totSec"]        = (int)course.TotalSections;
            TempData["totLec"]        = 0;
            course.TotalSections      = 0;
            course.TotalLectures      = "0";
            course.ProgressTracker    = "";
            //ViewBag.sectionsTobeAdded = TotalSec;
            //TempData["totSec"] = TotalSec;
            course.InstructorID    = user.Id;
            course.UploadedDate    = DateTime.Today;
            course.CoursePath      = coursePath;
            course.ProgressTracker = "";
            //Course course = new Course()
            //{
            //    CourseName = CName,
            //    InstructorID = user.Id,
            //    CoursePath = coursePath,
            //    Category = CCategory,
            //    UploadedDate = DateTime.Today,
            //    Totalpoints = totPoints,
            //    CourseSummary = CSummary,
            //    TotalSections = TotalSec

            //};

            if (ModelState.IsValid)
            {
                int existingCourseName = db.Course.Where(c => c.CourseName == course.CourseName).ToList().Count;
                if (existingCourseName != 0)
                {
                    TempData["error"] = "The courseName already exists, please choose different course Name";
                    return(RedirectToAction("Create"));
                }
                db.Course.Add(course);

                db.SaveChanges();

                coursePath = coursePath + "/" + course.CourseID;
                Directory.CreateDirectory(Server.MapPath(coursePath));
                course.CoursePath      = coursePath;
                db.Entry(course).State = EntityState.Modified;
                db.SaveChanges();
            }

            TempData["course"] = course;

            return(View());
        }
Exemple #2
0
        public ActionResult StudentsEnrollmentStatus(string CourseID, string[] StudentIDList)
        {
            Course course = db.Course.Find(Convert.ToInt32(CourseID));
            // Course course= adminView.courseList[0];
            EnrollmentStatus Estatus = new EnrollmentStatus()
            {
                courseName   = course.CourseName,
                studentEmail = new List <string>(),
                status       = new List <string>()
            };

            //[Bind(Include = "EnrollmentID,CourseID,StudentID,EnrollmentDate,Progress,pointsEarned")] Enrollment enrollment)
            foreach (string sid in StudentIDList)//adminView.studentList)
            {
                Enrollment courseEnrollment = new Enrollment()
                {
                    EnrollmentDate  = DateTime.Today,
                    StudentID       = sid,
                    CourseID        = course.CourseID,
                    pointsEarned    = 0,
                    Progress        = 0,
                    ProgressTracker = ""
                };
                Student s = db.Students.Find(sid);
                Estatus.studentEmail.Add(s.Email);

                var check = (from e in db.Enrollments
                             where e.CourseID == course.CourseID && e.StudentID == sid
                             select e).ToList();
                if (check.Count == 0)
                {
                    db.Enrollments.Add(courseEnrollment);
                    db.SaveChanges();
                    Estatus.status.Add("Sucess");
                }
                else
                {
                    Estatus.status.Add("Already Enrolled");
                }
            }
            return(View(Estatus));
        }
        // GET: Notes/Create
        public ActionResult Add(string notes, int EnrollmentID, int courseID, int secNum, int LecNum, string lecpath)
        {
            OnlineCoursePortalContext db = new OnlineCoursePortalContext();
            Notes note = new Notes
            {
                AddedNotes     = notes,
                EnrollmentID   = EnrollmentID,
                LastEditDate   = DateTime.Today,
                NotesAddedDate = DateTime.Today,
                LecturePath    = lecpath
            };

            db.Notes.Add(note);
            db.SaveChanges();
            return(RedirectToAction("Details", "Enrollments", new { Cid = courseID, sectionNum = secNum, LectureNum = LecNum }));
        }