public void EndExperiment() { experimentStatus = ExperimentStatus.INACTIVE; phraseConsole.SetActive(false); if (_path.Length != 0) { try { FileStream fileStream = File.Open(_path, FileMode.Append, FileAccess.Write); StreamWriter fileWriter = new StreamWriter(fileStream); fileWriter.WriteLine(experimentMode + "," + experiment.participant + "," + experiment.phrase + "," + experiment.date + "," + experiment.time); ExperimentSample firstSample = experiment.samples[0]; foreach (ExperimentSample sample in experiment.samples) { fileWriter.WriteLine((sample.timestamp - firstSample.timestamp) + "," + sample.character); } fileWriter.Flush(); fileWriter.Close(); } catch (IOException ioe) { Console.WriteLine(ioe); } } }
/// <summary> /// Sets the controls to the data stored in the given object. /// </summary> /// <param name="data">The data to set.</param> private void ApplyExperimentSample(ExperimentSample sample) { m_txt_name.Text = sample.Name ?? ""; m_txt_sample.Text = sample.SampleText ?? ""; m_qeditor_sample.Items.Clear(); if (sample.Questions != null) { m_qeditor_sample.Items.AddRange(sample.Questions.Values); } }
/// <summary> /// Updates the current sample with the selected text and questions. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Event_btn_updsample_Click(object sender, RoutedEventArgs e) { if (!FullExperimentSample()) { MessageBox.Show("Please make sure every control has a value.", "Missing sample data", MessageBoxButton.OK, MessageBoxImage.Warning); } else { ExperimentSample sample = CurrentExperimentSample(); sample.Id = m_samples[m_lstbx_samples.SelectedIndex].Id; m_samples[m_lstbx_samples.SelectedIndex] = sample; } }
private void SwypeButtonRelease() { ExperimentSample experimentSample = new ExperimentSample(); experimentSample.character = "RELEASE"; experimentSample.timestamp = Time.realtimeSinceStartup; _currentPressed = false; experiment.samples.Add(experimentSample); if (_currentString.Length > 0) { if (_swypeKeyboard.GetSuggestion(_selectedSwipeType, _currentString, _targetWords[_swypeCurrentIndex])) { ExperimentSample experimentSample2 = new ExperimentSample(); experimentSample2.character = ("CORRECT," + _currentString + "," + _targetWords[_swypeCurrentIndex]); experimentSample2.timestamp = Time.realtimeSinceStartup; experiment.samples.Add(experimentSample2); _audioSource.PlayOneShot(correctBell); _currentString = ""; outputPhraseText.text += " " + _targetWords[_swypeCurrentIndex++]; if (_swypeCurrentIndex >= _targetWords.Length) { EndExperiment(); } } else { ExperimentSample experimentSample2 = new ExperimentSample(); experimentSample2.character = ("INVALID," + _currentString + "," + _targetWords[_swypeCurrentIndex]); experimentSample2.timestamp = Time.realtimeSinceStartup; experiment.samples.Add(experimentSample2); _currentString = ""; _audioSource.PlayOneShot(incorrectBell); } } }
private void InsertStringNormalKeyboard(string value) { if (value.Equals("UNDO")) { _currentString = _currentString.Substring(0, _currentString.Length - 1); } else { _currentString += value; } ExperimentSample experimentSample = new ExperimentSample(); experimentSample.character = value; experimentSample.timestamp = Time.realtimeSinceStartup; experiment.samples.Add(experimentSample); if (_currentString.Equals(_targetString)) { Debug.Log("Ukonczono"); outputPhraseText.text = ""; EndExperiment(); } if (_currentString.Equals(_targetString.Substring(0, _currentString.Length))) { _audioSource.PlayOneShot(correctBell); } else { _audioSource.PlayOneShot(incorrectBell); } outputPhraseText.text = _currentString; }
private void Update() { _isPressedButton = Input.GetKey(KeyCode.JoystickButton15); _isButtonReleased = Input.GetKeyUp(KeyCode.JoystickButton15); if (_isPressedButton && experimentStatus == ExperimentStatus.ACTIVE_SWYPE) { if (!_currentPressed) { _currentPressed = true; ExperimentSample experimentSample = new ExperimentSample(); experimentSample.character = "PRESSED"; experimentSample.timestamp = Time.realtimeSinceStartup; experiment.samples.Add(experimentSample); } } if (_isButtonReleased && experimentStatus == ExperimentStatus.ACTIVE_SWYPE) { SwypeButtonRelease(); } }