/// <summary> /// The add interaction button pressed. /// </summary> /// <remarks>Validates the input GUI elements are not empty, then adds a new interaction to SCORM and the GUI</remarks> public void ButtonAddInteractionPressed() { GameObject inputFieldDescription = GameObject.Find("InputFieldDescription"); GameObject inputFieldWeighting = GameObject.Find("InputFieldWeighting"); GameObject inputFieldResponse = GameObject.Find("InputFieldResponse"); GameObject toggleCorrect = GameObject.Find("ToggleCorrect"); string description = inputFieldDescription.GetComponent <InputField>().text; string weighting = inputFieldWeighting.GetComponent <InputField>().text; string studentResponse = inputFieldResponse.GetComponent <InputField>().text; bool correct = toggleCorrect.GetComponent <Toggle>().isOn; if (description == "" | weighting == "" | studentResponse == "") // Validate the Input Elements { if (description == "") { inputFieldDescription.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "You must enter a description!"; } if (weighting == "") { inputFieldWeighting.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "You must enter a weighting!"; } if (studentResponse == "") { inputFieldResponse.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "You must enter a student response!"; } } else // Add the Interaction { StudentRecord.LearnerInteractionRecord newInteraction = new StudentRecord.LearnerInteractionRecord(); newInteraction.id = ScormManager.GetNextInteractionId(); newInteraction.timeStamp = DateTime.Now; newInteraction.type = StudentRecord.InteractionType.other; newInteraction.weighting = float.Parse(weighting); newInteraction.response = studentResponse; newInteraction.latency = 18.4f; newInteraction.description = description; StudentRecord.ResultType result = StudentRecord.ResultType.incorrect; if (correct) { result = StudentRecord.ResultType.correct; } newInteraction.result = result; ScormManager.AddInteraction(newInteraction); AddLearnerInteractionToList(newInteraction); //Reset inputFieldDescription.GetComponent <InputField>().text = ""; inputFieldWeighting.GetComponent <InputField>().text = ""; inputFieldResponse.GetComponent <InputField>().text = ""; toggleCorrect.GetComponent <Toggle>().isOn = true; inputFieldDescription.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "Description..."; inputFieldWeighting.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "Weighting..."; inputFieldResponse.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "Student response..."; } }