예제 #1
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();
        }
예제 #2
0
        [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")] // parameter is validated
        protected void WriteError(PlainTextString message, bool allowReloadCurrentActivity)
        {
            FramesetUtil.ValidateNonNullParameter("message", message);
            string msgToDisplay;

            // If the message will contain a link to reload the current activity, then add the link to have the
            // framesetMgr load the activity. We have to do this (rather than a get request) since we need to
            // re-initialize the RTE object at this point.
            if (allowReloadCurrentActivity)
            {
                JScriptString js =
                    new JScriptString(
                        ResHelper.FormatInvariant(
                            "API_GetFramesetManager().DoChoice(\"{0}\");",
                            FramesetUtil.GetStringInvariant(this.mSession.CurrentActivityId)));
                string        origMessage = message.ToString();
                StringBuilder sb          = new StringBuilder(origMessage.Length * 2);
                sb.Append(
                    ResHelper.Format(
                        "{0}<br><br><a href='{1}' >{2}</a>",
                        origMessage,
                        js.ToJavascriptProtocol(),
                        Localization.GetMessage("HID_ReloadCurrentContent")));

                msgToDisplay = sb.ToString();
            }
            else
            {
                msgToDisplay = message.ToString();
            }
            this.RegisterError(
                Localization.GetMessage("HID_ServerErrorTitle"), msgToDisplay, false);
        }
예제 #3
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();
            }
        }
