コード例 #1
0
 /// <summary>
 /// Constructor. Create a converter based on a data model.
 /// </summary>
 protected RteDataModelConverter(SessionView view, LearningDataModel dataModel)
 {
     this.mDm   = dataModel;
     this.mView = view;
     this.mPendingInteractions = new List <Interaction>();
     this.mPendingObjectives   = new List <Objective>();
 }
コード例 #2
0
 /// <summary>
 /// Constructor. Create a converter based on a data model.
 /// </summary>
 protected RteDataModelConverter(SessionView view, LearningDataModel dataModel)
 {
     m_dm   = dataModel;
     m_view = view;
     m_pendingInteractions = new List <Interaction>();
     m_pendingObjectives   = new List <Objective>();
 }
コード例 #3
0
 /// <summary>
 /// Constructor. Create a converter based on a data model.
 /// </summary>
 protected RteDataModelConverter(SessionView view, LearningDataModel dataModel)
 {
     this.mDm = dataModel;
     this.mView = view;
     this.mPendingInteractions = new List<Interaction>();
     this.mPendingObjectives = new List<Objective>();
 }
コード例 #4
0
 /// <summary>
 /// Constructor. Create a converter based on a data model.
 /// </summary>
 protected RteDataModelConverter(SessionView view, LearningDataModel dataModel) 
 {
     m_dm = dataModel;
     m_view = view;
     m_pendingInteractions = new List<Interaction>();
     m_pendingObjectives = new List<Objective>();
 }      
コード例 #5
0
ファイル: Activity.cs プロジェクト: nbl852003/iudico
        /// <summary>
        /// Initializes an Activity object for cloning.
        /// </summary>
        /// <param name="owner">The owner of this actitity tree.</param>
        /// <param name="activityId">The unique identifier of this activity.</param>
        /// <param name="rawStaticData">Refers to an xml block in Static Activity XML format.</param>
        /// <param name="rawSequencingData">Refers to an xml block in Sequencing Activity XML format.</param>
        /// <param name="randomPlacement">Random placement of this activity within its parent, or -1 if the original placement is to be used.</param>
        internal Activity(Navigator owner, long activityId, XPathNavigator rawStaticData,
                          XPathNavigator rawSequencingData, int randomPlacement)
        {
            m_owner        = owner;
            m_activityId   = activityId;
            m_rawStaticXml = rawStaticData;
            PackageFormat format;

            if (owner.PackageFormat == PackageFormat.V1p2)
            {
                if (GetResourceType(m_rawStaticXml) == ResourceType.Lrm)
                {
                    format = PackageFormat.Lrm;
                }
                else
                {
                    format = PackageFormat.V1p2;
                }
            }
            else
            {
                format = owner.PackageFormat;
            }
            m_dataModel = new LearningDataModel(format, m_rawStaticXml, rawSequencingData,
                                                null, null, null, null, DataModelWriteValidationMode.AlwaysAllowWrite, String.Empty, String.Empty, String.Empty,
                                                AudioCaptioning.NoChange, (float)1.0, (float)1.0);
            m_randomPlacement = randomPlacement;
            // only call the following after m_rawStaticXml is set.
            m_dataModel.Tracked = Sequencing.Tracked;
            m_dataModel.CompletionSetByContent = Sequencing.CompletionSetByContent;
            m_dataModel.ObjectiveSetByContent  = Sequencing.ObjectiveSetByContent;
        }
