/// <summary> /// Constructor. Create a converter based on a data model. /// </summary> protected RteDataModelConverter(SessionView view, LearningDataModel dataModel) { this.mDm = dataModel; this.mView = view; this.mPendingInteractions = new List<Interaction>(); this.mPendingObjectives = new List<Objective>(); }
/// <summary> /// Constructor. Create a converter based on a data model. /// </summary> protected RteDataModelConverter(SessionView view, LearningDataModel dataModel) { m_dm = dataModel; m_view = view; m_pendingInteractions = new List<Interaction>(); m_pendingObjectives = new List<Objective>(); }
/// <summary> /// Delegate implementation to allow the frameset to take action on a session view request. This allows SLK and /// BWP to have different behavior and messages about which requests are not valid. /// </summary> public bool ProcessViewRequest(SessionView view, LearningSession session) { Completed = false; switch (view) { case SessionView.Execute: { StoredLearningSession slsSession = session as StoredLearningSession; if (slsSession != null) { if (slsSession.AttemptStatus == AttemptStatus.Completed) { RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_InvalidAttemptStatusForViewTitle")), ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_ExecuteViewCompletedSessionMsg")), false); Completed = true; return false; } else if (slsSession.AttemptStatus == AttemptStatus.Abandoned) { RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_InvalidAttemptStatusForViewTitle")), ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_ExecuteViewAbandonedSessionMsg")), false); return false; } } } break; case SessionView.Review: // BWP does not provide review view RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_ViewNotSupportedTitle")), ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_ReviewViewNotSupportedMsg")), false); break; case SessionView.RandomAccess: RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_ViewNotSupportedTitle")), ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_RAViewNotSupportedMsg")), false); break; } return true; }
public bool GetViewInfo(bool showErrorPage, out SessionView view) { // make compiler happy view = SessionView.Execute; // Get the parts of the content path (parameter PF) value // pfParts[0] = "", pfParts[1] = view, pfParts[2] = extra view data, everything else is path or extra data for attempt views this.mContentPathParts = this.mContentPath.Split(new[] { '/' }); // First section is view -- it must exist in all cases. string strView = this.mContentPathParts[1]; if (string.IsNullOrEmpty(strView)) { if (showErrorPage) { this.RegisterError( ResHelper.GetMessage(Localization.GetMessage("FRM_ParameterRequiredTitle"), FramesetQueryParameter.View), ResHelper.GetMessage(Localization.GetMessage("FRM_ParameterRequiredMsg"), FramesetQueryParameter.View), false); } return false; } try { view = (SessionView)Enum.Parse(typeof(SessionView), strView, true); if (!Enum.IsDefined(typeof(SessionView), view)) { if (showErrorPage) { this.RegisterError( ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View), ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, strView), false); } return false; } } catch (ArgumentException) { if (showErrorPage) { this.RegisterError( ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View), ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, strView), false); } return false; } this.mView = view; return true; }
/// <summary>Process a view request to determine if it's valid. The AssignmentView must be set before calling this method.</summary> protected bool ProcessViewRequest(LearnerAssignmentState learnerStatus, SessionView sessionView) { switch (AssignmentView) { case AssignmentView.Execute: { // Verify that session view matches what you expect if (sessionView != SessionView.Execute) { throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml); } // Can only access active assignments in Execute view if (learnerStatus != LearnerAssignmentState.Active) { RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle, SlkFrameset.FRM_AssignmentTurnedInMsgHtml, false); return(false); } break; } case AssignmentView.Grading: { // Verify that session view matches what you expect if (sessionView != SessionView.Review) { throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml); } // Grading is not available if the assignment has not been submitted. if ((learnerStatus == LearnerAssignmentState.Active) || (learnerStatus == LearnerAssignmentState.NotStarted)) { RegisterError(SlkFrameset.FRM_AssignmentNotGradableTitle, SlkFrameset.FRM_AssignmentCantBeGradedMsgHtml, false); return(false); } break; } case AssignmentView.InstructorReview: { // Verify that session view matches what you expect if (sessionView != SessionView.Review) { throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml); } // Only available if student has started the assignment if (learnerStatus == LearnerAssignmentState.NotStarted) { RegisterError(SlkFrameset.FRM_ReviewNotAvailableTitle, SlkFrameset.FRM_ReviewNotAvailableMsgHtml, false); return(false); } break; } case AssignmentView.StudentReview: { // Verify that session view matches what you expect if (sessionView != SessionView.Review) { throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml); } // If the user is an observer and the assignment state is equal to 'Completed' or 'NotStarted', // then register error message if (SlkStore.IsObserver(SPWeb) && ((learnerStatus == LearnerAssignmentState.Completed) || (learnerStatus == LearnerAssignmentState.NotStarted))) { RegisterError(SlkFrameset.FRM_ObserverReviewNotAvailableTitle, SlkFrameset.FRM_ObserverReviewNotAvailableMsgHtml, false); return(false); } // If requesting student review, the assignment state must be final if (!SlkStore.IsObserver(SPWeb) && learnerStatus != LearnerAssignmentState.Final) { RegisterError(SlkFrameset.FRM_ReviewNotAvailableTitle, SlkFrameset.FRM_LearnerReviewNotAvailableMsgHtml, false); return(false); } break; } default: break; } return(true); }
/// <summary> /// Helper function to process the View parameter. This method assumes the parameter is required. If it does not /// exist or is not a valid value and showErrorPage=true, the error page is shown and the method returns false. /// If false is returned, the caller should ignore the value of <param name="view"/>. /// </summary> public bool ProcessViewParameter(bool showErrorPage, out SessionView view) { return(FramesetHelper.TryProcessViewParameter(showErrorPage, out view)); }
/// <summary> /// Constructor. Create a converter for 2004 content. /// </summary> /// <param name="view"></param> /// <param name="dataModel"></param> internal Rte2004DataModelConverter(SessionView view, LearningDataModel dataModel) : base(view, dataModel) { this.mPendingLearnerComments = new Dictionary<int, Comment>(); }
/// <summary> /// Gets the RTE string that represents the credit value. /// </summary> public static string GetRteCredit(bool credit, SessionView view) { // It's only possible to return 'credit' in execute view if (credit && (view == SessionView.Execute)) { return "credit"; } return "no-credit"; }
/// <summary> /// Constructor to create the LearningSession. This is internal, as only MLC subclasses can create one. /// </summary> /// <param name="view">The view of the session, for example Review, Execute, RandomAccess.</param> /// <remarks> /// Constructor is internal. Don't allow classes outside of our product to create one. /// /// Subclass constructors MUST assign a value to m_navigator. /// </remarks> internal LearningSession(SessionView view) { Resources.Culture = LocalizationManager.GetCurrentCulture(); m_view = view; }
/// <summary> /// Constructor. Create a converter for SCORM 1.2 content. /// </summary> /// <param name="view"></param> /// <param name="dataModel"></param> internal Rte1p2DataModelConverter(SessionView view, LearningDataModel dataModel) : base(view, dataModel) { }
public IActionResult AddEdit(SessionView session) { try { NewProtocol ptoList = INewPatient.GetProtocolByproId(session.ProtocolId); if (ptoList != null) { PatientRx lrx = IPatientRx.getPatientRx(ptoList.RxId); if (lrx != null) { Session _session = new Session(); _session.PatientId = ptoList.PatientId; _session.RxId = ptoList.RxId; _session.ProtocolId = ptoList.ProtocolId; _session.SessionDate = session.SessionDate; _session.Duration = session.Duration; _session.Reps = session.Reps; _session.MaxExtension = session.MaxExtension; _session.ExtensionReps = session.ExtensionReps; _session.MaxFlexion = session.MaxFlexion; _session.FlexionReps = session.FlexionReps; _session.MaxPain = session.MaxPain; _session.PainCount = session.PainCount; _session.Boom1Position = session.Boom1Position; _session.Boom2Position = session.Boom2Position; _session.RangeDuration1 = session.RangeDuration1; _session.RangeDuration2 = session.RangeDuration2; _session.GuidedMode = _session.GuidedMode; _session.TimeZoneOffset = ""; if (session.MaxFlexion > lrx.CurrentFlexion && session.MaxExtension > lrx.CurrentExtension) { int res = INewPatient.ChangeRxCurrent(lrx.RxId, session.MaxFlexion, session.MaxExtension, "Patient"); } else if (session.MaxFlexion > lrx.CurrentFlexion) { int res = INewPatient.ChangeRxCurrentFlexion(lrx.RxId, session.MaxFlexion, "Patient"); } else if (session.MaxExtension > lrx.CurrentExtension) { int res = INewPatient.ChangeRxCurrentExtension(lrx.RxId, session.MaxExtension, "Patient"); } else { RomchangeLog plog = new RomchangeLog(); plog.RxId = lrx.RxId; plog.PreviousFlexion = lrx.CurrentFlexion.HasValue ? Convert.ToInt32(lrx.CurrentFlexion) : 0; plog.PreviousExtension = lrx.CurrentExtension.HasValue ? Convert.ToInt32(lrx.CurrentExtension) : 0; plog.CreatedDate = DateTime.UtcNow; plog.ChangedBy = "Patient"; IRomChangeLog.InsertRomChangeLog(plog); } if (!string.IsNullOrEmpty(session.SessionId)) { _session.SessionId = session.SessionId; //Session editSession = lISessionInterface.getSession(session.SessionId); //if (editSession != null) //{ lISessionInterface.UpdateSession(_session); //} } else { _session.SessionId = Guid.NewGuid().ToString(); lISessionInterface.InsertSession(_session); } } } if (!string.IsNullOrEmpty(session.returnView)) { return(RedirectToAction("Index", "Review", new { id = session.PatientId, Username = session.Patname, EquipmentType = session.EType, actuator = session.EEnum, tab = "Sessions" })); } else { return(RedirectToAction("Index", "SessionView", new { id = session.PatientId, Username = session.Patname, Etype = session.EType, actuator = session.EEnum })); } } catch (Exception ex) { logger.LogDebug("User Post Error: " + ex); return(null); } }
public IActionResult AddEdit(int id, string Username = "", string Etype = "", string actuator = "", string returnView = "", string sessionid = "") { try { ViewBag.flexionString = "Flexion"; ViewBag.extensionString = "Extension"; List <EquipmentExercise> lExerciseString = lIEquipmentExerciseRepository.GetEquipmentExerciseString(); if (lExerciseString != null && lExerciseString.Count > 0 && Etype == "Shoulder") { var lexString = lExerciseString.Where(x => x.Limb == "Shoulder" && x.ExerciseEnum == actuator).FirstOrDefault(); if (lexString != null) { ViewBag.flexionString = lexString.FlexionString; } } else if (lExerciseString != null && lExerciseString.Count > 0) { var lexString = lExerciseString.Where(x => x.Limb == Etype).FirstOrDefault(); if (lexString != null) { ViewBag.flexionString = lexString.FlexionString; ViewBag.extensionString = lexString.ExtensionString; } } if (string.IsNullOrEmpty(sessionid)) { List <NewProtocol> ptoList = INewPatient.GetProtocolListBypatId(id.ToString()); if (Etype == "Shoulder") { ptoList = ptoList.Where(p => p.ExcerciseEnum == actuator).ToList(); } else { ptoList = ptoList.Where(p => p.ExcerciseEnum == "Flexion-Extension").ToList(); } List <SelectListItem> list = new List <SelectListItem>(); foreach (NewProtocol ex in ptoList) { list.Add(new SelectListItem { Text = ex.ProtocolName.ToString(), Value = ex.ProtocolId.ToString() }); } ViewBag.Protocol = list; SessionView sv = new SessionView(); sv.PatientId = id; sv.Patname = Username; sv.EType = Etype; sv.EEnum = actuator; if (!string.IsNullOrEmpty(returnView)) { sv.returnView = returnView; } return(View(sv)); } else { Session lSession = lISessionInterface.getSession(sessionid); if (lSession != null) { SessionView sv = SessionExtension.SessionToSessionView(lSession); if (sv != null) { List <NewProtocol> ptoList = INewPatient.GetProtocolListBypatId(sv.PatientId.ToString()); if (Etype == "Shoulder") { ptoList = ptoList.Where(p => p.ExcerciseEnum == actuator).ToList(); } else { ptoList = ptoList.Where(p => p.ExcerciseEnum == "Flexion-Extension").ToList(); } List <SelectListItem> list = new List <SelectListItem>(); foreach (NewProtocol ex in ptoList) { list.Add(new SelectListItem { Text = ex.ProtocolName.ToString(), Value = ex.ProtocolId.ToString() }); } ViewBag.Protocol = list; sv.PatientId = id; sv.Patname = Username; sv.EType = Etype; sv.EEnum = actuator; if (!string.IsNullOrEmpty(returnView)) { sv.returnView = returnView; } } return(View(sv)); } } } catch (Exception ex) { logger.LogDebug("User Post Error: " + ex); } return(View()); }
/// <summary> /// Constructor. Create a converter for SCORM 1.2 content. /// </summary> /// <param name="view"></param> /// <param name="dataModel"></param> internal Rte1p2DataModelConverter(SessionView view, LearningDataModel dataModel) : base(view, dataModel) { }
[SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")] // parameter is verified public static string GetValueAsParameter(SessionView value) { FramesetUtil.ValidateNonNullParameter("value", value); return(value.ToString()); }
/// <summary>Gets the string value of the SessionView.</summary> public static string GetString(SessionView view) { return(Convert.ToInt32(view, NumberFormatInfo.InvariantInfo).ToString(NumberFormatInfo.InvariantInfo)); }
/// <summary> /// Helper function to process the View parameter. This method assumes the parameter is required. If it does not /// exist or is not a valid value and showErrorPage=true, the error page is shown and the method returns false. /// If false is returned, the caller should ignore the value of <paramref name="view"/>. /// </summary> /// <param name="showErrorPage">TODO</param> /// <param name="view">TODO</param> public bool TryProcessViewParameter(bool showErrorPage, out SessionView view) { string viewParam; // Default value to make compiler happy view = SessionView.Execute; if (!TryGetRequiredParameter(FramesetQueryParameter.View, out viewParam)) return false; try { // Get the view enum value view = (SessionView)Enum.Parse(typeof(SessionView), viewParam, true); if ((view < SessionView.Execute) || (view > SessionView.Review)) { if (showErrorPage) { RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View), ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, viewParam), false); } return false; } } catch (ArgumentException) { if (showErrorPage) { RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View), ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, viewParam), false); } return false; } return true; }
/// <summary> /// Create a context to send to an RloHandler. /// </summary> /// <param name="view">The view that will be rendered from the form data.</param> /// <param name="learningDataModel">The data model of the current activity in the session.</param> internal RloProcessFormDataContext(SessionView view, LearningDataModel learningDataModel) { m_view = view; m_learningDataModel = learningDataModel; }
/// <summary>Gets the string value of the SessionView.</summary> public static string GetString(SessionView view) { return Convert.ToInt32(view, NumberFormatInfo.InvariantInfo).ToString(NumberFormatInfo.InvariantInfo); }
[SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")] // parameter is verified public static string GetValueAsParameter(SessionView value) { FramesetUtil.ValidateNonNullParameter("value", value); return value.ToString(); }
// Awake is called when the script instance is being loaded private void Awake() { // Get all active AIs and put them in a list List <IPlayer> allAIs = new List <IPlayer>(); GetComponents(allAIs); activeAIs = allAIs.FindAll(ai => (ai as AIPlayer).IsActive); // Load the match prefab matchPrefab = Resources.Load <GameObject>("Prefabs/Match"); // Get reference to the UI (session view) view = GetComponent <SessionView>(); // Set the session state to Begin state = SessionState.Begin; // Instantiate a human player if there are not enough AIs to do a match if (activeAIs.Count < 2) { humanPlayer = new HumanPlayer(); } // Instantiate the matches table allMatches = new SortedList <Match, Winner>(); // Instantiate the standings table and populate it with all AIs with // zero points standings = new Dictionary <IPlayer, int>(); foreach (IPlayer ai in activeAIs) { standings.Add(ai, 0); } // Setup session depending on how many AIs will play if (activeAIs.Count == 0) { // A game between human players uiWhoPlaysFirst = false; uiBlockStartNextMatch = true; uiBlockShowResult = true; allMatches.Add(new Match(humanPlayer, humanPlayer), Winner.None); } else if (activeAIs.Count == 1) { // A game between a human and an AI uiWhoPlaysFirst = true; uiBlockStartNextMatch = true; uiBlockShowResult = true; allMatches.Add(new Match(humanPlayer, activeAIs[0]), Winner.None); } else if (activeAIs.Count == 2) { // A game between two AIs, ask who plays first uiWhoPlaysFirst = true; uiBlockStartNextMatch = true; uiBlockShowResult = true; allMatches.Add(new Match(activeAIs[0], activeAIs[1]), Winner.None); } else { // Multiple AIs, run a tournament uiWhoPlaysFirst = false; uiBlockStartNextMatch = pressButtonBeforeMatch; uiBlockShowResult = pressButtonAfterMatch; // In this mode we need an even number of players to set up the // matches, so add a fake one if necessary if (activeAIs.Count % 2 != 0) { activeAIs.Add(new DummyPlayer()); } // Setup matches using the round-robin method // https://en.wikipedia.org/wiki/Round-robin_tournament for (int i = 1; i < activeAIs.Count; i++) { // This will be the AI to swap position after each round IPlayer aiToSwapPosition; // Set up matches for current round i for (int j = 0; j < activeAIs.Count / 2; j++) { // This is match j for current round i Match match = new Match( activeAIs[j], activeAIs[activeAIs.Count - 1 - j]); // Only add match to match list if it's not a dummy match if (!(match.player1 is DummyPlayer || match.player2 is DummyPlayer)) { // Each match is in practice two matches, so both AIs // can have a match where they are the first to play allMatches.Add(match, Winner.None); allMatches.Add(match.Swapped, Winner.None); } } // Swap AI positions for next round aiToSwapPosition = activeAIs[activeAIs.Count - 1]; activeAIs.RemoveAt(activeAIs.Count - 1); activeAIs.Insert(1, aiToSwapPosition); } } // Get the match enumerator and initialize it matchEnumerator = allMatches.Keys.ToList().GetEnumerator(); matchEnumerator.MoveNext(); currentMatch = matchEnumerator.Current; }
/// <summary> /// Returns false if the value is not a valid value for a SessionView. /// </summary> /// <param name="viewValue">A view to validate.</param> internal static bool ValidateSessionViewValue(SessionView viewValue) { return ((viewValue >= SessionView.Execute) && (viewValue <= SessionView.Review)); }
/// <summary> /// Create a context to send to an RloHandler. /// </summary> /// <param name="view">The view that will be rendered from the form data.</param> /// <param name="learningDataModel">The data model of the current activity in the session.</param> internal RloProcessFormDataContext(SessionView view, LearningDataModel learningDataModel) { m_view = view; m_learningDataModel = learningDataModel; }
public static string GetRteMode(SessionView view) { switch (view) { case SessionView.Review: return "review"; default: return "normal"; } }
async void OnSelected(object sender, ItemTappedEventArgs e) { EndpointView selected = e.Item as EndpointView; int i = storedList.endpointList.IndexOf(selected); string action = null; try { action = await DisplayActionSheet("Select authentication mode: ", "cancel", null, "Anonymous", "Username & Password"); if (action.Equals("Anonymous")) { Device.BeginInvokeOnMainThread(() => { UserDialogs.Instance.ShowLoading(); }); try { sessionView = await Task.Run(() => client.CreateSessionChannelAsync(i)); } catch (NotImplementedException) { Device.BeginInvokeOnMainThread(() => { UserDialogs.Instance.HideLoading(); }); await DisplayAlert("Error", "The Endpoint is not supported!", "ok"); return; } catch (UnsupportedEndpointException p) { Device.BeginInvokeOnMainThread(() => { UserDialogs.Instance.HideLoading(); }); await DisplayAlert("Error", p.Message, "ok"); return; } if (sessionView == null) { Device.BeginInvokeOnMainThread(() => { UserDialogs.Instance.HideLoading(); }); await DisplayAlert("Error", "Cannot connect to an OPC UA Server!", "OK"); } else { Device.BeginInvokeOnMainThread(() => { UserDialogs.Instance.HideLoading(); }); await DisplayAlert("Info", "Session created successfully!", "Ok"); ContentPage sessionPage = new SessionPage(client, sessionView); sessionPage.Title = "OPC Session Services"; await Navigation.PushAsync(sessionPage); } } else if (action.Equals("Username & Password")) { var _loginPopup = new LoginPopupPage(client, i, sessionView); await Navigation.PushPopupAsync(_loginPopup); } } catch (NullReferenceException) { } }
/// <summary> /// Helper function to process the View parameter. This method assumes the parameter is required. If it does not /// exist or is not a valid value and showErrorPage=true, the error page is shown and the method returns false. /// If false is returned, the caller should ignore the value of <param name="view"/>. /// </summary> public bool ProcessViewParameter(bool showErrorPage, out SessionView view) { return FramesetHelper.TryProcessViewParameter(showErrorPage, out view); }
public ProfilerSession(string title, ILifetimeScope scope, SessionView content) { _title = title; _scope = scope; _content = content; }