예제 #4
0
        // it's not worth changing this now
        private void InitHiddenControlInfo()
        {
            HiddenControlInfo hiddenCtrlInfo;
            Collection<HiddenControlInfo> hiddenControlInfos = this.HiddenControls;
            StringBuilder sb;

            // If the session is attempt-based, then write attempt information
            if (this.Session != null)
            {
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.AttemptId);
                hiddenCtrlInfo.Value = new PlainTextString(FramesetUtil.GetString(this.Session.AttemptId));
                hiddenCtrlInfo.FrameManagerInitializationScript =
                    new JScriptString(
                        ResHelper.FormatInvariant(
                            "frameMgr.SetAttemptId(document.getElementById({0}).value);",
                            JScriptString.QuoteString(HiddenFieldNames.AttemptId, false)));

                hiddenControlInfos.Add(hiddenCtrlInfo);
            }

            // If the session has ended (that is, is suspended, completed or abandoned), then just 
            // tell the framesetmgr and return. Nothing else is required on the client.
            if (this.SessionIsEnded)
            {
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = null; // no data to save
                hiddenCtrlInfo.Value = null;
                hiddenCtrlInfo.FrameManagerInitializationScript =
                    new JScriptString(
                        ResHelper.Format(
                            "frameMgr.TrainingComplete({0}, {1});",
                            JScriptString.QuoteString(this.mSessionEndedMsgTitle, false),
                            JScriptString.QuoteString(this.mSessionEndedMsg, false)));
                hiddenControlInfos.Add(hiddenCtrlInfo);

                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = null; // no data to save
                hiddenCtrlInfo.Value = null;
                hiddenCtrlInfo.FrameManagerInitializationScript =
                    new JScriptString(ResHelper.Format("frameMgr.ShowStatisticResults();"));
                hiddenControlInfos.Add(hiddenCtrlInfo);

                return;
            }

            // Write view to display. 
            hiddenCtrlInfo = new HiddenControlInfo();
            hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.View);
            hiddenCtrlInfo.Value = new PlainTextString(FramesetUtil.GetString(this.Session.View));
            hiddenCtrlInfo.FrameManagerInitializationScript =
                new JScriptString(
                    ResHelper.FormatInvariant(
                        "frameMgr.SetView(document.getElementById({0}).value);",
                        JScriptString.QuoteString(HiddenFieldNames.View, false)));

            hiddenControlInfos.Add(hiddenCtrlInfo);

            // Write frame and form to post. They depend on whether this is LRM content or SCORM content. If the submit 
            // page is being displayed, it is always this hidden frame that is posted.
            PlainTextString frameName;
            JScriptString postableFormScript;

            hiddenCtrlInfo = new HiddenControlInfo();
            hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.PostFrame);
            // Post the content frame on the next post if LRM content is being displayed.
            if (!this.mSaveOnly && !this.SubmitPageDisplayed && !this.HasError
                && (this.Session.HasCurrentActivity && (this.Session.CurrentActivityResourceType == ResourceType.Lrm)))
            {
                frameName = new PlainTextString("frameContent");
                postableFormScript =
                    new JScriptString("frameMgr.SetPostableForm(GetContentFrame().contentWindow.document.forms[0]);");
            }
            else
            {
                // Post hidden frame if there is no current activity, if the current activity is not LRM content, or 
                // if there is an error being displayed. This may happen if the current 
                // activity was exited or suspended and a new activity was not automagically determined.
                frameName = new PlainTextString("frameHidden");
                postableFormScript = new JScriptString("frameMgr.SetPostableForm(document.forms[0]);");
            }
            hiddenCtrlInfo.Value = frameName;
            hiddenCtrlInfo.FrameManagerInitializationScript =
                new JScriptString(
                    ResHelper.FormatInvariant(
                        "frameMgr.SetPostFrame(document.getElementById({0}).value);",
                        JScriptString.QuoteString(HiddenFieldNames.PostFrame, false)));

            hiddenControlInfos.Add(hiddenCtrlInfo);

            // Set postable form. 
            hiddenCtrlInfo = new HiddenControlInfo();
            hiddenCtrlInfo.FrameManagerInitializationScript = postableFormScript;
            hiddenControlInfos.Add(hiddenCtrlInfo);

            // If a new activity has been identified, then instruct frameMgr to reinitialize the RTE. 
            // BE CAREFUL to do this before setting any other data related to the rte! 
            if (this.ActivityHasChanged && !this.SubmitPageDisplayed)
            {
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = null; // No need to save data. Just write the script command
                hiddenCtrlInfo.Value = null;
                string initNewActivity = "false";
                if (this.Session.HasCurrentActivity)
                {
                    initNewActivity = (this.CurrentActivityRequiresRte ? "true" : "false");
                }
                hiddenCtrlInfo.FrameManagerInitializationScript =
                    new JScriptString(ResHelper.FormatInvariant("frameMgr.InitNewActivity( {0} );", initNewActivity));
                hiddenControlInfos.Add(hiddenCtrlInfo);
            }

            // Write the current activity Id if it has changed. 
            // Write "SUBMIT" if the submit page is being shown. Otherwise, write -1 if there isn't a current activity.
            hiddenCtrlInfo = new HiddenControlInfo();
            hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.ActivityId);
            PlainTextString setValue; // the value to set in the frameMgr for the current activity id.
            if (this.SubmitPageDisplayed)
            {
                setValue = new PlainTextString(SubmitId);
            }
            else
            {
                // Only set the actual activity id if this is the first rendering or if it has changed in this rendering,
                // and if there is a current activity.
                if (this.mIsFramesetInitialization || this.ActivityHasChanged)
                {
                    setValue =
                        new PlainTextString(
                            this.Session.HasCurrentActivity
                                ? FramesetUtil.GetStringInvariant(this.Session.CurrentActivityId)
                                : "-1");
                }
                else
                {
                    setValue = new PlainTextString("-1");
                }
            }
            // The value of the field is always the current activity id. The value the frameMgr gets is the value of the TOC element.
            hiddenCtrlInfo.Value =
                new PlainTextString(
                    this.Session.HasCurrentActivity
                        ? FramesetUtil.GetStringInvariant(this.Session.CurrentActivityId)
                        : "-1");
            hiddenCtrlInfo.FrameManagerInitializationScript =
                new JScriptString(
                    ResHelper.FormatInvariant(
                        "frameMgr.SetActivityId({0});", JScriptString.QuoteString(setValue, false)));
            hiddenControlInfos.Add(hiddenCtrlInfo);

            // Write the navigation control state. Format of the control state is a series of T (to show) or F (to hide)
            // values, separated by semi-colons. The order of controls is: 
            // showNext, showPrevious, showAbandon, showExit, showSave
            hiddenCtrlInfo = new HiddenControlInfo();
            // Issue: What is the hidden field used for? 
            hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.ShowUI);
            sb = new StringBuilder(10);
            sb.Append((this.Session.ShowNext) ? "T" : "F");
            sb.Append(";");
            sb.Append((this.Session.ShowPrevious) ? "T" : "F");
            sb.Append(";");
            sb.Append((this.Session.ShowAbandon) ? "T" : "F");
            sb.Append(";");
            sb.Append((this.Session.ShowExit) ? "T" : "F");
            sb.Append(";");
            sb.Append((this.Session.ShowSave) ? "T" : "F");
            sb.Append(";");
            hiddenCtrlInfo.Value = new PlainTextString(sb.ToString());
            sb = new StringBuilder(1000);
            sb.Append(string.Empty);
            if (this.SubmitPageDisplayed)
            {
                // If the submit page is being displayed, don't show UI elements
                sb.Append(
                    ResHelper.FormatInvariant(
                        "frameMgr.SetNavVisibility( {0}, {1}, {2}, {3}, {4});",
                        ("false"),
                        // showNext
                        ("false"),
                        // showPrevious
                        ("false"),
                        // showAbandon
                        ("false"),
                        // showExit
                        ("false")));
                        // showSave
            }
            else
            {
                sb.Append(
                    ResHelper.FormatInvariant(
                        "frameMgr.SetNavVisibility( {0}, {1}, {2}, {3}, {4});",
                        (this.Session.ShowNext ? "true" : "false"),
                        (this.Session.ShowPrevious ? "true" : "false"),
                        (this.Session.ShowAbandon ? "true" : "false"),
                        (this.Session.ShowExit ? "true" : "false"),
                        (this.Session.ShowSave ? "true" : "false")));
            }
            hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString(sb.ToString());
            hiddenControlInfos.Add(hiddenCtrlInfo);

            // If there was an error, write it to the client. Note that if the submit page is being rendered, this code 
            // will execute, as it appears in the same form as an error message.
            if (!string.IsNullOrEmpty(this.ErrorMessage))
            {
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.ErrorMessage);
                hiddenCtrlInfo.Value = this.ErrorMessage;
                if (string.IsNullOrEmpty(this.ErrorTitle))
                {
                    hiddenCtrlInfo.FrameManagerInitializationScript =
                        new JScriptString(
                            ResHelper.Format(
                                "frameMgr.SetErrorMessage(document.getElementById({0}).value);",
                                JScriptString.QuoteString(HiddenFieldNames.ErrorMessage, false)));
                }
                else
                {
                    hiddenCtrlInfo.FrameManagerInitializationScript =
                        new JScriptString(
                            ResHelper.Format(
                                "frameMgr.SetErrorMessage(document.getElementById({0}).value, {1}, {2});",
                                JScriptString.QuoteString(HiddenFieldNames.ErrorMessage, false),
                                JScriptString.QuoteString(this.ErrorTitle, false),
                                this.ErrorAsInfo ? "true" : "false"));
                }
                hiddenControlInfos.Add(hiddenCtrlInfo);
            }

            // If this is the first time rendering the frameset, need to write initialization information.
            if (this.mIsFramesetInitialization)
            {
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.Title);
                hiddenCtrlInfo.Value = this.GetSessionTitle(this.Session).ToHtmlString().ToString();
                hiddenCtrlInfo.FrameManagerInitializationScript =
                    new JScriptString(
                        ResHelper.Format(
                            "frameMgr.SetTitle(document.getElementById({0}).value);",
                            JScriptString.QuoteString(HiddenFieldNames.Title, false)));

                hiddenControlInfos.Add(hiddenCtrlInfo);
            }
            else
            {
                // Only update the toc when this is not the first rendering of the frameset. (The first time, the toc page itself
                // will get it correct.
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.TocState);
                hiddenCtrlInfo.Value = new PlainTextString(this.GetTocStates());
                hiddenCtrlInfo.FrameManagerInitializationScript =
                    new JScriptString(
                        ResHelper.FormatInvariant(
                            "frameMgr.SetTocNodes(document.getElementById({0}).value);",
                            JScriptString.QuoteString(HiddenFieldNames.TocState, false)));

                hiddenControlInfos.Add(hiddenCtrlInfo);
            }

            // Write content href value (value to GET into content frame) -- only if it's required
            hiddenCtrlInfo = new HiddenControlInfo();
            hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.ContentHref);
            sb = new StringBuilder(4096);

            // If we need to load the content frame because the current activity changed, or we need to render the content 
            // frame URL because there was an error, then figure out the content frame URL.

            if (this.LoadContentFrame || this.HasError)
            {
                // The activity has changed, so find the new Url for the content frame. 
                if (this.Session.HasCurrentActivity)
                {
                    sb.Append(this.GetContentFrameUrl());
                }
            }
            hiddenCtrlInfo.Value = new PlainTextString(new UrlString(sb.ToString()).ToAscii());
            hiddenCtrlInfo.FrameManagerInitializationScript =
                new JScriptString(
                    ResHelper.Format(
                        "frameMgr.SetContentFrameUrl(document.getElementById({0}).value);",
                        JScriptString.QuoteString(HiddenFieldNames.ContentHref, false)));

            hiddenControlInfos.Add(hiddenCtrlInfo);

            // Write the data model information, only if the current activity requires it.
            if (!this.SubmitPageDisplayed && this.CurrentActivityRequiresRte)
            {
                // There are 3 controls to update: the data model values and the map between n and id for interactions and objectives
                RteDataModelConverter converter = RteDataModelConverter.Create(this.Session);

                DataModelValues dataModelValues = converter.GetDataModelValues(this.FormatDataModelValueForClient);

                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.ObjectiveIdMap);
                hiddenCtrlInfo.Value = dataModelValues.ObjectiveIdMap;
                hiddenCtrlInfo.FrameManagerInitializationScript = null;
                hiddenControlInfos.Add(hiddenCtrlInfo);

                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.DataModel);
                hiddenCtrlInfo.Value = dataModelValues.Values;
                StringBuilder initCommand = new StringBuilder(1000);
                initCommand.AppendLine(
                    ResHelper.Format(
                        "var hidDM = document.getElementById({0});",
                        JScriptString.QuoteString(HiddenFieldNames.DataModel, false)));
                initCommand.AppendLine(
                    ResHelper.Format(
                        "var hidObjectiveMap = document.getElementById({0});",
                        JScriptString.QuoteString(HiddenFieldNames.ObjectiveIdMap, false)));
                initCommand.Append("frameMgr.InitDataModelValues(hidDM.value, hidObjectiveMap.value);");
                initCommand.AppendFormat("hidDM.value = {0};", JScriptString.QuoteString(string.Empty, false));
                initCommand.AppendFormat("hidObjectiveMap.value = {0};", JScriptString.QuoteString(string.Empty, false));
                hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString(initCommand.ToString());
                hiddenControlInfos.Add(hiddenCtrlInfo);
            }

            // If there was an IsMove*Valid request, send the response
            if (this.mIsNavValidResponse != null)
            {
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.IsNavigationValidResponse);
                hiddenCtrlInfo.Value = this.mIsNavValidResponse.ClientFieldResponse;
                hiddenCtrlInfo.FrameManagerInitializationScript =
                    new JScriptString(
                        ResHelper.FormatInvariant(
                            "frameMgr.SetIsNavigationValid(document.getElementById({0}).value);",
                            JScriptString.QuoteString(HiddenFieldNames.IsNavigationValidResponse, false)));

                hiddenControlInfos.Add(hiddenCtrlInfo);
            }

            if (this.mIsPostedPage)
            {
                // Set PostIsComplete. THIS MUST BE THE LAST VALUE SET! 
                hiddenCtrlInfo = new HiddenControlInfo();
                hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString("frameMgr.PostIsComplete();");
                hiddenControlInfos.Add(hiddenCtrlInfo);
            }
        }