コード例 #6
0
        /// <summary>
        /// Process data returned from a form generated by an instance of this class. Also sets the data model's
        /// evaluation points field to the total points, computed from the autograding or teacher grading.
        /// </summary>
        /// <param name="context">
        /// The context within which to process the form data. </param>
        /// <param name="formData">The collection of information from the form that should be processed.</param>
        /// <param name="files">Collection of valid files, posted from the request. This may be a subset of the files
        /// included in the request, as some posted files may have been removed by the application as invalid.</param>
        /// <remarks>
        /// <p>Data that does not correspond to expected information is ignored.</p>
        /// </remarks>
        /// <exception cref="InvalidFormDataException">Thrown if posted data contains invalid data.</exception>
        public override void ProcessFormData(RloProcessFormDataContext context, NameValueCollection formData, IDictionary <string, HttpPostedFile> files)
        {
            // Do two passes here through all the interactions. This allows detecting any error in the posted data
            // before making changes to the data model based on posted data

            AssessmentItemManager.ProcessFormContext = context;

            LearningDataModel learningDataModel = context.LearningDataModel;

            // Validate the form data for all interactions. Any validation error throws InvalidFormDataException.
            foreach (Interaction interaction in learningDataModel.Interactions)
            {
                FormDataProcessor processor = m_assessmentItemMgr.GetFormDataProcessor(interaction);
                // must check that processor is non null, since GetFormDataProcessor() can return null
                if (processor != null)
                {
                    processor.ValidateFormData(formData, files); // throws exception if not valid
                }
            }
            // Process the form data.  This won't execute if ValidateFormData threw and exception, above.
            // Keep a running sum the Interaction.Evaluation.Points values to set the page's Points value.
            float?totalPoints = null;

            foreach (Interaction interaction in learningDataModel.Interactions)
            {
                FormDataProcessor processor = m_assessmentItemMgr.GetFormDataProcessor(interaction);
                // must check that processor is non null, since GetFormDataProcessor() can return null.
                // If it is null, any item score associated with this interaction is not totalled into
                // EvaluationPoints.
                if (processor != null)
                {
                    processor.ProcessFormData(formData, files);
                    if (interaction.Evaluation.Points.HasValue)
                    {
                        if (totalPoints.HasValue)
                        {
                            totalPoints += interaction.Evaluation.Points.Value;
                        }
                        else
                        {
                            totalPoints = interaction.Evaluation.Points.Value;
                        }
                    }
                }
            }
            learningDataModel.EvaluationPoints = totalPoints;

            if (context.View == SessionView.Execute)
            {
                SetPageHasBeenAutograded(learningDataModel);
            }
        }
コード例 #7
0
ファイル: Activity.cs プロジェクト: nbl852003/iudico
        /// <summary>
        /// Initializes an Activity object.
        /// </summary>
        /// <param name="owner">The owner of this actitity tree.</param>
        /// <param name="activityId">The unique identifier of this activity.</param>
        /// <param name="rawStaticData">Refers to an xml block in Static Activity XML format.</param>
        /// <param name="rawSequencingData">Refers to an xml block in Sequencing Activity XML format.</param>
        /// <param name="rawDynamicData">Refers to an xml block in Dynamic Activity XML format.</param>
        /// <param name="commentsFromLms">Refers to an xml block in LMS Comments XML format.</param>
        /// <param name="wrap">Delegate to wrap attachments.</param>
        /// <param name="wrapGuid">Delegate to wrap guids that represent attachments.</param>
        /// <param name="randomPlacement">Random placement of this activity within its parent, or -1 if the original placement is to be used.</param>
        /// <param name="objectivesGlobalToSystem">Whether or not objectives are global to the system within this activity tree.</param>
        /// <param name="writeValidationMode">Validation mode to determine if the data model is writable.</param>
        /// <param name="learnerId">The unique identifier of the learner.</param>
        /// <param name="learnerName">The name of the learner.</param>
        /// <param name="learnerLanguage">The language code for the learner.</param>
        /// <param name="learnerCaption">The AudioCaptioning setting for the learner.</param>
        /// <param name="learnerAudioLevel">The audio level setting for the learner.</param>
        /// <param name="learnerDeliverySpeed">The delivery speed setting for the learner.</param>
        internal Activity(Navigator owner, long activityId, XPathNavigator rawStaticData, XPathNavigator rawSequencingData,
                          XPathNavigator rawDynamicData, XPathNavigator commentsFromLms,
                          LearningDataModel.WrapAttachmentDelegate wrap, LearningDataModel.WrapAttachmentGuidDelegate wrapGuid,
                          int randomPlacement, bool objectivesGlobalToSystem, DataModelWriteValidationMode writeValidationMode, string learnerId, string learnerName, string learnerLanguage,
                          AudioCaptioning learnerCaption, float learnerAudioLevel, float learnerDeliverySpeed)
        {
            m_owner        = owner;
            m_activityId   = activityId;
            m_rawStaticXml = rawStaticData.SelectSingleNode("/item");
            PackageFormat format;

            if (owner.PackageFormat == PackageFormat.V1p2)
            {
                if (GetResourceType(m_rawStaticXml) == ResourceType.Lrm)
                {
                    format = PackageFormat.Lrm;
                }
                else
                {
                    format = PackageFormat.V1p2;
                }
            }
            else
            {
                format = owner.PackageFormat;
            }
            m_dataModel = new LearningDataModel(format, m_rawStaticXml, rawSequencingData,
                                                rawDynamicData, commentsFromLms, wrap, wrapGuid, writeValidationMode, learnerId, learnerName, learnerLanguage,
                                                learnerCaption, learnerAudioLevel, learnerDeliverySpeed);
            m_dataModel.DataChange     = OnDataModelChanged;
            m_randomPlacement          = randomPlacement;
            m_objectivesGlobalToSystem = objectivesGlobalToSystem;
            // only call the following after m_rawStaticXml is set.
            m_dataModel.Tracked = Sequencing.Tracked;
            if (IsLeaf)
            {
                m_dataModel.CompletionSetByContent = Sequencing.CompletionSetByContent;
                m_dataModel.ObjectiveSetByContent  = Sequencing.ObjectiveSetByContent;
            }
            m_dataModel.UpdateScore = UpdateScore;
        }
