Example #1
0
        public async Task <Dictionary <int, int> > GetQuizForLectureAlailability(int disciplineId)
        {
            var studentId = AccountCredentials.GetStudentId();

            return(await(from itp in _context.IndividualQuizPasseds
                         where !itp.IsPassed && itp.StudentId == studentId && itp.DisciplineId == disciplineId
                         select new { itp.LectureId, itp.Id }).ToDictionaryAsync(td => td.LectureId, td => td.Id));
        }
Example #2
0
        public async Task <RealTimeQuizViewModel> GetRealtimeQnA(int moduleHistoryId)
        {
            var student = await AccountCredentials.GetStudent();

            bool studentCanPass = await _studentPageHelper.StudentCanPass(moduleHistoryId, student.Id);

            if (studentCanPass)
            {
                RealTimeQuizViewModel qnA = new RealTimeQuizViewModel();
                if (await _context.RealtimeModulesPasseds.AnyAsync(smp =>
                                                                   smp.StudentId == student.Id && smp.ModuleHistoryId == moduleHistoryId))
                {
                    return(qnA);
                }
                ModuleHistory moduleHistory =
                    await _context.ModuleHistories.SingleOrDefaultAsync(mh => mh.Id == moduleHistoryId);

                int lectureId = _context.LecturesHistories.Where(lh => lh.Id == moduleHistory.LectureHistoryId)
                                .Select(lh => lh.LectureId).SingleOrDefault();
                var question = await _context.Questions.Where(q => q.ModuleId == moduleHistory.ModuleId && q.QuestionType == QuestionType.RealtimeId &&
                                                              !_context.RealtimeResponses.Where(r => r.ModuleHistoryId == moduleHistoryId &&
                                                                                                r.StudentId == student.Id).Select(r => r.QuestionId).Contains(q.Id))
                               .OrderBy(q => Guid.NewGuid()).FirstOrDefaultAsync();

                if (question == null)
                {
                    await ResovlePassedRealtimeQuiz(moduleHistory.ModuleId, student.Id, moduleHistoryId, lectureId);

                    return(qnA);
                }

                qnA = new RealTimeQuizViewModel
                {
                    Question         = question,
                    Student          = student,
                    Answers          = await GetAnswersList(question.Id),
                    LectureHistoryId = moduleHistory.LectureHistoryId,
                    ModuleHistoryId  = moduleHistoryId
                };
                return(qnA);
            }
            return(null);
        }
Example #3
0
        public async Task StartLecture(ReasignViewModel model)
        {
            var disc   = model.Disciplines[0].Id;
            var lect   = model.Lectures[0].Id;
            var date   = DateTime.UtcNow;
            var lector = await AccountCredentials.GetLector();

            var lectureHistory = _db.LecturesHistories.Add(new LecturesHistory
            {
                LectureId    = lect,
                DisciplineId = disc,
                StartTime    = date,
                IsFrozen     = false,
                LectorId     = lector.Id
            });
            await _db.SaveChangesAsync();

            _db.ModuleHistories.AddRange(
                from m in await _db.Modules.ToListAsync()
                where m.LectureId == lect
                select new ModuleHistory
            {
                IsPassed         = false,
                LectureHistoryId = lectureHistory.Id,
                ModuleId         = m.Id,
                StartTime        = null,
                LectorId         = lector.Id
            });

            _db.LectureHistoryGroups.AddRange(
                from g in model.Groups
                where g.IsSelected
                select new LectureHistoryGroup
            {
                GroupId          = g.Id,
                LectureHistoryId = lectureHistory.Id
            });

            await _db.SaveChangesAsync();
        }
        public async Task <IEnumerable <DiscLectorCumulativeCheckViewModel> > StudentsDisciplinesList()
        {
            var studentId = AccountCredentials.GetStudentId();
            List <DiscLectorCumulativeCheckViewModel> model =
                await(from d in _db.Disciplines
                      join sd in _db.StudentDisciplines on d.Id equals sd.DisciplineId
                      where sd.StudentId == studentId
                      join cq in _db.CumulativeQuizPasseds on sd.DisciplineId equals cq.DisciplineId into cqsjoin
                      from cqs in cqsjoin.DefaultIfEmpty()
                      where cqs.StudentId == studentId || cqs == null
                      join ld in _db.LectorDisciplines on d.Id equals ld.DisciplineId
                      join l in _db.Lectors on ld.LectorId equals l.Id into lectjoin
                      select new DiscLectorCumulativeCheckViewModel()
            {
                DiscId           = d.Id,
                DiscName         = d.Name,
                Lectors          = lectjoin,
                CumulativeQuizId = cqs.IsPassed != true && cqs != null ? cqs.Id : (int?)null
            }).ToListAsync();

            return(model);
        }