Пример #1
0
 internal DataModelValues(PlainTextString dataModelValues)
     : this(dataModelValues, "")
 {
 }
Пример #2
0
        [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] // large switch statement
        public override void SetValue(PlainTextString inName, PlainTextString inValue)
        {
            // It's not valid to call in Review mode
            if (this.View == SessionView.Review)
            {
                throw new InvalidOperationException(
                    ResHelper.GetMessage(Localization.GetMessage("CONV_InvalidViewOnSetValue")));
            }

            if (this.ObjectiveIndexer == null)
            {
                throw new InvalidOperationException(
                    ResHelper.GetMessage(Localization.GetMessage("CONV_MappingRequired")));
            }

            this.CurrentElementName = inName.ToString();
            string[] nameParts = this.CurrentElementName.Split('.');

            string value = inValue.ToString();

            if (nameParts[0] == "cmi")
            {
                if (nameParts.Length < 2)
                {
                    throw new InvalidOperationException(
                        ResHelper.GetMessage(
                            Localization.GetMessage("CONV_SetValueInvalidName"),
                            this.CurrentElementName));
                }

                switch (nameParts[1])
                {
                    case "comments_from_learner":
                        {
                            this.VerifyElementNameTokens(4, nameParts);
                            this.SetCommentsFromLearner(nameParts[2], nameParts[3], value);
                        }
                        break;
                    case "completion_status":
                        {
                            this.SetCompletionStatus(value);
                        }
                        break;
                    case "exit":
                        {
                            this.SetExit(value);
                        }
                        break;
                    case "interactions":
                        {
                            this.SetInteractions(this.CurrentElementName.Substring(17), value);
                        }
                        break;
                    case "learner_preference":
                        {
                            this.VerifyElementNameTokens(3, nameParts);
                            this.SetLearnerPreferences(nameParts[2], value);
                        }
                        break;
                    case "location":
                        {
                            this.DataModel.Location = value;
                        }
                        break;
                    case "objectives":
                        {
                            this.SetObjectives(this.CurrentElementName.Substring(15), value);
                        }
                        break;
                    case "progress_measure":
                        {
                            this.SetProgressMeasure(value);
                        }
                        break;
                    case "score":
                        {
                            this.VerifyElementNameTokens(3, nameParts);
                            this.SetScore(nameParts[2], value);
                        }
                        break;
                    case "session_time":
                        {
                            this.SetSessionTime(value);
                        }
                        break;
                    case "success_status":
                        {
                            this.SetSuccessStatus(value);
                        }
                        break;
                    case "suspend_data":
                        {
                            this.SetSuspendData(value);
                        }
                        break;

                    default:
                        // All other values are read-only. This will throw exception.
                        this.SetReadOnlyValue();
                        break;
                }
            }
            else if (nameParts[0] == "adl")
            {
                if (nameParts.Length < 3)
                {
                    throw new InvalidOperationException(
                        ResHelper.GetMessage(
                            Localization.GetMessage("CONV_SetValueInvalidName"),
                            this.CurrentElementName));
                }

                if (nameParts[1] != "nav")
                {
                    throw new InvalidOperationException(
                        ResHelper.GetMessage(
                            Localization.GetMessage("CONV_SetValueInvalidName"),
                            this.CurrentElementName));
                }

                switch (nameParts[2])
                {
                    case "request":
                        {
                            this.SetNavRequest(value);
                        }
                        break;
                    default:
                        throw new InvalidOperationException(
                            ResHelper.GetMessage(
                                Localization.GetMessage("CONV_SetValueInvalidName"),
                                this.CurrentElementName));
                }
            }
            else
            {
                this.DataModel.ExtensionData[this.CurrentElementName] = value;
            }
        }
Пример #3
0
 /// <summary>
 /// The entry point for SetValue functions. Pass in the name (in SCORM terms) of the data model element
 /// and this method sets the appropriate value in the LearningDataModel class.
 /// </summary>
 /// <param name="inName">SCORM data model element name (e.g., "cmi.exit"). </param>
 /// <param name="inValue">The value of the element in SCORM terms (e.g., "logout").</param>
 /// <remarks>
 /// <para>It is not valid to call SetValue in Review view.</para></remarks>
 public abstract void SetValue(PlainTextString inName, PlainTextString inValue);
Пример #4
0
 internal DataModelValues(PlainTextString dataModelValues, PlainTextString objectiveIdMap)
 {
     m_dataModelValues = dataModelValues;
     m_objectiveIdMap = objectiveIdMap;
 }