コード例 #8
0
        /// <summary>
        /// Render a file attachment.  File attachments will have a relativePath of the form:
        /// .../~RLO/&lt;interactionId&gt;/&lt;attachmentIndex&gt;
        /// </summary>
        /// <param name="context"></param>
        /// <param name="attachmentInfo">The portion of the path to the file after the "/~RLO" portion.</param>
        /// <exception cref="FileNotFoundException">The requested file attachment can't be found.</exception>
        private static void RenderFileAttachment(RloRenderContext context, string attachmentInfo)
        {
            AIResources.Culture = LocalizationManager.GetCurrentCulture();

            // File attachments will have a relativePath of the form:
            //  .../~RLO/<interactionId>/<attachmentIndex>
            //
            // If it's a request to view a file attachment, then there will be extension data in the data model of the form:
            //      ms.learningcomponents.fileAttachment.<interactionId>.<attachmentIndex>

            // find the /~RLO/ portion of the path, so that we can find the beginning of the <interactionId>/<attachmentIndex>
            // part of the path.

            // attachmentInfo should be of the form <interactionId>/<attachmentIndex>, so split it into the parts
            string[]          splitAttachmentInfo = attachmentInfo.Split(new char[] { '/' });
            LearningDataModel learningDataModel   = context.LearningDataModel;

            //if(learningDataModel.Interactions.Contains(splitAttachmentInfo[0]))
            if (learningDataModel.InteractionListContains(splitAttachmentInfo[0]))
            {
                //Interaction i = learningDataModel.Interactions[splitAttachmentInfo[0]];
                Interaction i = learningDataModel.InteractionListElement(splitAttachmentInfo[0]);
                string      fileAttachmentKey = FileAttachmentKey(splitAttachmentInfo[1]);
                if (i.ExtensionData.ContainsKey(fileAttachmentKey))
                {
                    byte[] fileAttachment = (byte[])i.ExtensionData[fileAttachmentKey];
                    if (context.Response != null)
                    {
                        context.Response.Clear();
                    }
                    context.SetOutputStreamExtension((string)i.ExtensionData[FileAttachmentExtensionKey(splitAttachmentInfo[1])]);
                    context.WriteFileToResponse(fileAttachment);
                    return;
                }
            }

            // couldn't get the file
            throw new FileNotFoundException(AIResources.FileAttachmentNotFound);
        }
コード例 #9
0
ファイル: Activity.cs プロジェクト: supermuk/iudico
 /// <summary>
 /// Initializes an Activity object for cloning.
 /// </summary>
 /// <param name="owner">The owner of this actitity tree.</param>
 /// <param name="activityId">The unique identifier of this activity.</param>
 /// <param name="rawStaticData">Refers to an xml block in Static Activity XML format.</param>
 /// <param name="rawSequencingData">Refers to an xml block in Sequencing Activity XML format.</param>
 /// <param name="randomPlacement">Random placement of this activity within its parent, or -1 if the original placement is to be used.</param>
 internal Activity(Navigator owner, long activityId, XPathNavigator rawStaticData, 
     XPathNavigator rawSequencingData, int randomPlacement)
 {
     m_owner = owner;
     m_activityId = activityId;
     m_rawStaticXml = rawStaticData;
     PackageFormat format;
     if(owner.PackageFormat == PackageFormat.V1p2)
     {
         if(GetResourceType(m_rawStaticXml) == ResourceType.Lrm)
         {
             format = PackageFormat.Lrm;
         }
         else
         {
             format = PackageFormat.V1p2;
         }
     }
     else
     {
         format = owner.PackageFormat;
     }
     m_dataModel = new LearningDataModel(format, m_rawStaticXml, rawSequencingData,
         null, null, null, null, DataModelWriteValidationMode.AlwaysAllowWrite, String.Empty, String.Empty, String.Empty, 
         AudioCaptioning.NoChange, (float)1.0, (float)1.0);
     m_randomPlacement = randomPlacement;
     // only call the following after m_rawStaticXml is set.
     m_dataModel.Tracked = Sequencing.Tracked;
     m_dataModel.CompletionSetByContent = Sequencing.CompletionSetByContent;
     m_dataModel.ObjectiveSetByContent = Sequencing.ObjectiveSetByContent;
 }
