Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context"></param>
 internal FillInFormDataProcessor(RloProcessFormDataContext context)
     : base(context)
 {
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context"></param>
 internal EssayFormDataProcessor(RloProcessFormDataContext context)
     : base(context)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context"></param>
 internal FileAttachmentFormDataProcessor(RloProcessFormDataContext context)
     : base(context)
 {
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context"></param>
 internal MultipleChoiceFormDataProcessor(RloProcessFormDataContext context)
     : base(context)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context">Context in which data from a posted form is processed.</param>
 public FormDataProcessor(RloProcessFormDataContext context)
 {
     AIResources.Culture = LocalizationManager.GetCurrentCulture();
     m_context = context;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context"></param>
 internal MatchingFormDataProcessor(RloProcessFormDataContext context)
     : base(context)
 {
 }
Exemplo n.º 9
0
 /// <summary>
 /// Requests the RloHandler to process information received from the client.
 /// </summary>
 /// <param name="context">The context within which to process the form data.</param>
 /// <param name="formData">The data to process.</param>
 /// <param name="files">File collection from the <Typ>HttpRequest</Typ>.  E.g. <c>HttpRequest.Files</c>.</param>
 public abstract void ProcessFormData(RloProcessFormDataContext context, NameValueCollection formData, IDictionary <string, HttpPostedFile> files);
Exemplo n.º 10
0
 /// <summary>
 /// Requests the RloHandler to process information received from the client.
 /// </summary>
 /// <remarks>
 /// This method does not take action on the posted data
 /// </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 nothing
 }
Exemplo n.º 11
0
 /// <summary>
 /// Requests the RloHandler to process information received from the client.
 /// </summary>
 /// <param name="context">The context within which to process the form data.</param>
 /// <param name="formData">The data to process.</param>
 /// <param name="files">File collection from the <Typ>HttpRequest</Typ>.  E.g. <c>HttpRequest.Files</c>.</param>
 public abstract void ProcessFormData(RloProcessFormDataContext context, NameValueCollection formData, IDictionary<string, HttpPostedFile> files); 
Exemplo n.º 12
0
 /// <summary>
 /// Requests the RloHandler to process information received from the client.
 /// </summary>
 /// <remarks>
 /// This method does not take action on the posted data
 /// </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 nothing
 }