コード例 #1
0
    /// <summary>
    /// Adds the objective to list.
    /// </summary>
    /// <remarks>When a new objective is added via the GUI, we need to add a new 'AnObjective' prefab.</remarks>
    /// <param name="index">Index.</param>
    /// <param name="newObjective">New objective.</param>
    private void AddObjectiveToList(int index, StudentRecord.Objectives newObjective)
    {
        Transform panelObjectivesList  = GameObject.Find("PanelObjectivesList").transform;
        Transform transformNewObjectve = Instantiate(AnObjective);

        transformNewObjectve.SetParent(panelObjectivesList);
        transformNewObjectve.GetComponent <AnObjective>().Initialise(index, newObjective);
    }
コード例 #2
0
    /// <summary>
    /// Initialise the specified objective.
    /// </summary>
    /// <param name="newIndex">New index.</param>
    /// <param name="newData">New data of the objective.</param>
    public void Initialise(int newIndex, StudentRecord.Objectives newData)
    {
        isInitialising = true;                                                                                                                                          // Set the isInitialising flag to true (stops the updating of the Objective while the data is loading

        index = newIndex;
        data  = newData;

        objectiveIndexGO.GetComponent <Text> ().text       = index.ToString();                          // Set the text of the Objective Index GUI Element
        objectiveIDGO.GetComponent <Text> ().text          = newData.id;                                // Set the text of the Objective ID GUI Element
        objectiveDescriptionGO.GetComponent <Text> ().text = newData.description;                       // Set the text of the Objective Description GUI Element

        objectiveScoreMinGO.GetComponent <InputField> ().text = newData.score.min.ToString();           // Set the text of the Min Score GUI Element
        objectiveScoreMaxGO.GetComponent <InputField> ().text = newData.score.max.ToString();           // Set the text of the Max Score GUI Element
        objectiveScoreRawGO.GetComponent <InputField> ().text = newData.score.raw.ToString();           // Set the text of the Raw Score GUI Element

        objectiveProgressMeasureGO.GetComponent <Slider> ().value = newData.progressMeasure;            // Set the text of the Progress Measure GUI Element

        switch (newData.successStatus)                                                                  // Set the correct Success Status toggle
        {
        case StudentRecord.SuccessStatusType.passed:
            objectiveSuccessPassedGO.GetComponent <Toggle>().isOn = true;
            break;

        case StudentRecord.SuccessStatusType.failed:
            objectiveSuccessFailedGO.GetComponent <Toggle>().isOn = true;
            break;

        case StudentRecord.SuccessStatusType.unknown:
            objectiveSuccessUnknownGO.GetComponent <Toggle>().isOn = true;
            break;
        }

        switch (newData.completionStatus)                                                                                                                       // Set the correct Completion Status toggle
        {
        case StudentRecord.CompletionStatusType.completed:
            objectiveCompletedGO.GetComponent <Toggle>().isOn = true;
            break;

        case StudentRecord.CompletionStatusType.incomplete:
            objectiveIncompleteGO.GetComponent <Toggle>().isOn = true;
            break;

        case StudentRecord.CompletionStatusType.not_attempted:
            objectiveNotAttemptedGO.GetComponent <Toggle>().isOn = true;
            break;

        case StudentRecord.CompletionStatusType.unknown:
            objectiveUnknownGO.GetComponent <Toggle>().isOn = true;
            break;
        }

        ResizeParent();                                                                                                                                                 // I could not get the Content Size Fitter working correctly on the PanelObjectivesList GUI element, calculated manually
        isInitialising = false;                                                                                                                                         // Initialise complete, update reactivated.
    }
コード例 #3
0
    /// <summary>
    /// The add objective button pressed.
    /// </summary>
    /// <remarks>Validates the input GUI elements are not empty, then adds a new objective to SCORM and the GUI</remarks>
    public void ButtonAddObjectivePressed()
    {
        GameObject inputFieldObjectiveId          = GameObject.Find("InputFieldObjectiveId");
        GameObject inputFieldObjectiveDescription = GameObject.Find("InputFieldObjectiveDescription");

        string objectiveId          = inputFieldObjectiveId.GetComponent <InputField> ().text;
        string objectiveDescription = inputFieldObjectiveDescription.GetComponent <InputField> ().text;

        if (objectiveId == "" | objectiveDescription == "")                                                                                                     // Validate the Input Elements
        {
            if (objectiveId == "")
            {
                inputFieldObjectiveId.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "You must enter an ID!";
            }
            if (objectiveDescription == "")
            {
                inputFieldObjectiveDescription.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "You must enter a description!";
            }
        }
        else                                                                                                                                                                                                    // Add the Objective
        {
            StudentRecord.Objectives newObjective = new StudentRecord.Objectives();
            newObjective.id          = objectiveId;
            newObjective.description = objectiveDescription;

            StudentRecord.LearnerScore score = new StudentRecord.LearnerScore();
            score.min    = 0f;
            score.max    = 100f;
            score.raw    = 0f;
            score.scaled = 0f;

            newObjective.score            = score;
            newObjective.successStatus    = StudentRecord.SuccessStatusType.unknown;
            newObjective.completionStatus = StudentRecord.CompletionStatusType.not_attempted;
            newObjective.progressMeasure  = 0f;

            ScormManager.AddObjective(newObjective);
            int index = ScormManager.GetObjectives().Count;
            AddObjectiveToList(index, newObjective);

            //Reset Fields
            inputFieldObjectiveId.GetComponent <InputField> ().text          = "";
            inputFieldObjectiveDescription.GetComponent <InputField> ().text = "";
            inputFieldObjectiveId.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text          = "Objective ID...";
            inputFieldObjectiveDescription.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "Objective Description...";
        }
    }
