コード例 #1
0
    /// <summary>
    /// Loads the objectives from SCORM.
    /// </summary>
    /// <remarks>Load the objectives from SCORM and add a new 'AnObjective' prefab for each objective</remarks>
    private void LoadObjectives()
    {
        Transform panelObjectivesList = GameObject.Find("PanelObjectivesList").transform;

        int count = 0;
        List <StudentRecord.Objectives> objectivesList = ScormManager.GetObjectives();

        foreach (StudentRecord.Objectives objective in objectivesList)
        {
            Transform NewObjectve = Instantiate(AnObjective);
            NewObjectve.SetParent(panelObjectivesList);
            NewObjectve.GetComponent <AnObjective>().Initialise(count, objective);
            count++;
        }
    }
コード例 #2
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...";
        }
    }