예제 #5
0
 /// <summary>
 /// Write a hidden control to the string writer. The controlId shows up in id= and name= attributes. The 
 /// value is the Value of the control.
 /// </summary>
 private static void WriteHiddenControl(HtmlStringWriter sw, PlainTextString controlId, PlainTextString value)
 {
     sw.AddAttribute(HtmlTextWriterAttribute.Type, new HtmlString("hidden"));
     sw.AddAttribute(HtmlTextWriterAttribute.Id, controlId.ToHtmlString());
     sw.AddAttribute(HtmlTextWriterAttribute.Name, controlId.ToHtmlString());
     sw.AddAttribute(HtmlTextWriterAttribute.Value, value.ToHtmlString());
     sw.RenderBeginTag(HtmlTextWriterTag.Input);
     sw.RenderEndTag();
 }
예제 #6
0
        [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]    // parameter is validated
        protected void WriteError(PlainTextString message, bool allowReloadCurrentActivity)
        {
            FramesetUtil.ValidateNonNullParameter("message", message);
            string msgToDisplay;

            // If the message will contain a link to reload the current activity, then add the link to have the 
            // framesetMgr load the activity. We have to do this (rather than a get request) since we need to 
            // re-initialize the RTE object at this point.
            if (allowReloadCurrentActivity)
            {
                JScriptString js = new JScriptString(ResHelper.FormatInvariant("API_GetFramesetManager().DoChoice(\"{0}\");", 
                                    FramesetUtil.GetStringInvariant(m_session.CurrentActivityId)));
                string origMessage = message.ToString();
                StringBuilder sb = new StringBuilder(origMessage.Length * 2);
                sb.Append(ResHelper.Format("{0}<br><br><a href='{1}' >{2}</a>",origMessage, js.ToJavascriptProtocol(), IUDICO.TestingSystem.Localization.getMessage("HID_ReloadCurrentContent")));

                msgToDisplay = sb.ToString();
            }
            else
            {
                msgToDisplay = message.ToString();
            }
            RegisterError(IUDICO.TestingSystem.Localization.getMessage("HID_ServerErrorTitle"), msgToDisplay, false);
        }