コード例 #4
0
    /// <summary>
    /// Initialise the specified objective.
    /// </summary>
    /// <param name="newIndex">New index.</param>
    /// <param name="newData">New data of the objective.</param>
    public void Initialise(int newIndex, StudentRecord.Objectives newData)
    {
        isInitialising = true;																	// Set the isInitialising flag to true (stops the updating of the Objective while the data is loading

        index = newIndex;
        data = newData;

        objectiveIndexGO.GetComponent<Text> ().text = index.ToString ();						// Set the text of the Objective Index GUI Element
        objectiveIDGO.GetComponent<Text> ().text = newData.id;									// Set the text of the Objective ID GUI Element
        objectiveDescriptionGO.GetComponent<Text> ().text = newData.description;				// Set the text of the Objective Description GUI Element

        objectiveScoreMinGO.GetComponent<InputField> ().text = newData.score.min.ToString();	// Set the text of the Min Score GUI Element
        objectiveScoreMaxGO.GetComponent<InputField> ().text = newData.score.max.ToString();	// Set the text of the Max Score GUI Element
        objectiveScoreRawGO.GetComponent<InputField> ().text = newData.score.raw.ToString();	// Set the text of the Raw Score GUI Element

        objectiveProgressMeasureGO.GetComponent<Slider> ().value = newData.progressMeasure;		// Set the text of the Progress Measure GUI Element

        switch(newData.successStatus) {															// Set the correct Success Status toggle
        case StudentRecord.SuccessStatusType.passed:
            objectiveSuccessPassedGO.GetComponent<Toggle>().isOn = true;
            break;
        case StudentRecord.SuccessStatusType.failed:
            objectiveSuccessFailedGO.GetComponent<Toggle>().isOn = true;
            break;
        case StudentRecord.SuccessStatusType.unknown:
            objectiveSuccessUnknownGO.GetComponent<Toggle>().isOn = true;
            break;
        }

        switch(newData.completionStatus) {														// Set the correct Completion Status toggle
        case StudentRecord.CompletionStatusType.completed:
            objectiveCompletedGO.GetComponent<Toggle>().isOn = true;
            break;
        case StudentRecord.CompletionStatusType.incomplete:
            objectiveIncompleteGO.GetComponent<Toggle>().isOn = true;
            break;
        case StudentRecord.CompletionStatusType.not_attempted:
            objectiveNotAttemptedGO.GetComponent<Toggle>().isOn = true;
            break;
        case StudentRecord.CompletionStatusType.unknown:
            objectiveUnknownGO.GetComponent<Toggle>().isOn = true;
            break;
        }

        ResizeParent ();																		// I could not get the Content Size Fitter working correctly on the PanelObjectivesList GUI element, calculated manually
        isInitialising = false;																	// Initialise complete, update reactivated.
    }
コード例 #5
0
    /// <summary>
    /// The add objective button pressed.
    /// </summary>
    /// <remarks>Validates the input GUI elements are not empty, then adds a new objective to SCORM and the GUI</remarks>
    public void ButtonAddObjectivePressed()
    {
        GameObject inputFieldObjectiveId = GameObject.Find ("InputFieldObjectiveId");
        GameObject inputFieldObjectiveDescription = GameObject.Find ("InputFieldObjectiveDescription");

        string objectiveId = inputFieldObjectiveId.GetComponent<InputField> ().text;
        string objectiveDescription = inputFieldObjectiveDescription.GetComponent<InputField> ().text;

        if (objectiveId == "" | objectiveDescription == "") {												// Validate the Input Elements
            if (objectiveId == "") {
                inputFieldObjectiveId.transform.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "You must enter an ID!";
            }
            if (objectiveDescription == "") {
                inputFieldObjectiveDescription.transform.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "You must enter a description!";
            }
        } else {																							// Add the Objective
            StudentRecord.Objectives newObjective = new StudentRecord.Objectives();
            newObjective.id = objectiveId;
            newObjective.description = objectiveDescription;

            StudentRecord.LearnerScore score = new StudentRecord.LearnerScore();
            score.min = 0f;
            score.max = 100f;
            score.raw = 0f;
            score.scaled = 0f;

            newObjective.score = score;
            newObjective.successStatus = StudentRecord.SuccessStatusType.unknown;
            newObjective.completionStatus = StudentRecord.CompletionStatusType.not_attempted;
            newObjective.progressMeasure = 0f;

            ScormManager.AddObjective(newObjective);
            int index = ScormManager.GetObjectives().Count;
            AddObjectiveToList(index, newObjective);

            //Reset Fields
            inputFieldObjectiveId.GetComponent<InputField> ().text = "";
            inputFieldObjectiveDescription.GetComponent<InputField> ().text = "";
            inputFieldObjectiveId.transform.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "Objective ID...";
            inputFieldObjectiveDescription.transform.FindChild ("Placeholder").gameObject.GetComponent<Text> ().text = "Objective Description...";
        }
    }
コード例 #6
0
    /// <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;
    }