コード例 #1
0
        public async Task <ActionResult> Index()
        {
            //If admin
            if (AccountCredentials.GetRole() != RoleName.Lecturer)
            {
                var adminModel = new ReasignViewModel
                {
                    Disciplines  = await Context.Disciplines.ToListAsync(),
                    Lectures     = await Context.Lectures.ToListAsync(),
                    Modules      = await Context.Modules.ToListAsync(),
                    Questions    = await Context.Questions.ToListAsync(),
                    Answers      = await Context.Answers.ToListAsync(),
                    Specialities = await Context.Specialities.ToListAsync(),
                    Groups       = await Context.Groups.ToListAsync(),
                    Students     = await Context.Students.ToListAsync(),
                    Lectors      = await Context.Lectors.ToListAsync()
                };
                return(View(adminModel));
            }
            //If lector
            Lector lector = await AccountCredentials.GetLector();

            if (await Context.LecturesHistories.AnyAsync(lh => lh.IsFrozen == false && lh.LectorId == lector.Id && lh.EndTime == null))
            {
                if (await Context.ModuleHistories.AnyAsync(mh => mh.StartTime != null && mh.IsPassed == false && mh.LectorId == lector.Id))
                {
                    return(RedirectToAction("modulestatistics", "quiz"));
                }
                return(RedirectToAction("activelecture", "admin"));
            }
            var checkIfLector = await _adminPageHelper.LecturesIndexPage(lector);

            return(View(checkIfLector));
        }
コード例 #2
0
        public async Task <ActionResult> ModuleStatistics()
        {
            Lector lector = await AccountCredentials.GetLector();

            if (await Context.ModuleHistories.AnyAsync(mh => mh.StartTime != null &&
                                                       mh.IsPassed == false &&
                                                       mh.LectorId == lector.Id))
            {
                return(View(await _quizManager.GetRealTimeStatisticsViewModel(lector)));
            }
            return(RedirectToAction("index", "admin"));
        }
コード例 #3
0
        public async Task <ActionResult> ActiveLecture()
        {
            var lector = await AccountCredentials.GetLector();

            if (await Context.LecturesHistories.AnyAsync(lh => lh.EndTime == null &&
                                                         lh.IsFrozen == false &&
                                                         lh.LectorId == lector.Id))
            {
                if (await Context.ModuleHistories.AnyAsync(mh => mh.StartTime != null &&
                                                           mh.IsPassed == false &&
                                                           mh.LectorId == lector.Id))
                {
                    return(RedirectToAction("modulestatistics", "quiz"));
                }
                return(View(await _lectureHistoryHelper.GetActiveLecture(lector)));
            }
            return(RedirectToAction("Index", "Admin"));
        }