/// <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..."; } }
/// <summary> /// Adds the learner interaction to the list. /// </summary> /// /// <remarks>When a new interaction is added via the GUI, we need to add it to the list in the GUI</remarks> /// <param name="record">Record.</param> public void AddLearnerInteractionToList(StudentRecord.LearnerInteractionRecord record) { string stringInteractionsList = ""; string timeStamp = record.timeStamp.ToString(); // Get the Interaction data as strings String id = record.id; string type = record.type.ToString(); string weighting = record.weighting.ToString(); string latency = record.latency.ToString(); string description = record.description; string response = record.response; string result = record.result.ToString(); // If the Interaction result is set as the 'estimate', the result needs to be set to the numeric estimate value if (record.result == StudentRecord.ResultType.estimate) { result = record.estimate.ToString(); } string stringInteractionObjectivesList = ""; // Load the list of objectives and format it into a string if (record.objectives != null) { List <StudentRecord.LearnerInteractionObjective> interactionObjectivesList = record.objectives; if (interactionObjectivesList.Count > 0) { string stringObjectiveIds = ""; foreach (StudentRecord.LearnerInteractionObjective singleObjective in interactionObjectivesList) { stringObjectiveIds += singleObjective.id + " "; } stringInteractionObjectivesList = "Objectives (" + stringObjectiveIds + ")\n"; } } string stringInteractionCorrectResponseList = ""; // Load the list of correct response patterns and format it into a string if (record.correctResponses != null) { List <StudentRecord.LearnerInteractionCorrectResponse> interactionCorrectResponseList = record.correctResponses; if (interactionCorrectResponseList.Count > 0) { string stringPatterns = ""; foreach (StudentRecord.LearnerInteractionCorrectResponse singleCorrectResponse in interactionCorrectResponseList) { stringPatterns += singleCorrectResponse.pattern + " "; } stringInteractionCorrectResponseList = "Correct Response Patterns (" + stringPatterns + ")\n"; } } stringInteractionsList += timeStamp + " :: " + id + "\n" + description + "\n(type: " + type + " weighting: " + weighting + " latency: " + latency + "secs)\nResponse: " + response + " Result: " + result + "\n" + stringInteractionCorrectResponseList + stringInteractionObjectivesList + "\n"; // Format the entire Interaction data set as a string and add to the GUI element GameObject.Find("InteractionList").GetComponent <Text> ().text += stringInteractionsList; }
/// <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.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "You must enter a description!"; } if (weighting == "") { inputFieldWeighting.transform.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "You must enter a weighting!"; } if (studentResponse == "") { inputFieldResponse.transform.FindChild ("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.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "Description..."; inputFieldWeighting.transform.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "Weighting..."; inputFieldResponse.transform.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "Student response..."; } }
/// <summary> /// Loads the student record. /// </summary> /// <remarks>This is called on initialise and loads the SCORM data into the StudentRecord object. <see cref="Initialize_imp"/></remarks> /// <returns>The StudentRecord student record object.</returns> private static StudentRecord LoadStudentRecord() { studentRecord = new StudentRecord(); studentRecord.version = scormAPIWrapper.GetValue ("cmi._version"); //Comments From Learner int commentsFromLearnerCount = ParseInt (scormAPIWrapper.GetValue ("cmi.comments_from_learner._count")); studentRecord.commentsFromLearner = new List<StudentRecord.CommentsFromLearner>(); if (commentsFromLearnerCount != 0) { for (int i = 0; i < commentsFromLearnerCount; i++) { string comment = scormAPIWrapper.GetValue ("cmi.comments_from_learner."+i+".comment"); string location = scormAPIWrapper.GetValue ("cmi.comments_from_learner."+i+".location"); DateTime timestamp = DateTime.Parse( scormAPIWrapper.GetValue ("cmi.comments_from_learner."+i+".timestamp") ); StudentRecord.CommentsFromLearner newRecord = new StudentRecord.CommentsFromLearner(); newRecord.comment = comment; newRecord.location = location; newRecord.timeStamp = timestamp; studentRecord.commentsFromLearner.Add(newRecord); } } //Comments From LMS int commentsFromLMSCount = ParseInt (scormAPIWrapper.GetValue ("cmi.comments_from_lms._count")); studentRecord.commentsFromLMS = new List<StudentRecord.CommentsFromLMS>(); if (commentsFromLMSCount != 0) { for (int i = 0; i < commentsFromLMSCount; i++) { string comment = scormAPIWrapper.GetValue ("cmi.comments_from_lms."+i+".comment"); string location = scormAPIWrapper.GetValue ("cmi.comments_from_lms."+i+".location"); DateTime timeStamp = DateTime.Parse( scormAPIWrapper.GetValue ("cmi.comments_from_lms."+i+".timestamp") ); StudentRecord.CommentsFromLMS newRecord = new StudentRecord.CommentsFromLMS(); newRecord.comment = comment; newRecord.location = location; newRecord.timeStamp = timeStamp; studentRecord.commentsFromLMS.Add(newRecord); } } studentRecord.completionStatus = StringToCompletionStatusType (scormAPIWrapper.GetValue ("cmi.completion_status")); studentRecord.completionThreshold = ParseFloat(scormAPIWrapper.GetValue ("cmi.completion_threshold")); studentRecord.credit = StringToCreditType (scormAPIWrapper.GetValue ("cmi.credit")); studentRecord.entry = StringToEntryType (scormAPIWrapper.GetValue ("cmi.entry")); //Interactions int interactionCount = ParseInt (scormAPIWrapper.GetValue ("cmi.interactions._count")); studentRecord.interactions = new List<StudentRecord.LearnerInteractionRecord>(); if (interactionCount != 0) { for (int i = 0; i < interactionCount; i++) { string id = scormAPIWrapper.GetValue ("cmi.interactions."+i+".id"); StudentRecord.InteractionType type = StringToInteractionType( scormAPIWrapper.GetValue ("cmi.interactions."+i+".type") ); DateTime timestamp = DateTime.Parse( scormAPIWrapper.GetValue ("cmi.interactions."+i+".timestamp") ); float weighting = ParseFloat( scormAPIWrapper.GetValue ("cmi.interactions."+i+".weighting") ); string response = scormAPIWrapper.GetValue ("cmi.interactions."+i+".learner_response"); float latency = timeIntervalToSeconds ( scormAPIWrapper.GetValue ("cmi.interactions."+i+".latency") ); string description = scormAPIWrapper.GetValue ("cmi.interactions."+i+".description"); float estimate = 0; StudentRecord.ResultType result = StringToResultType(scormAPIWrapper.GetValue ("cmi.interactions."+i+".result"), out estimate); StudentRecord.LearnerInteractionRecord newRecord = new StudentRecord.LearnerInteractionRecord(); newRecord.id = id; newRecord.type = type; newRecord.timeStamp = timestamp; newRecord.weighting = weighting; newRecord.response = response; newRecord.latency = latency; newRecord.description = description; newRecord.result = result; newRecord.estimate = estimate; int interactionObjectivesCount = ParseInt (scormAPIWrapper.GetValue ("cmi.interactions."+i+".objectives._count")); newRecord.objectives = new List<StudentRecord.LearnerInteractionObjective>(); if(interactionObjectivesCount != 0) { for (int x = 0; x < interactionObjectivesCount; x++) { StudentRecord.LearnerInteractionObjective newObjective = new StudentRecord.LearnerInteractionObjective(); newObjective.id = scormAPIWrapper.GetValue ("cmi.interactions."+i+".objectives."+x+".id"); newRecord.objectives.Add(newObjective); } } int correctResponsesCount = ParseInt (scormAPIWrapper.GetValue ("cmi.interactions."+i+".correct_responses._count")); newRecord.correctResponses = new List<StudentRecord.LearnerInteractionCorrectResponse>(); if(correctResponsesCount != 0) { for (int x = 0; x < correctResponsesCount; x++) { StudentRecord.LearnerInteractionCorrectResponse newCorrectResponse = new StudentRecord.LearnerInteractionCorrectResponse(); newCorrectResponse.pattern = scormAPIWrapper.GetValue ("cmi.interactions."+i+".correct_responses."+x+".pattern"); newRecord.correctResponses.Add(newCorrectResponse); } } studentRecord.interactions.Add(newRecord); } } studentRecord.launchData = scormAPIWrapper.GetValue ("cmi.launch_data"); studentRecord.learnerID = scormAPIWrapper.GetValue ("cmi.learner_id"); studentRecord.learnerName = scormAPIWrapper.GetValue ("cmi.learner_name"); //learner_preference StudentRecord.LearnerPreference learnerPreference = new StudentRecord.LearnerPreference (); learnerPreference.audioLevel = ParseFloat (scormAPIWrapper.GetValue ("cmi.learner_preference.audio_level")); learnerPreference.langauge = scormAPIWrapper.GetValue ("cmi.learner_preference.language"); learnerPreference.deliverySpeed = ParseFloat (scormAPIWrapper.GetValue ("cmi.learner_preference.delivery_speed")); learnerPreference.audioCaptioning = ParseInt (scormAPIWrapper.GetValue ("cmi.learner_preference.audio_captioning")); studentRecord.learnerPreference = learnerPreference; studentRecord.location = scormAPIWrapper.GetValue ("cmi.location"); //Objectives int objectivesCount = ParseInt (scormAPIWrapper.GetValue ("cmi.objectives._count")); studentRecord.objectives = new List<StudentRecord.Objectives> (); if (objectivesCount != 0) { for (int i = 0; i < objectivesCount; i++) { string id = scormAPIWrapper.GetValue ("cmi.objectives."+i+".id"); StudentRecord.LearnerScore objectivesScore = new StudentRecord.LearnerScore(); objectivesScore.scaled = ParseFloat (scormAPIWrapper.GetValue ("cmi.objectives."+i+".score.scaled")); objectivesScore.raw = ParseFloat (scormAPIWrapper.GetValue ("cmi.objectives."+i+".score.raw")); objectivesScore.max = ParseFloat (scormAPIWrapper.GetValue ("cmi.objectives."+i+".score.max")); objectivesScore.min = ParseFloat (scormAPIWrapper.GetValue ("cmi.objectives."+i+".score.min")); StudentRecord.SuccessStatusType successStatus = StringToSuccessStatusType(scormAPIWrapper.GetValue ("cmi.objectives."+i+".success_status")); StudentRecord.CompletionStatusType completionStatus = StringToCompletionStatusType(scormAPIWrapper.GetValue ("cmi.objectives."+i+".completion_status")); float progressMeasure = ParseFloat (scormAPIWrapper.GetValue ("cmi.objectives."+i+".progress_measure")); string description = scormAPIWrapper.GetValue ("cmi.objectives."+i+".description"); StudentRecord.Objectives newRecord = new StudentRecord.Objectives(); newRecord.id = id; newRecord.score = objectivesScore; newRecord.successStatus = successStatus; newRecord.completionStatus = completionStatus; newRecord.progressMeasure = progressMeasure; newRecord.description = description; studentRecord.objectives.Add(newRecord); } } studentRecord.maxTimeAllowed = timeIntervalToSeconds (scormAPIWrapper.GetValue ("cmi.max_time_allowed")); studentRecord.mode = StringToModeType (scormAPIWrapper.GetValue ("cmi.mode")); studentRecord.progressMeasure = ParseFloat (scormAPIWrapper.GetValue ("cmi.progress_measure")); studentRecord.scaledPassingScore = ParseFloat(scormAPIWrapper.GetValue ("cmi.scaled_passing_score")); //Score studentRecord.learnerScore = new StudentRecord.LearnerScore (); studentRecord.learnerScore.scaled = ParseFloat (scormAPIWrapper.GetValue ("cmi.score.scaled")); studentRecord.learnerScore.raw = ParseFloat (scormAPIWrapper.GetValue ("cmi.score.raw")); studentRecord.learnerScore.max = ParseFloat (scormAPIWrapper.GetValue ("cmi.score.max")); studentRecord.learnerScore.min = ParseFloat (scormAPIWrapper.GetValue ("cmi.score.min")); studentRecord.successStatus = StringToSuccessStatusType (scormAPIWrapper.GetValue ("cmi.success_status")); studentRecord.suspendData = scormAPIWrapper.GetValue ("cmi.suspend_data"); studentRecord.timeLimitAction = StringToTimeLimitActionType (scormAPIWrapper.GetValue ("cmi.time_limit_action")); studentRecord.totalTime = timeIntervalToSeconds (scormAPIWrapper.GetValue ("cmi.total_time")); return studentRecord; }