public ActionResult UpdateStudentLessonTracking(int LessonId)
        {
            var UserId = User.Identity.GetUserId();
            StudentLessonTracking LessonTracking = db.StudentLessonTrackings.Where(x => x.LessonId == LessonId && x.StudentId == UserId).FirstOrDefault();

            if (LessonTracking == null)
            {
                StudentLessonTracking lessonTracking = new StudentLessonTracking();

                lessonTracking.LessonId    = LessonId;
                lessonTracking.IsCompleted = true;

                TimeZone time2        = TimeZone.CurrentTimeZone;
                DateTime test         = time2.ToUniversalTime(DateTime.Now);
                var      pakistan     = TimeZoneInfo.FindSystemTimeZoneById("Pakistan Standard Time");
                DateTime pakistantime = TimeZoneInfo.ConvertTimeFromUtc(test, pakistan);
                lessonTracking.StartDate         = pakistantime;
                lessonTracking.StudentId         = User.Identity.GetUserId();
                lessonTracking.Assignment_Status = "Pending";

                db.StudentLessonTrackings.Add(lessonTracking);
                db.SaveChanges();
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult TeacherCommentsMethod(int id, string TeacherComments)

        {
            AspnetStudentAssignmentSubmission assignmentSubmission = db.AspnetStudentAssignmentSubmissions.Where(x => x.Id == id).FirstOrDefault();

            assignmentSubmission.TeacherComments = TeacherComments;
            db.SaveChanges();


            int?LessonId  = assignmentSubmission.LessonId;
            int?StudentId = assignmentSubmission.StudentId;

            var StudentIdInString = db.AspNetStudents.Where(x => x.Id == StudentId).FirstOrDefault().StudentID;

            StudentLessonTracking LessonTracking = db.StudentLessonTrackings.Where(x => x.LessonId == LessonId && x.StudentId == StudentIdInString).FirstOrDefault();

            if (LessonTracking != null)
            {
                LessonTracking.Assignment_Status = "Approved";
                db.SaveChanges();
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
        public ActionResult StudentAssignmentSubmission(int LessonID)
        {
            var IsSubmitted = "";
            var UserId1     = User.Identity.GetUserId();

            AspNetStudent Student = db.AspNetStudents.Where(x => x.StudentID == UserId1).FirstOrDefault();

            AspnetStudentAssignmentSubmission StudentAssignmentSubmission = db.AspnetStudentAssignmentSubmissions.Where(x => x.LessonId == LessonID && x.StudentId == Student.Id).FirstOrDefault();

            if (StudentAssignmentSubmission == null)
            {
                IsSubmitted = "Submit Assignment Successfully";

                var File = Request.Files["file"];

                var fileName = "";
                if (File.ContentLength > 0)
                {
                    fileName = Path.GetFileName(File.FileName);
                    File.SaveAs(Server.MapPath("~/Content/StudentAssignments/") + fileName);
                }

                AspnetStudentAssignmentSubmission AssignmentSubmission = new AspnetStudentAssignmentSubmission();

                int?TopicId   = db.AspnetLessons.Where(x => x.Id == LessonID).FirstOrDefault().TopicId;
                int?SubjectId = db.AspnetSubjectTopics.Where(x => x.Id == TopicId).FirstOrDefault().SubjectId;

                //  db.AspnetSubjectTopics.Where(x => x.Id == LessonID);

                var Subject = db.GenericSubjects.Where(x => x.Id == SubjectId).FirstOrDefault();

                var id     = User.Identity.GetUserId();
                var UserId = db.AspNetUsers.Where(x => x.Id == id).FirstOrDefault().Id;

                int StudentId = db.AspNetStudents.Where(x => x.StudentID == UserId).FirstOrDefault().Id;
                int?ClassId   = db.AspNetStudents.Where(x => x.StudentID == UserId).FirstOrDefault().ClassID;

                var AssignmentDueDate = db.AspnetStudentAssignments.Where(x => x.LessonId == LessonID).FirstOrDefault().DueDate;


                TimeZone time2    = TimeZone.CurrentTimeZone;
                DateTime test     = time2.ToUniversalTime(DateTime.Now);
                var      pakistan = TimeZoneInfo.FindSystemTimeZoneById("Pakistan Standard Time");


                DateTime pakistantime = TimeZoneInfo.ConvertTimeFromUtc(test, pakistan);
                AssignmentSubmission.LessonId   = LessonID;
                AssignmentSubmission.TopicId    = TopicId;
                AssignmentSubmission.SubjectId  = SubjectId;
                AssignmentSubmission.ClassId    = ClassId;
                AssignmentSubmission.CourseType = Subject.SubjectType;
                AssignmentSubmission.StudentId  = StudentId;
                AssignmentSubmission.AssignmentSubmittedDate = pakistantime;
                AssignmentSubmission.AssignmentDueDate       = AssignmentDueDate;
                AssignmentSubmission.AssignmentFileName      = fileName;

                db.AspnetStudentAssignmentSubmissions.Add(AssignmentSubmission);
                db.SaveChanges();
            }
            else
            {
                IsSubmitted = "Submit Assignment failed, you have already Submited Assignment";
            }


            StudentLessonTracking LessonTracking = db.StudentLessonTrackings.Where(x => x.LessonId == LessonID && x.StudentId == UserId1).FirstOrDefault();

            if (LessonTracking != null)
            {
                LessonTracking.Assignment_Status = "Submitted";
                db.SaveChanges();
            }


            return(Json(IsSubmitted, JsonRequestBehavior.AllowGet));
        }// Student Assignment Submission
        public ActionResult GetCourseContent(int LessonID)
        {
            var UserId = User.Identity.GetUserId();

            var TopicId   = db.AspnetLessons.Where(x => x.Id == LessonID).FirstOrDefault().TopicId;
            var SubjectId = db.AspnetSubjectTopics.Where(x => x.Id == TopicId).FirstOrDefault().SubjectId;

            var SubjectsTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList();

            List <Topic> TopicListObj = new List <Topic>();

            int Count = 0;

            foreach (var a in SubjectsTopics)
            {
                int   count1   = 0;
                Topic TopicObj = new Topic();

                //var list = db.AspnetLessons.Where(x => x.TopicId == a.Id).ToList();

                var UserId1 = User.Identity.GetUserId();

                var userSessionId = db.AspNetUsers_Session.Where(x => x.UserID == UserId1).FirstOrDefault().SessionID;


                TopicObj.TopicId   = a.Id;
                TopicObj.TopicName = a.Name;


                var today = DateTime.Today;

                var LessonList = (from Lesson in db.AspnetLessons
                                  join LessonSession in db.Lesson_Session on Lesson.Id equals LessonSession.LessonId
                                  where Lesson.TopicId == a.Id && Lesson.IsActive == true && LessonSession.SessionId == userSessionId && LessonSession.StartDate <= today && today <= LessonSession.DueDate
                                  select Lesson).ToList();

                List <Lesson> LessonsList = new List <Lesson>();

                foreach (var lesson in LessonList)
                {
                    var LessonExist = "";
                    StudentLessonTracking LessonTracking = db.StudentLessonTrackings.Where(x => x.LessonId == lesson.Id && x.StudentId == UserId).FirstOrDefault();

                    if (LessonTracking == null)
                    {
                        LessonExist = "No";
                    }
                    else
                    {
                        LessonExist = "Yes";
                    }

                    Lesson lessonobj = new Lesson();
                    lessonobj.LessonId                   = lesson.Id;
                    lessonobj.LessonName                 = lesson.Name;
                    lessonobj.LessonDuration             = lesson.Duration;
                    lessonobj.LessonExistInTrackingTable = LessonExist;

                    LessonsList.Add(lessonobj);
                    Count++;
                    count1++;
                }

                List <Lesson> OrderByLessons = LessonsList.OrderBy(x => x.LessonName).ToList();

                TopicObj.LessonList = OrderByLessons;

                TopicObj.TotalLessons  = Count;
                TopicObj.TotalLessons1 = count1;

                TopicListObj.Add(TopicObj);
            }

            // return Json(TopicListObj, JsonRequestBehavior.AllowGet);

            return(Json(TopicListObj.OrderBy(x => x.TopicName).ToList(), JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetSubjectTopicsAndLessons(int SubjectId)
        {
            try
            {
                var UserId = User.Identity.GetUserId();

                var userSessionId = db.AspNetUsers_Session.Where(x => x.UserID == UserId).FirstOrDefault().SessionID;



                //  var SubjectTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList();


                //var AllSubjectTopicsLessons = from SubjectTopic in db.AspnetSubjectTopics
                //                              join Lesson in db.AspnetLessons on SubjectTopic.Id equals Lesson.TopicId
                //                              where SubjectTopic.SubjectId == SubjectId
                //                              select new
                //                              {
                //                                  TopicId = SubjectTopic.Id,
                //                                  TopicName =   SubjectTopic.Name,
                //                                  LessonId = Lesson.Id,
                //                                  LessonName = Lesson.Name,
                //                                  Lesson.Duration,
                //                                  Lesson.Description

                //                              };

                var SubjectsTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList();



                List <Topic> TopicListObj = new List <Topic>();

                int Count = 0;
                foreach (var a in SubjectsTopics)
                {
                    int   count1   = 0;
                    Topic TopicObj = new Topic();

                    //  var list = db.AspnetLessons.Where(x => x.TopicId == a.Id).Where(x=>x.IsActive== true).ToList();



                    var today      = DateTime.Today;
                    var LessonList = (from Lesson in db.AspnetLessons
                                      join LessonSession in db.Lesson_Session on Lesson.Id equals LessonSession.LessonId
                                      where Lesson.TopicId == a.Id && Lesson.IsActive == true && LessonSession.SessionId == userSessionId && LessonSession.StartDate <= today && today <= LessonSession.DueDate
                                      select Lesson).ToList();


                    TopicObj.TopicId   = a.Id;
                    TopicObj.TopicName = a.Name;



                    List <Lesson> LessonsList = new List <Lesson>();


                    foreach (var lesson in LessonList)
                    {
                        var LessonExist = "";
                        StudentLessonTracking LessonTracking = db.StudentLessonTrackings.Where(x => x.LessonId == lesson.Id & x.StudentId == UserId).FirstOrDefault();

                        if (LessonTracking == null)
                        {
                            LessonExist = "No";
                        }
                        else
                        {
                            LessonExist = "Yes";
                        }
                        Lesson lessonobj = new Lesson();
                        lessonobj.LessonId                   = lesson.Id;
                        lessonobj.LessonName                 = lesson.Name;
                        lessonobj.LessonDuration             = lesson.Duration;
                        lessonobj.LessonExistInTrackingTable = LessonExist;
                        lessonobj.EncryptedID                = lesson.EncryptedID;
                        LessonsList.Add(lessonobj);
                        Count++;
                        count1++;
                    }

                    List <Lesson> OrderByLessons = LessonsList.OrderBy(x => x.LessonName).ToList();

                    TopicObj.LessonList = OrderByLessons;

                    TopicObj.TotalLessons  = Count;
                    TopicObj.TotalLessons1 = count1;

                    TopicListObj.Add(TopicObj);
                }
                return(Json(TopicListObj.OrderBy(x => x.TopicName).ToList(), JsonRequestBehavior.AllowGet));
            }

            catch (Exception ex)
            {
                var a = ex.Message;
            }


            return(Json("", JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetCourseContent(int LessonID)
        {
            var UserId = User.Identity.GetUserId();

            var TopicId   = db.AspnetLessons.Where(x => x.Id == LessonID).FirstOrDefault().TopicId;
            var SubjectId = db.AspnetSubjectTopics.Where(x => x.Id == TopicId).FirstOrDefault().SubjectId;

            var SubjectsTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList();

            List <Topic> TopicListObj = new List <Topic>();

            int Count = 0;

            foreach (var a in SubjectsTopics)
            {
                int   count1   = 0;
                Topic TopicObj = new Topic();

                var list = db.AspnetLessons.Where(x => x.TopicId == a.Id).ToList();

                TopicObj.TopicId   = a.Id;
                TopicObj.TopicName = a.Name;

                List <Lesson> LessonsList = new List <Lesson>();

                foreach (var lesson in list)
                {
                    var LessonExist = "";
                    StudentLessonTracking LessonTracking = db.StudentLessonTrackings.Where(x => x.LessonId == lesson.Id && x.StudentId == UserId).FirstOrDefault();

                    if (LessonTracking == null)
                    {
                        LessonExist = "No";
                    }
                    else
                    {
                        LessonExist = "Yes";
                    }

                    Lesson lessonobj = new Lesson();
                    lessonobj.LessonId                   = lesson.Id;
                    lessonobj.LessonName                 = lesson.Name;
                    lessonobj.LessonDuration             = lesson.Duration;
                    lessonobj.LessonExistInTrackingTable = LessonExist;

                    LessonsList.Add(lessonobj);
                    Count++;
                    count1++;
                }

                List <Lesson> OrderByLessons = LessonsList.OrderBy(x => x.LessonName).ToList();

                TopicObj.LessonList = OrderByLessons;

                TopicObj.TotalLessons  = Count;
                TopicObj.TotalLessons1 = count1;

                TopicListObj.Add(TopicObj);
            }

            // return Json(TopicListObj, JsonRequestBehavior.AllowGet);

            return(Json(TopicListObj.OrderBy(x => x.TopicName).ToList(), JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetSubjectTopicsAndLessons(int SubjectId)
        {
            //  var SubjectTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList();


            //var AllSubjectTopicsLessons = from SubjectTopic in db.AspnetSubjectTopics
            //                              join Lesson in db.AspnetLessons on SubjectTopic.Id equals Lesson.TopicId
            //                              where SubjectTopic.SubjectId == SubjectId
            //                              select new
            //                              {
            //                                  TopicId = SubjectTopic.Id,
            //                                  TopicName =   SubjectTopic.Name,
            //                                  LessonId = Lesson.Id,
            //                                  LessonName = Lesson.Name,
            //                                  Lesson.Duration,
            //                                  Lesson.Description

            //                              };

            var SubjectsTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList();

            var UserId = User.Identity.GetUserId();


            List <Topic> TopicListObj = new List <Topic>();

            int Count = 0;

            foreach (var a in SubjectsTopics)
            {
                int   count1   = 0;
                Topic TopicObj = new Topic();

                var list = db.AspnetLessons.Where(x => x.TopicId == a.Id).ToList();

                TopicObj.TopicId   = a.Id;
                TopicObj.TopicName = a.Name;



                List <Lesson> LessonsList = new List <Lesson>();


                foreach (var lesson in list)
                {
                    var LessonExist = "";
                    StudentLessonTracking LessonTracking = db.StudentLessonTrackings.Where(x => x.LessonId == lesson.Id & x.StudentId == UserId).FirstOrDefault();

                    if (LessonTracking == null)
                    {
                        LessonExist = "No";
                    }
                    else
                    {
                        LessonExist = "Yes";
                    }
                    Lesson lessonobj = new Lesson();
                    lessonobj.LessonId                   = lesson.Id;
                    lessonobj.LessonName                 = lesson.Name;
                    lessonobj.LessonDuration             = lesson.Duration;
                    lessonobj.LessonExistInTrackingTable = LessonExist;

                    LessonsList.Add(lessonobj);
                    Count++;
                    count1++;
                }

                List <Lesson> OrderByLessons = LessonsList.OrderBy(x => x.LessonName).ToList();

                TopicObj.LessonList = OrderByLessons;

                TopicObj.TotalLessons  = Count;
                TopicObj.TotalLessons1 = count1;

                TopicListObj.Add(TopicObj);
            }

            return(Json(TopicListObj.OrderBy(x => x.TopicName).ToList(), JsonRequestBehavior.AllowGet));
        }