Пример #5
0
        /// <summary>
        /// Write an element in to the TOC that allows submitting the attempt.
        /// </summary>
        /// <param name="sw">The string writer to write the toc entry to.</param>
        private void WriteSubmitPageEntry(HtmlStringWriter sw)
        {
            string activityId = "SUBMIT";
            HtmlString activityIdHtml = new PlainTextString(activityId).ToHtmlString();
            HtmlString titleHtml = new PlainTextString(m_submitPageLinkText).ToHtmlString();

            sw.AddAttribute(HtmlTextWriterAttribute.Class, new PlainTextString("NodeParent"));
            sw.AddAttribute("activityId", activityIdHtml);
            sw.AddAttribute("isValidChoice", "true");
            sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("div{0}", activityIdHtml));
            sw.RenderBeginTag(HtmlTextWriterTag.Div);   // #Div1
                      
            sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("icon{0}", activityIdHtml));
            sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/Leaf.gif");
            sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
            sw.RenderBeginTag(HtmlTextWriterTag.Img);
            sw.RenderEndTag();

            sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/1px.gif");
            sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
            sw.RenderBeginTag(HtmlTextWriterTag.Img);
            sw.RenderEndTag();
            sw.WriteLine();

            sw.AddAttribute(HtmlTextWriterAttribute.Href, "");
            sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("a{0}", activityIdHtml));
            sw.AddAttribute(HtmlTextWriterAttribute.Style, "FONT-WEIGHT: normal;visibility:visible");
            sw.AddAttribute(HtmlTextWriterAttribute.Title, titleHtml);
            sw.RenderBeginTag(HtmlTextWriterTag.A);
            sw.WriteHtml(titleHtml);
            sw.RenderEndTag();
        
            sw.RenderEndTag();  // div (see #Div1, above)
            sw.WriteLine();
        }
Пример #6
0
        /// <summary>
        /// The entry point for SetValue functions. Pass in the name (in SCORM terms) of the data model element
        /// and this method sets the appropriate value in the LearningDataModel class.
        /// </summary>
        /// <param name="inName">SCORM data model element name (e.g., "cmi.exit"). </param>
        /// <param name="inValue">The value of the element in SCORM terms (e.g., "logout").</param>
        /// <remarks>Note: InteractionIndexer and ObjectiveIndexer must be set prior to calling this method.
        /// <para>It is not valid to call SetValue in Review view.</para>
        /// <p/>This method is relatively lax about throwing exceptions for invalid names. It assumes the caller 
        /// is passing in valid information.
        /// </remarks>
        public override void SetValue(PlainTextString inName, PlainTextString inValue)
        {
            // It's not valid to call in Review mode
            if (View == SessionView.Review)
                throw new InvalidOperationException(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("CONV_InvalidViewOnSetValue")));

            CurrentElementName = inName.ToString();
            string[] nameParts = CurrentElementName.Split('.');

            string value = inValue.ToString();

            if (nameParts[0] == "cmi")
            {
                if (nameParts.Length < 2)
                    throw new InvalidOperationException(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("CONV_SetValueInvalidName"), CurrentElementName));

                switch (nameParts[1])
                {
                    case "core":
                        {
                            SetCoreValues(nameParts, value);
                            break;
                        }

                    case "suspend_data":
                        {
                            DataModel.SuspendData = value;
                            break;
                        }
                    case "comments":
                        {
                            SetCommentsFromLearner(value);
                            break;
                        }
                    case "objectives":
                        {
                            VerifyElementNameTokens(4, nameParts);
                            SetObjectives(CurrentElementName.Substring(15) ,value);
                            break;
                        }
                    case "student_preference":
                        {
                            VerifyElementNameTokens(3, nameParts);
                            SetLearnerPreferences(nameParts[2], value);
                            break;
                        }
                    case "interactions":
                        {
                            SetInteractions(CurrentElementName.Substring(17), value);
                            break;
                        }

                    default:
                        // All other values are read-only (or invalid names). This will throw exception.
                        SetReadOnlyValue();
                        break;
                }

            }
            else
            {
                DataModel.ExtensionData[CurrentElementName] = value;
            }
        }
Пример #7
0
 /// <summary>
 /// Convert a plaintextString to Html.
 /// </summary>
 /// <param name="plaintext">Text string.</param>
 /// <remarks>
 /// HtmlEncodes the <paramref name="plaintext"/>
 /// </remarks>
 public HtmlString(PlainTextString plaintext)
 {
     this.mHtml = HttpUtility.HtmlEncode(plaintext);
 }
