Пример #1
0
		public ActionResult CourseList()
		{
			var model = new CourseListViewModel
			{
				Courses = courseManager.GetCourses().ToList(), 
				PackageNames = courseManager.GetStagingPackages().ToList()
			};
			return View(model);
		}
Пример #2
0
        public async Task <ActionResult> Courses(string courseId = null, string courseTitle = null)
        {
            var isSystemAdministrator = User.IsSystemAdministrator();
            var userId  = User.Identity.GetUserId();
            var courses = courseManager.GetCourses();

            // Неопубликованные курсы не покажем тем, кто не имеет роли в них.
            if (!isSystemAdministrator)
            {
                var visibleCourses = unitsRepo.GetVisibleCourses();
                var coursesInWhichUserHasAnyRole = userRolesRepo.GetCoursesWhereUserIsInRole(userId, CourseRole.Tester);
                var coursesWhereIAmStudent       = groupsRepo.GetUserGroups(userId)
                                                   .Select(g => g.CourseId)
                                                   .Distinct(StringComparer.OrdinalIgnoreCase)
                                                   .Where(c => visibleCourses.Contains(c)).ToList();
                courses = courses.Where(c => coursesInWhichUserHasAnyRole.Contains(c.Id, StringComparer.OrdinalIgnoreCase) ||
                                        coursesWhereIAmStudent.Contains(c.Id, StringComparer.OrdinalIgnoreCase));
            }

            var incorrectChars = new string(CourseManager.GetInvalidCharacters().OrderBy(c => c).Where(c => 32 <= c).ToArray());

            if (isSystemAdministrator)
            {
                courses = courses.OrderBy(course => course.Id, StringComparer.InvariantCultureIgnoreCase);
            }
            else
            {
                courses = courses.OrderBy(course => course.Title, StringComparer.InvariantCultureIgnoreCase);
            }

            var tempCourses = tempCoursesRepo.GetTempCourses().Select(c => c.CourseId).ToHashSet();
            var model       = new CourseListViewModel
            {
                Courses = courses
                          .Select(course => new CourseViewModel
                {
                    Id            = course.Id,
                    Title         = course.Title,
                    LastWriteTime = courseManager.GetLastWriteTime(course.Id),
                    IsTemp        = tempCourses.Contains(course.Id)
                })
                          .ToList(),
                LastTryCourseId    = courseId,
                LastTryCourseTitle = courseTitle,
                InvalidCharacters  = incorrectChars
            };

            return(View(model));
        }
Пример #3
0
		public ActionResult CourseList(string courseCreationLastTry = null)
		{
			var courses = new HashSet<string>(User.GetControllableCoursesId());
			var incorrectChars = new string(CourseManager.GetInvalidCharacters().OrderBy(c => c).Where(c => 32 <= c).ToArray());
			var model = new CourseListViewModel
			{
				Courses = courseManager.GetCourses().Where(course => courses.Contains(course.Id)).Select(course => new CourseViewModel
				{
					Id = course.Id,
					Title = course.Title,
					LastWriteTime = courseManager.GetLastWriteTime(course.Id)
				}).ToList(),
				CourseCreationLastTry = courseCreationLastTry,
				InvalidCharacters = incorrectChars
			};
			return View(model);
		}
Пример #4
0
        public ActionResult CourseList(string courseCreationLastTry = null)
        {
            var courses        = new HashSet <string>(User.GetControllableCoursesId());
            var incorrectChars = new string(CourseManager.GetInvalidCharacters().OrderBy(c => c).Where(c => 32 <= c).ToArray());
            var model          = new CourseListViewModel
            {
                Courses = courseManager.GetCourses().Where(course => courses.Contains(course.Id)).Select(course => new CourseViewModel
                {
                    Id            = course.Id,
                    Title         = course.Title,
                    LastWriteTime = courseManager.GetLastWriteTime(course.Id)
                }).ToList(),
                CourseCreationLastTry = courseCreationLastTry,
                InvalidCharacters     = incorrectChars
            };

            return(View(model));
        }