public IActionResult GetSessionStatus(int sessionId) { BoBSession boBSession = _boBSessionRepository.GetById(sessionId); bool active = boBSession.SessionStatus == SessionStatus.Started; return(Json(active)); }
public IActionResult SessionInfo(int sessionId) { BoBSession session = _boBSessionRepository.GetByIdDetail(sessionId); OrderGroupPaths(session.Groups); return(Json(session)); }
public IActionResult WaitScreen(int id, int sessionId) { //Already chose a group CheckForCurrentGroup(sessionId); BoBSession session = _boBSessionRepository.GetById(sessionId); ViewData["freejoin"] = session.IsFreeJoinEnabled; //Make sure the chosen groupId is from the current session BoBGroup group = _boBSessionRepository.GetSpecificGroupFromSession(sessionId, id); //Chosen group is not from this session if (group == null) { TempData["bruteforce"] = "Groep is niet van de geselecteerde sessie"; return(RedirectToAction("Index", "Home")); } //Chosen group has already been chosen try { session.SelectGroup(group); } catch (InvalidOperationException ex) { TempData["groupchosen"] = ex.Message; return(RedirectToAction("Index", null)); } //Save Changes to database _boBSessionRepository.SaveChanges(); HttpContext.Session.SetInt32("groupId", group.Id); return(RedirectToAction("WaitScreen")); }
public IActionResult ValidateAnswer(int sessionId, int groupId, String answer) { //Get session and group from repo BoBSession session = _bobSessionRepository.GetById(sessionId); BoBGroup group = _bobSessionRepository.GetSpecificGroupFromSession(sessionId, groupId); bool correct = false; //Get the next assignment, cannot use assignment method from repo because we need the groupstate to check Assignment assignment = group.NextAssignment; try { //Validate answer correct = session.ValidateAnswer(group, assignment, answer); } catch (InvalidOperationException ex) { //Groupstate not valid TempData["blocked"] = "Roep de leerkracht om te vragen om je te deblokkeren"; return(RedirectToAction("Index")); } _bobSessionRepository.SaveChanges(); //Is the answer incorrect? if (!correct) { //Show last answer TempData["wronganswer"] = answer + " was niet het juiste antwoord"; //Is group blocked? if (group.Status == GroupStatus.Blocked) { //yep TempData["blocked"] = "Je bent geblokkeerd"; } //Is feedback enabled and answercount higher than 3? if (session.IsFeedbackEnabled && group.NextAssignment.WrongCount >= 3) { TempData["feedback"] = "Bekijk de feedback om dit hoofdstuk terug op te helderen"; } //Try again return(RedirectToAction("Index")); } //Answer is correct, check if we need to show the next action if (session.AreActionsEnabled && !session.IsDistant) { return(RedirectToAction("Action", new RouteValueDictionary { { "referenceNumber", assignment.ReferenceNr } })); } //Answer is correct, actions not enabled, show next assignment return(RedirectToAction("Index")); }
public IActionResult EnableActions(int sessionId) { BoBSession session = _boBSessionRepository.GetById(sessionId); session.AreActionsEnabled = true; _boBSessionRepository.SaveChanges(); return(RedirectToAction("SessionDetail")); }
public IActionResult DisableFreeJoin(int sessionId) { BoBSession session = _boBSessionRepository.GetById(sessionId); session.IsFreeJoinEnabled = false; _boBSessionRepository.SaveChanges(); return(RedirectToAction("SessionDetail")); }
public DummyApplicationDbContext() { //Invullen this._sessions = new BoBSession[4]; _sessions[0] = new BoBSession(); //invalid _sessions[1] = new BoBSession(); _sessions[2] = new BoBSession(); _sessions[3] = new BoBSession(); _sessions[0].SessionStatus = SessionStatus.Scheduled; _sessions[1].SessionStatus = SessionStatus.Activated; _sessions[2].SessionStatus = SessionStatus.Closed; _sessions[3].SessionStatus = SessionStatus.Started; Assignment1 = new Assignment { Exercise = new Exercise() { Answer = "10" }, GroupOperation = new GroupOperation() { AnswerBehaviour = new MinBehaviour(), ValueString = "5" } }; LazyAssignment = new Assignment { Exercise = new Exercise() { Answer = "10" }, GroupOperation = new GroupOperation() { GroupOperationCategory = GroupOperationCategory.Min, ValueString = "5" } }; SelectedGroup = new BoBGroup { Path = new SessionPath { Assignments = new List <Assignment>() { Assignment1 } }, }; SelectedGroup.GroupState = new LockedState(SelectedGroup); }
public IActionResult ActivateSession(int sessionId) { HttpContext.Session.SetInt32("SessionId", sessionId); BoBSession session = _boBSessionRepository.GetById(sessionId); try { session.Activate(); } catch (InvalidOperationException ex) { return(RedirectToAction("Index", "Session")); } _boBSessionRepository.SaveChanges(); return(RedirectToAction(nameof(SessionDetail))); }
private int?CheckForCurrentGroup(int sessionId) { //Get current groupId int? groupId = HttpContext.Session.GetInt32("groupId"); BoBSession session = _boBSessionRepository.GetById(sessionId); //Deselect current group, there is a current group if (groupId.HasValue) { int groupIdVal = groupId.Value; BoBGroup group = _boBGroupRepository.GetById(groupIdVal); session.DeselectGroup(group); _boBGroupRepository.SaveChanges(); TempData["groupchosen"] = "De vorig geselecteerde groep is nu niet meer geselecteerd!"; HttpContext.Session.Remove("groupId"); } return(groupId); }
public IActionResult Control(int id) { BoBSession session = _boBSessionRepository.GetById(id); if (session == null) { TempData["sessionCode"] = "Deze sessiecode bestaat niet"; return(RedirectToAction("Index")); } if (session.SessionStatus != SessionStatus.Activated) { TempData["sessionCode"] = "Deze sessie is nog niet gestart of is al bezig"; return(RedirectToAction("Index")); } HttpContext.Session.SetInt32("SessionId", id); //Keert terug naar het scherm van controller 'BobGroup' naar de html 'Index' return(RedirectToAction("Index", "BoBGroup")); }
public IActionResult Index(int sessionId) { //Already chosen a group => deselect current group try { CheckForCurrentGroup(sessionId); } catch (InvalidOperationException ex) { TempData["runaway"] = "Niet proberen weglopen!"; return(RedirectToAction("WaitScreen")); } BoBSession session = _boBSessionRepository.GetById(sessionId); IEnumerable <BoBGroup> groups = session.Groups.OrderBy(g => g.Status, new GroupStatusComparer()).ThenBy(g => g.GroupName, new GroupNameComparer()); return(View(groups)); }
public IActionResult WaitScreen(int sessionId) { BoBSession boBSession = _boBSessionRepository.GetById(sessionId); //Are students able to join? ViewData["freejoin"] = boBSession.IsFreeJoinEnabled; //Could use filter int?groupId = HttpContext.Session.GetInt32("groupId"); if (!groupId.HasValue) { TempData["groupchosen"] = "Kies een groep aub"; return(RedirectToAction("Index")); } BoBGroup group = _boBGroupRepository.GetById(groupId.Value); return(View(group)); }
public static SessionState CreateState(BoBSession session, SessionStatus status) { SessionState state = null; switch (status) { case SessionStatus.Scheduled: state = new ScheduledState(session); break; case SessionStatus.Activated: state = new ActivatedState(session); break;; case SessionStatus.Started: state = new StartedState(session); break; case SessionStatus.Closed: state = new LockedState(session); break; } return(state); }
protected SessionState(BoBSession session) { Session = session; }
public LockedState(BoBSession session) : base(session) { }
public ScheduledState(BoBSession session) : base(session) { }
public StartedState(BoBSession session) : base(session) { }
public ActivatedState(BoBSession session) : base(session) { }