コード例 #10
0
        /// <summary>
        /// Requests the RloHandler to do whatever is required to exit from the current activity.
        /// This request may only be issued when the session is in Execute view and is not active -- it is
        /// either Completed or Abandoned.
        /// </summary>
        /// <param name="context">The context within which the command is processed</param>
        /// <remarks>
        /// This method should only be called for the <c>SessionView.Execute</c> view.  However,
        /// no checks are done internally to verify this - if this is called with other views,
        /// unexpected results will occur.
        /// </remarks>
        public override void ProcessSessionEnd(RloDataModelContext context)
        {
            LearningDataModel learningDataModel = context.LearningDataModel;

            // Set ExitMode to suspend so that when a student exits the activity it is left in a suspended state.
            // This way if the activity is reactivated, the student's previous answers are intact.
            learningDataModel.NavigationRequest.ExitMode = ExitMode.Suspended;
            // If the page has never been visited, "visit" it.
            if (!GetPageHasBeenVisited(learningDataModel))
            {
                AssessmentItemManager.DataModelContext = context;
                // Get the input stream containing the primary file from the resource associated with the
                // current activity in the session.
                using (Stream inputStream = context.GetInputStream())
                {
                    // find all the assessment items (<IMG> tags that contain the text "mslamrk" as part of the src attribute.)
                    using (HtmlTextReader reader = new HtmlTextReader(inputStream))
                    {
                        int srcIndex;
                        while (reader.Read())
                        {
                            if (IsAITag(reader, out srcIndex))
                            {
                                try
                                {
                                    AssessmentItem         ai       = AssessmentItem.Parse(reader.GetAttributeValue(srcIndex));
                                    AssessmentItemRenderer renderer = AssessmentItemManager.GetRenderer(ai);
                                    renderer.TryAddToDataModel();
                                }
                                catch (FormatException)
                                {
                                    // skip this one.
                                }
                            }
                        }
                    }
                }
                SetPageHasBeenVisited(learningDataModel);
            }
            // If the page has never been autograded, call ProcessSessionEnd on the form data processors
            if (!GetPageHasBeenAutograded(learningDataModel))
            {
                AssessmentItemManager.ProcessFormContext = new RloProcessFormDataContext(SessionView.Execute, learningDataModel);
                float?totalPoints = null;
                foreach (Interaction interaction in learningDataModel.Interactions)
                {
                    FormDataProcessor processor = m_assessmentItemMgr.GetFormDataProcessor(interaction);
                    // must check that processor is non null, since GetFormDataProcessor() can return null.
                    // If it is null, any item score associated with this interaction is not totalled into
                    // EvaluationPoints.
                    if (processor != null)
                    {
                        processor.ProcessSessionEnd(context);
                        if (interaction.Evaluation.Points.HasValue)
                        {
                            if (totalPoints.HasValue)
                            {
                                totalPoints += interaction.Evaluation.Points;
                            }
                            else
                            {
                                totalPoints = interaction.Evaluation.Points;
                            }
                        }
                    }
                }
                learningDataModel.EvaluationPoints = totalPoints;
                SetPageHasBeenAutograded(learningDataModel);
            }
        }
コード例 #11
0
 /// <summary>
 /// Remember that the page has been autograded.
 /// </summary>
 private static void SetPageHasBeenAutograded(LearningDataModel learningDataModel)
 {
     // setting the value to "true" is arbitrary, as the existence of the key in the extension data is
     // sufficient.
     learningDataModel.ExtensionData[InteractionExtensionDataKeys.PageAutograded] = true;
 }