예제 #7
0
#pragma warning restore 1591

        /// <summary>
        /// If there was an error condition, write the error message to the hidden control so that it can
        /// be displayed to the user. This method does not allow reloading the current content frame.
        /// </summary>
        /// <param name="message"></param>
        protected void WriteError(PlainTextString message)
        {
            WriteError(message, false);
        }
예제 #8
0
 internal DataModelValues(PlainTextString dataModelValues)
     : this(dataModelValues, "")
 {
 }
예제 #9
0
 internal DataModelValues(PlainTextString dataModelValues, PlainTextString objectiveIdMap)
 {
     m_dataModelValues = dataModelValues;
     m_objectiveIdMap  = objectiveIdMap;
 }
예제 #10
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);
예제 #11
0
 internal DataModelValues(PlainTextString dataModelValues)
     : this(dataModelValues, string.Empty)
 {
 }
예제 #12
0
 internal DataModelValues(PlainTextString dataModelValues, PlainTextString objectiveIdMap)
 {
     this.mDataModelValues = dataModelValues;
     this.mObjectiveIdMap  = objectiveIdMap;
 }
예제 #13
0
#pragma warning restore 1591

        /// <summary>
        /// If there was an error condition, write the error message to the hidden control so that it can
        /// be displayed to the user. This method does not allow reloading the current content frame.
        /// </summary>
        /// <param name="message"></param>
        protected void WriteError(PlainTextString message)
        {
            this.WriteError(message, false);
        }
예제 #14
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 (this.View == SessionView.Review)
            {
                throw new InvalidOperationException(
                          ResHelper.GetMessage(Localization.GetMessage("CONV_InvalidViewOnSetValue")));
            }

            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 "core":
                {
                    this.SetCoreValues(nameParts, value);
                    break;
                }

                case "suspend_data":
                {
                    this.DataModel.SuspendData = value;
                    break;
                }

                case "comments":
                {
                    this.SetCommentsFromLearner(value);
                    break;
                }

                case "objectives":
                {
                    this.VerifyElementNameTokens(4, nameParts);
                    this.SetObjectives(this.CurrentElementName.Substring(15), value);
                    break;
                }

                case "student_preference":
                {
                    this.VerifyElementNameTokens(3, nameParts);
                    this.SetLearnerPreferences(nameParts[2], value);
                    break;
                }

                case "interactions":
                {
                    this.SetInteractions(this.CurrentElementName.Substring(17), value);
                    break;
                }

                default:
                    // All other values are read-only (or invalid names). This will throw exception.
                    this.SetReadOnlyValue();
                    break;
                }
            }
            else
            {
                this.DataModel.ExtensionData[this.CurrentElementName] = value;
            }
        }