Example #1
0
        // GET: Lectures/courseId
        public ActionResult Index(int courseId)
        {
            var lectures = LectureHelper.GetLecturesForCourse(courseId);

            ViewBag.CourseID = courseId;

            return(View(lectures));
        }
        public static DetailedOverviewForStudentVM CreateDetailedOverviewForStudentVM(User user, Course course)
        {
            var vm = new DetailedOverviewForStudentVM(user, course)
            {
                AttendedLectures = LectureHelper.GetAllAttendedLecturesForStudent(course.CourseID, user.UserID),
                AllLectures      = LectureHelper.GetLecturesForCourse(course.CourseID)
            };

            return(vm);
        }
Example #3
0
        public static DetailedCourseVM CreateDetailedCourseVMW(Course course)
        {
            var vm = new DetailedCourseVM(course)
            {
                Supervisors  = SupervisorHelper.GetSupervisorsForCourse(course.CourseID),
                Lectures     = LectureHelper.GetLecturesForCourse(course.CourseID),
                Participants = UserHelper.GetParticipantsForCourse(course.CourseID)
            };

            return(vm);
        }
Example #4
0
        // GET: Courses/Details/courseId
        // returns details view with all related data depending on the logged in user
        public ActionResult Details(int?courseId)
        {
            if (courseId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // cast nullable int
            int    id     = (int)courseId;
            Course course = CourseHelper.GetById(id);

            if (course == null)
            {
                return(HttpNotFound());
            }

            DetailedCourseVM viewModel = null;

            // check if the current user is a student and setup accordingly the view model
            if (CurrentWebContext.CurrentUser.Type == "student")
            {
                ViewBag.IsParticipant = false;
                viewModel             = new DetailedCourseVM(course);
                viewModel.Lectures    = LectureHelper.GetLecturesForCourse(course.CourseID);
                // get the type of student for this course
                ViewBag.StatusOfStudent = CourseHelper.GetStudentStatusForCourse(CurrentWebContext.CurrentUser.UserID, course.CourseID);
            }

            // check if the current user is a teacher and create the view model for him
            if (CurrentWebContext.CurrentUser.Type == "teacher")
            {
                viewModel = DetailedCourseVM.CreateDetailedCourseVMW(course);
                ViewBag.CountOfPendingStudents = ParticipantHelper.GetCountOfPendingParticipants(id);
            }
            return(View(viewModel));
        }