コード例 #12
0
 /// <summary>
 /// Determine from data model if the page has been autograded.
 /// </summary>
 private static bool GetPageHasBeenAutograded(LearningDataModel learningDataModel)
 {
     return(learningDataModel.ExtensionData.ContainsKey(InteractionExtensionDataKeys.PageAutograded));
 }
コード例 #13
0
 /// <summary>
 /// Constructor. Create a converter for SCORM 1.2 content.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="dataModel"></param>
 internal Rte1p2DataModelConverter(SessionView view, LearningDataModel dataModel)
     : base(view, dataModel)
 {
 }
コード例 #14
0
        /// <summary>
        /// Render the requested view into the output stream.
        /// </summary>
        /// <param name="context">The context within which to render the page.</param>
        /// <remarks>
        /// When this method returns the <paramref name="context"/> OutputStream will contain
        /// the rendered file.
        /// <p>
        /// The following methods and properties must be return valid values from
        /// the <paramref name="context"/>:
        /// <ul>
        /// <li>EmbeddedUiResourcePath, must be non-null</li>
        /// <li>FormElementId</li>
        /// <li>GetInputStream</li>
        /// <li>OutputStream</li>
        /// <li>View</li>
        /// </ul>
        /// </p>
        /// <p>
        /// Additionally, if the following properties are set, they will be used:
        /// <ul>
        /// <li>FormElementAction</li>
        /// <li>HiddenControls</li>
        /// <li>ScriptToRender</li>
        /// </ul>
        /// </p>
        /// All other properties on <paramref name="context"/> are ignored.
        /// </remarks>
        /// <exception cref="FileNotFoundException">The requested file attachment can't be found.</exception>
        public override void Render(RloRenderContext context)
        {
            AIResources.Culture = LocalizationManager.GetCurrentCulture();

            // string is the key (which is AssessmentItem.Id_AssessmentItem.Type)
            // int is the ordinal (0 based) which is the number of times the key has been processed
            Dictionary <string, int> assessmentItems = new Dictionary <string, int>();

            // The most common case is that the file is in the package
            Stream inputStream = null;

            AssessmentItemManager.DataModelContext = context;
            LearningDataModel learningDataModel = context.LearningDataModel;

            try
            {
                int srcIndex; // represents the index of the "src" attribute on an <img> node.
                // If this is the first time the page is being rendered, parse the page and determine
                // the interactions on the page.
                if (context.View == SessionView.Execute)
                {
                    if (!GetPageHasBeenVisited(learningDataModel))
                    {
                        using (inputStream = context.GetInputStream())
                        {
                            // If the file being requested is the default file for the current activity,
                            if (context.IsResourceEntryPoint)
                            {
                                // find all the assessment items (<IMG> tags that contain the text "mslamrk" as part of the src attribute.)
                                using (HtmlTextReader reader = new HtmlTextReader(inputStream))
                                {
                                    while (reader.Read())
                                    {
                                        if (IsAITag(reader, out srcIndex))
                                        {
                                            try
                                            {
                                                AssessmentItem         ai       = AssessmentItem.Parse(reader.GetAttributeValue(srcIndex));
                                                AssessmentItemRenderer renderer = AssessmentItemManager.GetRenderer(ai);
                                                renderer.TryAddToDataModel();
                                            }
                                            catch (FormatException)
                                            {
                                                // skip this one.  This is mirrored below in the 2nd pass.
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        SetPageHasBeenVisited(learningDataModel);
                    }
                }

                // must get the input stream again since it may not be possible to seek back to the beginning
                using (inputStream = context.GetInputStream())
                {
                    if (context.Response != null)
                    {
                        // Clear the output response
                        context.Response.Clear();
                    }

                    // If the file being requested is the default file for the current activity,
                    if (context.IsResourceEntryPoint)
                    {
                        if (context.View == SessionView.Execute)
                        {
                            // Set ExitMode to suspend so that when a student exits the activity it is left in a suspended state.
                            // This way if the activity is reactivated, the student's previous answers are intact.
                            learningDataModel.NavigationRequest.ExitMode = ExitMode.Suspended;
                        }

                        DetachableStream detachable = new DetachableStream(context.OutputStream);
                        // Parse through the input stream again, this time rendering into the output as we go.
                        using (StreamWriter writer = new StreamWriter(detachable))
                        {
                            using (HtmlTextReader reader = new HtmlTextReader(inputStream))
                            {
                                while (reader.Read())
                                {
                                    if (IsAITag(reader, out srcIndex))
                                    {
                                        try
                                        {
                                            AssessmentItem         ai       = AssessmentItem.Parse(reader.GetAttributeValue(srcIndex));
                                            AssessmentItemRenderer renderer = AssessmentItemManager.GetRenderer(ai);
                                            if (assessmentItems.ContainsKey(ai.RenderKey))
                                            {
                                                assessmentItems[ai.RenderKey] += 1;
                                            }
                                            else
                                            {
                                                assessmentItems.Add(ai.RenderKey, 0);
                                            }
                                            writer.Write(renderer.Render(assessmentItems[ai.RenderKey]).ToString());
                                        }
                                        catch (FormatException)
                                        {
                                            // skip this one.  This is mirrored above in the 1st pass.
                                        }
                                    }
                                    else
                                    {
                                        HandleNode(reader, writer);
                                    }
                                }
                            }
                            // don't allow closing the StreamWriter to close the context.OutputStream.
                            writer.Flush();
                            detachable.Detach();
                        }

                        // set the response type
                        context.SetOutputStreamExtension(Path.GetExtension(context.RelativePath));
                    }
                    else
                    {
                        // for a non-entry-point file, copy the file directly to the output stream
                        context.WriteFileToResponse(context.RelativePath);
                    }
                }



                return;
            }
            catch (FileNotFoundException)
            {
                // This means the requested file is not in the package. That's not necessarily a problem, since it
                // may be a request for an attachment.
            }

            // We got here because the file is not in the package. In that case, render it if it is a file attachment
            int beginAttachmentInfo = context.RelativePath.IndexOf("/~RLO/", StringComparison.Ordinal);

            if (beginAttachmentInfo != -1)
            {
                // attachmentInfo should be of the form <interactionId>/<attachmentIndex>, so split it into the parts
                string attachmentInfo = context.RelativePath.Substring(beginAttachmentInfo + 6);

                RenderFileAttachment(context, attachmentInfo);
            }
            else
            {
                // This means the requested file is not in the package, nor is it a request for an attachment.
                throw new FileNotFoundException(AIResources.FileNotFound);
            }
        }
コード例 #15
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())));
        }
コード例 #16
0
 /// <summary>
 /// Constructor. Create a converter for SCORM 1.2 content.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="dataModel"></param>
 internal Rte1p2DataModelConverter(SessionView view, LearningDataModel dataModel)
     : base(view, dataModel)
 {
 }
コード例 #17
0
ファイル: LrmRloHandler.cs プロジェクト: supermuk/iudico
 /// <summary>
 /// Determine from data model if the page has been visited by learner yet
 /// </summary>
 private static bool GetPageHasBeenVisited(LearningDataModel learningDataModel)
 {
     return learningDataModel.ExtensionData.ContainsKey(InteractionExtensionDataKeys.PageRendered);
 }
コード例 #18
0
 /// <summary>
 /// Create a context to send to an RloHandler.
 /// </summary>
 /// <param name="view">The view that will be rendered from the form data.</param>
 /// <param name="learningDataModel">The data model of the current activity in the session.</param>
 internal RloProcessFormDataContext(SessionView view, LearningDataModel learningDataModel)
 {
     m_view = view;
     m_learningDataModel = learningDataModel;
 }
コード例 #19
0
ファイル: Activity.cs プロジェクト: supermuk/iudico
 /// <summary>
 /// Initializes an Activity object.
 /// </summary>
 /// <param name="owner">The owner of this actitity tree.</param>
 /// <param name="activityId">The unique identifier of this activity.</param>
 /// <param name="rawStaticData">Refers to an xml block in Static Activity XML format.</param>
 /// <param name="rawSequencingData">Refers to an xml block in Sequencing Activity XML format.</param>
 /// <param name="rawDynamicData">Refers to an xml block in Dynamic Activity XML format.</param>
 /// <param name="commentsFromLms">Refers to an xml block in LMS Comments XML format.</param>
 /// <param name="wrap">Delegate to wrap attachments.</param>
 /// <param name="wrapGuid">Delegate to wrap guids that represent attachments.</param>
 /// <param name="randomPlacement">Random placement of this activity within its parent, or -1 if the original placement is to be used.</param>
 /// <param name="objectivesGlobalToSystem">Whether or not objectives are global to the system within this activity tree.</param>
 /// <param name="writeValidationMode">Validation mode to determine if the data model is writable.</param>
 /// <param name="learnerId">The unique identifier of the learner.</param>
 /// <param name="learnerName">The name of the learner.</param>
 /// <param name="learnerLanguage">The language code for the learner.</param>
 /// <param name="learnerCaption">The AudioCaptioning setting for the learner.</param>
 /// <param name="learnerAudioLevel">The audio level setting for the learner.</param>
 /// <param name="learnerDeliverySpeed">The delivery speed setting for the learner.</param>
 internal Activity(Navigator owner, long activityId, XPathNavigator rawStaticData, XPathNavigator rawSequencingData, 
     XPathNavigator rawDynamicData, XPathNavigator commentsFromLms, 
     LearningDataModel.WrapAttachmentDelegate wrap, LearningDataModel.WrapAttachmentGuidDelegate wrapGuid,
     int randomPlacement, bool objectivesGlobalToSystem, DataModelWriteValidationMode writeValidationMode, string learnerId, string learnerName, string learnerLanguage, 
     AudioCaptioning learnerCaption, float learnerAudioLevel, float learnerDeliverySpeed)
 {
     m_owner = owner;
     m_activityId = activityId;
     m_rawStaticXml = rawStaticData.SelectSingleNode("/item");
     PackageFormat format;
     if(owner.PackageFormat == PackageFormat.V1p2)
     {
         if(GetResourceType(m_rawStaticXml) == ResourceType.Lrm)
         {
             format = PackageFormat.Lrm;
         }
         else
         {
             format = PackageFormat.V1p2;
         }
     }
     else
     {
         format = owner.PackageFormat;
     }
     m_dataModel = new LearningDataModel(format, m_rawStaticXml, rawSequencingData,
         rawDynamicData, commentsFromLms, wrap, wrapGuid, writeValidationMode, learnerId, learnerName, learnerLanguage, 
         learnerCaption, learnerAudioLevel, learnerDeliverySpeed);
     m_dataModel.DataChange = OnDataModelChanged;
     m_randomPlacement = randomPlacement;
     m_objectivesGlobalToSystem = objectivesGlobalToSystem;
     // only call the following after m_rawStaticXml is set.
     m_dataModel.Tracked = Sequencing.Tracked;
     if (IsLeaf)
     {
         m_dataModel.CompletionSetByContent = Sequencing.CompletionSetByContent;
         m_dataModel.ObjectiveSetByContent = Sequencing.ObjectiveSetByContent;
     }
     m_dataModel.UpdateScore = UpdateScore;
 }
コード例 #20
0
ファイル: LrmRloHandler.cs プロジェクト: supermuk/iudico
 /// <summary>
 /// Remember that the page has been autograded.
 /// </summary>
 private static void SetPageHasBeenAutograded(LearningDataModel learningDataModel)
 {
     // setting the value to "true" is arbitrary, as the existence of the key in the extension data is
     // sufficient.
     learningDataModel.ExtensionData[InteractionExtensionDataKeys.PageAutograded] = true;
 }
コード例 #21
0
ファイル: LrmRloHandler.cs プロジェクト: supermuk/iudico
 /// <summary>
 /// Determine from data model if the page has been autograded.
 /// </summary>
 private static bool GetPageHasBeenAutograded(LearningDataModel learningDataModel)
 {
     return learningDataModel.ExtensionData.ContainsKey(InteractionExtensionDataKeys.PageAutograded);
 }
コード例 #22
0
 /// <summary>
 /// Constructor. Create a converter for 2004 content.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="dataModel"></param>
 internal Rte2004DataModelConverter(SessionView view, LearningDataModel dataModel)
     : base(view, dataModel)
 {
     this.mPendingLearnerComments = new Dictionary<int, Comment>();
 }
コード例 #23
0
ファイル: RloHandler.cs プロジェクト: supermuk/iudico
 /// <summary>
 /// Create a context to send to an RloHandler.
 /// </summary>
 /// <param name="view">The view that will be rendered from the form data.</param>
 /// <param name="learningDataModel">The data model of the current activity in the session.</param>
 internal RloProcessFormDataContext(SessionView view, LearningDataModel learningDataModel)
 {
     m_view = view;
     m_learningDataModel = learningDataModel;
 }