/// <summary> /// Ends the experiment session. /// </summary> public void End() { if (hasInitialised) { isEnding = true; if (InTrial) { try { CurrentTrial.End(); } catch (Exception e) { Debug.LogException(e); } } SaveResults(); try { preSessionEnd.Invoke(this); } catch (Exception e) { Debug.LogException(e); } // end DataHandler - forces completion of tasks foreach (var dataHandler in ActiveDataHandlers) { dataHandler.CleanUp(); } try { onSessionEnd.Invoke(this); } catch (Exception e) { Debug.LogException(e); } currentTrialNum = 0; currentBlockNum = 0; blocks = new List <Block>(); _hasInitialised = false; Debug.Log("Ended session."); isEnding = false; } }
/// <summary> /// Ends the experiment session. /// </summary> public void End() { if (hasInitialised) { if (InTrial) { CurrentTrial.End(); } SaveResults(); // raise cleanup event if (cleanUp != null) { cleanUp(); } // end FileIOManager - forces immediate writing of all files fileIOManager.End(); onSessionEnd.Invoke(this); currentTrialNum = 0; currentBlockNum = 0; blocks = new List <Block>(); _hasInitialised = false; Debug.Log("Ended session."); } }
/// <summary> /// Ends the experiment session. /// </summary> public void End() { if (hasInitialised) { isEnding = true; if (InTrial) { try { CurrentTrial.End(); } catch (Exception e) { Debug.LogException(e); } } SaveResults(); try { preSessionEnd.Invoke(this); } catch (Exception e) { Debug.LogException(e); } if (storeSessionSettings) { // copy Settings to session folder SaveJSONSerializableObject(new Dictionary <string, object>(settings.baseDict), "settings", dataType: UXFDataType.Settings); } if (storeParticipantDetails) { // copy participant details to session folder // we convert to a DataTable because we know the dictionary will be "flat" (one value per key) UXFDataTable ppDetailsTable = new UXFDataTable(participantDetails.Keys.ToArray()); var row = new UXFDataRow(); foreach (var kvp in participantDetails) { row.Add((kvp.Key, kvp.Value)); } ppDetailsTable.AddCompleteRow(row); var ppDetailsLines = ppDetailsTable.GetCSVLines(); SaveDataTable(ppDetailsTable, "participant_details", dataType: UXFDataType.ParticipantDetails); } // end DataHandlers - forces completion of tasks foreach (var dataHandler in ActiveDataHandlers) { try { dataHandler.CleanUp(); } catch (Exception e) { Debug.LogException(e); } } try { onSessionEnd.Invoke(this); } catch (Exception e) { Debug.LogException(e); } currentTrialNum = 0; currentBlockNum = 0; blocks = new List <Block>(); _hasInitialised = false; Utilities.UXFDebugLog("Ended session."); isEnding = false; } }
public void BeginPreloadedEvent(GameObject loadToMe) { loadOnThis = loadToMe; if (CurrentTrial != null) { Debug.Log("Beginning Preloaded Trial: " + CurrentTrial.Name); CurrentTrial.Setup(); } }
public override bool EndCurrentTrial() { if (CurrentTrainingLevel <= MaxTrainingLevels) { CurrentTrainingLevel++; CurrentTrial.Close(); return(false); } return(base.EndCurrentTrial()); }
public void BeginEvent(Type t) { if (CurrentTrial != null) { CurrentTrial.Cleanup(); } gameObject.AddComponent(t); Debug.Log("Beginning Trial: " + CurrentTrial.Name); CurrentTrial.Setup(); }
public void Update(float DeltaTime) { if (Replay.IsReady) { Replay.WriteCurrentState(); } if (TrialCount > 0) { CurrentTrial.Update(DeltaTime); } }
public virtual bool EndCurrentTrial() { CurrentTrial.Close(); return(false); }
public override bool EndCurrentTrial() { var trial = CurrentTrial as SelectionTrial; if (trial.Answer == ITrial.AnswerType.CORRECT && CurrentLevel >= StartLevel) { points++; } if (trial.Answer != ITrial.AnswerType.CORRECT && CurrentLevel < StartLevel) { points--; } //1st iteration if (CurrentLevel == StartLevel) { CurrentLevel++; } //2nd iteration else if (CurrentLevel == StartLevel + 1) { var prevTrial = Trials[Trials.Count - 2] as SelectionTrial; if (trial.Answer == ITrial.AnswerType.CORRECT && prevTrial.Answer == ITrial.AnswerType.CORRECT) { CurrentLevel = StartLevel + 2; } else { CurrentLevel = StartLevel - 1; } } //begin backwards movement else if (CurrentLevel == StartLevel - 1) { CurrentLevel--; } //continue backwards movement else if (CurrentLevel < StartLevel - 1) { var prevTrial = Trials[Trials.Count - 2] as SelectionTrial; if (trial.Answer == ITrial.AnswerType.CORRECT && prevTrial.Answer == ITrial.AnswerType.CORRECT) { CurrentLevel = StartLevel + 2; } else { CurrentLevel--; } } //forward movement else { var trial2 = Trials[Trials.Count - 2] as SelectionTrial; var trial3 = Trials[Trials.Count - 3] as SelectionTrial; if (trial.Answer != ITrial.AnswerType.CORRECT && trial2.Answer != ITrial.AnswerType.CORRECT && trial3.Answer != ITrial.AnswerType.CORRECT) { CurrentTrial.Close(); return(true); } else { CurrentLevel++; } } return(base.EndCurrentTrial()); }
/// <summary> /// Ends currently running trial. Useful to call from an inspector event /// </summary> public void EndCurrentTrial() { CurrentTrial.End(); }
//Go to the next trial //Return false if this is the end of the experimentation public bool NextTrial() { //if there's a current trial (may be we are at the beginning of the manip) and if the current trial has failed we have to do some stuff if (CurrentTrial != null && !CurrentTrial.Success) { if (_replayFailedTrialType != ReplayFailedTrialType.DoNot) { CurrentTrial.ResetState(); _failedTrialIndexes.Add(CurrentTrial.Index); } } //if we are playing the failed trials we check if there's again failed trial if (_replayFailedTrials) { _failedTrialIndexes.RemoveAt(0); //we remove the previous index if (_failedTrialIndexes.Count == 0) //it was the last failed trial { _replayFailedTrials = false; } else { //we have to replay the next failed trial _order++; CurrentTrial.Order = _order; return(true); } } if (_replayFailedTrialType == ReplayFailedTrialType.AtTheEndOfBlock && (_trialIndex + 1) % _blockSize == 0) //if we are at the end of blocks { if (_failedTrialIndexes.Count > 0) //if there's failed trials we have to play them { _replayFailedTrials = true; } else { if (_trialIndex == _trials.Count - 1) { return(false); } _trialIndex++;//we continue to the next trial of the next block; } } else if (_replayFailedTrialType == ReplayFailedTrialType.AtTheEnd && _trialIndex == _trials.Count - 1) //if we are at the end of manip { if (_failedTrialIndexes.Count > 0) //if there's failed trials we have to play them { _replayFailedTrials = true; } else { //it's finished! we have nothing to do return(false);//we don't have to affect the order at the end of this method } } else if (_replayFailedTrialType == ReplayFailedTrialType.JustAfter && CurrentTrial != null && !CurrentTrial.Success)//if the current trial failed and we have to play it now { _replayFailedTrials = true; } else //else we continue as normal { if (_trialIndex == _trials.Count - 1) { return(false); } _trialIndex++; } //in every case, we increase the order _order++; CurrentTrial.Order = _order; return(true); }
public void EventFinished() { CurrentTrial.Cleanup(); Debug.Log("Trial Complete!"); }
public void EventFailed() { CurrentTrial.Cleanup(); Debug.Log("Trial Failed..."); }