Пример #8
0
        [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]    // parameter is validated
        private void WriteTocEntry(HtmlStringWriter sw, TableOfContentsElement currentElement)
        {
            FramesetUtil.ValidateNonNullParameter("sw", sw);
            FramesetUtil.ValidateNonNullParameter("currentElement", currentElement);

            string activityId = FramesetUtil.GetStringInvariant(currentElement.ActivityId);
            bool elementHasChildren = currentElement.Children.Count > 0;
            HtmlString activityIdHtml = new PlainTextString(activityId).ToHtmlString();
            HtmlString titleHtml = new PlainTextString(currentElement.Title).ToHtmlString();

            // If the current element is visible or is an invisible leaf node, then render it. (If it's an 
            // invisible leaf node, the node will exist but not be visible.)
            if (RenderThisNode(currentElement))
            {
                sw.AddAttribute(HtmlTextWriterAttribute.Class, new PlainTextString("NodeParent"));
                sw.AddAttribute("activityId", activityIdHtml);
                sw.AddAttribute("isValidChoice", (currentElement.IsValidChoiceNavigationDestination ? "true" : "false"));
                sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("div{0}", activityIdHtml));
                sw.RenderBeginTag(HtmlTextWriterTag.Div);   // #Div1

                if (currentElement.IsVisible)
                {
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("icon{0}", activityIdHtml));
                    if (currentElement.HasVisibleChildren)
                        sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/MinusBtn.gif");
                    else
                        sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/Leaf.gif");
                    sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
                    sw.RenderBeginTag(HtmlTextWriterTag.Img);
                    sw.RenderEndTag();

                    sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/1px.gif");
                    sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
                    sw.RenderBeginTag(HtmlTextWriterTag.Img);
                    sw.RenderEndTag();
                    sw.WriteLine();

                    sw.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("a{0}", activityIdHtml));
                    if (!currentElement.IsValidChoiceNavigationDestination)
                    {
                        sw.AddAttribute(HtmlTextWriterAttribute.Disabled, "true");
                        sw.AddAttribute("class", "disable");
                    }

                    sw.AddAttribute(HtmlTextWriterAttribute.Style,
                                        ResHelper.FormatInvariant("FONT-WEIGHT: normal;visibility:{0}", (currentElement.IsVisible ? "visible" : "hidden")));
                    sw.AddAttribute(HtmlTextWriterAttribute.Title, titleHtml);
                    sw.RenderBeginTag(HtmlTextWriterTag.A);
                    sw.WriteHtml(titleHtml);
                    sw.RenderEndTag();
                }
            }

            // Write sub-elements (regardless of whether or not this node is rendered)
            if (elementHasChildren)
            {
                sw.WriteLine();
                bool clusterStarted = false;
                if (currentElement.IsVisible)
                {
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("divCluster{0}", activityIdHtml));
                    sw.AddAttribute(HtmlTextWriterAttribute.Style, "MARGIN-TOP: 5px; DISPLAY: block; MARGIN-LEFT: 18px;");
                    sw.RenderBeginTag(HtmlTextWriterTag.Div);
                    clusterStarted = true;
                }

                foreach (TableOfContentsElement childElement in currentElement.Children)
                {
                    WriteTocEntry(sw, childElement);
                }

                if (clusterStarted)
                {
                    sw.RenderEndTag(); // end div
                    sw.WriteLine();
                }
            }

            if (RenderThisNode(currentElement))
            {
                sw.RenderEndTag();  // div (see #Div1, above)
                sw.WriteLine();
            }
        }
Пример #9
0
 /// <summary>
 /// TODO
 /// </summary>
 ///
 /// <param name="plaintext">TODO</param>
 ///
 /// <remarks>
 /// TODO
 /// </remarks>
 ///
 public void WriteText(PlainTextString plaintext)
 {
     this.mHtmlTextWriter.WriteEncodedText(plaintext);
 }
Пример #10
0
 /// <summary>
 /// TODO
 /// </summary>
 ///
 /// <param name="key">TODO</param>
 ///
 /// <param name="plaintext">TODO</param>
 ///
 /// <remarks>
 /// TODO
 /// </remarks>
 ///
 public void AddAttribute(HtmlTextWriterAttribute key, PlainTextString plaintext)
 {
     this.mHtmlTextWriter.AddAttribute(key, plaintext);
 }
Пример #11
0
 /// <summary>
 /// TODO
 /// </summary>
 ///
 /// <param name="name">TODO</param>
 ///
 /// <param name="plaintext">TODO</param>
 ///
 /// <remarks>
 /// TODO
 /// </remarks>
 ///
 public void AddAttribute(string name, PlainTextString plaintext)
 {
     this.mHtmlTextWriter.AddAttribute(name, plaintext);
 }
Пример #12
0
 internal DataModelValues(PlainTextString dataModelValues)
     : this(dataModelValues, string.Empty)
 {
 }
Пример #13
0
 internal DataModelValues(PlainTextString dataModelValues, PlainTextString objectiveIdMap)
 {
     this.mDataModelValues = dataModelValues;
     this.mObjectiveIdMap = objectiveIdMap;
 }