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)); }
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()); }
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)); }
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)); }