public void interactionsLongFillIn()
        {
            LETSIRTE_Service client = getClient();

            string intFillInID = "Long_FillIn";

            cocdType        cocd  = client.Get();
            interactionType inter = cocd.GetInteraction(intFillInID, true);

            inter.type             = interactionTypeType.long_fill_in;
            inter.correctResponses = new correctResponsesType();
            inter.correctResponses.ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.correctResponseLongFillIn, ItemsChoiceType.correctResponseLongFillIn };
            correctResponsesTypeCorrectResponseLongFillIn rsp  = new correctResponsesTypeCorrectResponseLongFillIn();
            correctResponsesTypeCorrectResponseLongFillIn rsp2 = new correctResponsesTypeCorrectResponseLongFillIn();

            inter.correctResponses.Items = new object[] { rsp, rsp2 };

            rsp.Value  = "answer 1";
            rsp2.Value = "answer 2";

            inter.description       = new interactionTypeDescription();
            inter.description.Value = "long fillin interaction";
            inter.learnerResponse   = new learnerResponseType();
            inter.learnerResponse.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.learnerResponseLongFillIn };
            learnerResponseTypeLearnerResponseLongFillIn lrsp = new learnerResponseTypeLearnerResponseLongFillIn();

            inter.learnerResponse.Items = new object[] { lrsp };

            lrsp.Value = "answer 2";

            inter.result          = interactionTypeResult.correct;
            inter.resultSpecified = true;


            Assert.IsNotNull(inter, "inter");
            Assert.IsNotNull(inter.correctResponses, "inter.correctResponses");
            Assert.IsNotNull(inter.correctResponses.Items, "inter.correctResponses.Items");
            Assert.AreEqual(2, inter.correctResponses.Items.Length, "correct response count");
            Assert.AreEqual(1, inter.learnerResponse.Items.Length, "learner response count");
            Assert.AreEqual("answer 1", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[0]).Value, "correct response 1");
            Assert.AreEqual("answer 2", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[1]).Value, "correct response 2");
            Assert.AreEqual("answer 2", ((learnerResponseTypeLearnerResponseLongFillIn)inter.learnerResponse.Items[0]).Value, "learner response");


            cocd.exit          = exit.suspend;
            cocd.exitSpecified = true;
            client.Set(cocd);
            cocd = client.Get();

            inter = cocd.GetInteraction(intFillInID, false);
            Assert.IsNotNull(inter, "inter");
            Assert.IsNotNull(inter.correctResponses, "inter.correctResponses");
            Assert.IsNotNull(inter.correctResponses.Items, "inter.correctResponses.Items");
            Assert.AreEqual(2, inter.correctResponses.Items.Length, "correct response count");
            Assert.AreEqual(1, inter.learnerResponse.Items.Length, "learner response count");
            Assert.AreEqual("answer 1", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[0]).Value, "correct response 1");
            Assert.AreEqual("answer 2", ((correctResponsesTypeCorrectResponseLongFillIn)inter.correctResponses.Items[1]).Value, "correct response 2");
            Assert.AreEqual("answer 2", ((learnerResponseTypeLearnerResponseLongFillIn)inter.learnerResponse.Items[0]).Value, "learner response");
        }
Beispiel #2
0
    ///<summary>
    ///Add an interaction to the course data.
    ///</summary>
    ///<returns>
    ///A new interaction object.
    ///</returns>
    ///<remarks>
    ///The new interaction object created is added into the array, it is not necessary to add it
    ///again manually. The identifier is generated automatically, as is the timestamp.
    ///The new interaction is the LongFillIn type. You will have to get deeper into the SCORM for
    ///other types. Note that if you wish to set the LearnerResponse values, you need to cast
    ///interaction.learner_response to learnerResponseTypeLearnerResponseLongFillIn
    ///</remarks>
    public static interactionType AddInteraction()
    {
        interactionType i = new interactionType();

        i.id = "urn:ADL:interaction-id-" + GetLearnerRecord().interactions.Count.ToString();
        learnerResponseTypeLearnerResponseLongFillIn lrs = new learnerResponseTypeLearnerResponseLongFillIn();

        lrs.Value          = "this is the data that should be in the answer";
        lrs.lang           = "en-US";
        i.learner_response = lrs;
        i.objectives       = new System.Collections.Generic.List <objectiveIDType>();
        i.result           = interactionTypeResult.incorrect;

        i.timestamp         = new Scorm2004.DateTime(System.DateTime.Now);
        i.type              = interactionTypeType.long_fill_in;
        i.weighting         = new System.Decimal(100);
        i.description.lang  = "en-US";
        i.description.Value = "this is the description for the interaction";

        GetLearnerRecord().interactions.Add(i);
        return(i);
    }