Beispiel #1
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);
        }
Beispiel #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(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);
        }
Beispiel #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>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;
            }
        }