Exemplo n.º 1
0
 virtual protected void GradeQuestion()
 {
     if (IsCaseSensitive)
     {
         Correctness = (ResponseText == CorrectResponse) ? 1.0 : 0.0;
     }
     else
     {
         Correctness = (ResponseText.ToLower() == CorrectResponse.ToLower()) ? 1.0 : 0.0;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Method to ask the question to grade itself. Marked virtual because different
 /// types of question may have different types of grading.
 /// </summary>
 virtual protected void GradeQuestion()
 {
     // By default, simply compare the user's response to the correct response
     if (IsCaseSensitive)
     {
         Correctness = (ResponseText == CorrectResponse) ? 1.0 : 0.0;
     }
     else
     {
         Correctness = (ResponseText.ToLower() == CorrectResponse.ToLower()) ? 1.0 : 0.0;
     }
 }
    protected override IEnumerator ForcedSolveIEnumerator()
    {
        yield return(null);

        while (State != TwoBitsState.Complete)
        {
            if (CurrentQuery.StartsWith("_") && State == TwoBitsState.Idle)
            {
                yield return(DoInteractionClick(_buttons[ButtonLabels.IndexOf(CorrectResponse.Substring(0, 1), StringComparison.Ordinal)]));
            }
            if (CurrentQuery.EndsWith("_") && State == TwoBitsState.Idle)
            {
                yield return(DoInteractionClick(_buttons[ButtonLabels.IndexOf(CorrectResponse.Substring(1, 1), StringComparison.Ordinal)]));
            }
            if (State == TwoBitsState.Idle)
            {
                yield return(CorrectResponse.Equals(CurrentQuery) ? DoInteractionClick(_submit) : DoInteractionClick(_query));
            }

            yield return(true);
        }
    }
    protected internal override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        var split = inputCommand.ToLowerInvariant().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

        if (split.Length < 2 || split[0] != "press")
        {
            yield break;
        }

        foreach (string x in split.Skip(1))
        {
            switch (x)
            {
            case "query":
            case "submit":
                break;

            default:
                foreach (char y in x)
                {
                    if (!ButtonLabels.Contains(y))
                    {
                        yield break;
                    }
                }
                break;
            }
        }

        yield return("Two Bits Solve Attempt");

        foreach (string x in split.Skip(1))
        {
            switch (x)
            {
            case "query":
                yield return(DoInteractionClick(_query));

                break;

            case "submit":
                yield return(DoInteractionClick(_submit));

                break;

            default:
                foreach (char y in x)
                {
                    yield return(DoInteractionClick(_buttons[ButtonLabels.IndexOf(y)]));

                    if (State == TwoBitsState.ShowingError || State == TwoBitsState.Inactive)
                    {
                        yield break;
                    }
                }
                break;
            }
            yield return(new WaitForSeconds(0.1f));
        }

        if (State == TwoBitsState.SubmittingResult)
        {
            yield return(CorrectResponse.Equals(CurrentQuery) ? "solve" : "strike");
        }
    }
Exemplo n.º 5
0
        /// <summary>
        /// Return the encoded string of all current data model values to pass to the client. This method
        /// reinitializes the ObjectiveIndexer and InteractionIndexer values.
        /// </summary>
        public override DataModelValues GetDataModelValues(AddDataModelValue addDataModelValue)
        {
            StringBuilder dataModelValuesBuffer = new StringBuilder(4096); // data model values
            string        n;

            LearningDataModel dm = this.DataModel;

            Learner learner = dm.Learner;

            addDataModelValue(dataModelValuesBuffer, "cmi.core.student_id", learner.Id);
            addDataModelValue(dataModelValuesBuffer, "cmi.core.student_name", learner.Name);

            // cmi.core values
            addDataModelValue(dataModelValuesBuffer, "cmi.core.lesson_location", dm.Location);
            addDataModelValue(dataModelValuesBuffer, "cmi.core.credit", GetRteCredit(dm.Credit, this.View));
            addDataModelValue(dataModelValuesBuffer, "cmi.core.lesson_status", GetRteLessonStatus(dm.LessonStatus));
            addDataModelValue(dataModelValuesBuffer, "cmi.core.entry", GetRteEntry(dm.Entry));

            AddDataModelScore(addDataModelValue, dataModelValuesBuffer, "cmi.core.score", dm.Score);

            addDataModelValue(dataModelValuesBuffer, "cmi.core.total_time", GetRteTimeSpan(dm.TotalTime));
            addDataModelValue(dataModelValuesBuffer, "cmi.core.lesson_mode", GetRteMode(this.View));

            addDataModelValue(dataModelValuesBuffer, "cmi.suspend_data", dm.SuspendData);
            addDataModelValue(dataModelValuesBuffer, "cmi.launch_data", dm.LaunchData);
            addDataModelValue(dataModelValuesBuffer, "cmi.comments", GetRteComment(dm.CommentsFromLearner));
            addDataModelValue(dataModelValuesBuffer, "cmi.comments_from_lms", GetRteCommentFromLms(dm.CommentsFromLms));

            int objCountOrig     = dm.Objectives.Count; // num objectives in data model
            int objCountToClient = 0;                   // num objectives sent to client

            for (int i = 0; i < objCountOrig; i++)
            {
                Objective objective = dm.Objectives[i];

                n = XmlConvert.ToString(objCountToClient);
                addDataModelValue(
                    dataModelValuesBuffer, ResHelper.FormatInvariant("cmi.objectives.{0}.id", n), objective.Id);

                AddDataModelScore(
                    addDataModelValue,
                    dataModelValuesBuffer,
                    ResHelper.FormatInvariant("cmi.objectives.{0}.score", n),
                    objective.Score);

                if (objective.Status != null)
                {
                    addDataModelValue(
                        dataModelValuesBuffer,
                        ResHelper.FormatInvariant("cmi.objectives.{0}.status", n),
                        GetRteLessonStatus(objective.Status.Value));
                }

                objCountToClient++;
            }
            addDataModelValue(dataModelValuesBuffer, "cmi.objectives._count", RteIntValue(objCountToClient));

            // cmi.student_data
            addDataModelValue(dataModelValuesBuffer, "cmi.student_data.mastery_score", GetRteFloat(dm.MasteryScore));
            addDataModelValue(
                dataModelValuesBuffer, "cmi.student_data.max_time_allowed", GetRteTimeSpan(dm.MaxTimeAllowed));
            addDataModelValue(
                dataModelValuesBuffer, "cmi.student_data.time_limit_action", GetTimeLimitAction(dm.TimeLimitAction));

            // cmi.student_preference
            addDataModelValue(dataModelValuesBuffer, "cmi.student_preference.audio", GetRteFloat(learner.AudioLevel));
            addDataModelValue(dataModelValuesBuffer, "cmi.student_preference.language", learner.Language);
            addDataModelValue(dataModelValuesBuffer, "cmi.student_preference.speed", GetRteFloat(learner.DeliverySpeed));
            addDataModelValue(
                dataModelValuesBuffer, "cmi.student_preference.text", GetRteAudioCaptioning(learner.AudioCaptioning));

            // Interactions
            int numInterations = dm.Interactions.Count;

            addDataModelValue(
                dataModelValuesBuffer,
                "cmi.interactions._count",
                numInterations.ToString(NumberFormatInfo.InvariantInfo));

            int count = 0;

            foreach (Interaction interaction in dm.Interactions)
            {
                n = XmlConvert.ToString(count);

                // Not intuitive: interaction.n.id, time, weighting, student_response and type are write only in Scorm 1.2, so don't add them here.

                int numObjectives = interaction.Objectives.Count;
                for (int j = 0; j < numObjectives; j++)
                {
                    InteractionObjective obj = interaction.Objectives[j];
                    addDataModelValue(
                        dataModelValuesBuffer,
                        ResHelper.FormatInvariant("cmi.interactions.{0}.objectives.{1}.id", n, RteIntValue(j)),
                        obj.Id);
                }
                addDataModelValue(
                    dataModelValuesBuffer,
                    ResHelper.FormatInvariant("cmi.interactions.{0}.objectives._count", n),
                    RteIntValue(numObjectives));

                int numResponses = interaction.CorrectResponses.Count;
                addDataModelValue(
                    dataModelValuesBuffer,
                    ResHelper.FormatInvariant("cmi.interactions.{0}.correct_responses._count", n),
                    RteIntValue(numResponses));
                for (int resI = 0; resI < numResponses; resI++)
                {
                    CorrectResponse response = interaction.CorrectResponses[resI];
                    if (response.Pattern != null)
                    {
                        addDataModelValue(
                            dataModelValuesBuffer,
                            ResHelper.FormatInvariant("cmi.interactions.{0}.correct_responses.{1}.pattern", n, RteIntValue(resI)),
                            response.Pattern);
                    }
                }

                count++;
            } // end interactions

            return(new DataModelValues(new PlainTextString(dataModelValuesBuffer.ToString())));
        }