示例#1
0
 public override Task OnDisconnected(bool stopCalled)
 {
     if (Context.User.IsInRole(RoleName.Student))
     {
         int studentId = AccountCredentials.GetStudentId((ClaimsIdentity)Context.User.Identity);
         Connections.Remove(studentId, Context.ConnectionId);
     }
     return(base.OnDisconnected(stopCalled));
 }
示例#2
0
 public override Task OnConnected()
 {
     if (Context.User.IsInRole(RoleName.Student))
     {
         int studentId = AccountCredentials.GetStudentId((ClaimsIdentity)Context.User.Identity);
         Connections.Add(studentId, Context.ConnectionId);
     }
     return(base.OnConnected());
 }
示例#3
0
        public async Task <JsonResult> CheckForActiveCumulativeQuiz()
        {
            var studentId        = AccountCredentials.GetStudentId();
            var cumulativeQuizId = await Context.CumulativeQuizPasseds
                                   .Where(iqp => iqp.StudentId == studentId && iqp.StartDate != null && iqp.EndDate == null)
                                   .OrderBy(o => o.StartDate).Select(s => s.Id).FirstOrDefaultAsync();

            return(Json(cumulativeQuizId, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public async Task <JsonResult> CheckForActiveRealtimeQuiz()
        {
            var studentId       = AccountCredentials.GetStudentId();
            var moduleHistoryId =
                await(from s in Context.Students
                      where s.Id == studentId
                      join lhg in Context.LectureHistoryGroups on s.GroupId equals lhg.GroupId
                      join sd in Context.StudentDisciplines on s.Id equals sd.StudentId
                      join lh in Context.LecturesHistories on sd.DisciplineId equals lh.DisciplineId
                      where lh.Id == lhg.LectureHistoryId
                      join mh in Context.ModuleHistories on lh.Id equals mh.LectureHistoryId
                      where mh.StartTime != null && mh.IsPassed == false
                      select mh).OrderBy(mh => mh.StartTime).Select(s => s.Id).FirstOrDefaultAsync();

            return(Json(moduleHistoryId, JsonRequestBehavior.AllowGet));
        }