Example #1
0
        /// <summary>Writes the frame manager initialization javascript.</summary>
        public void WriteFrameMgrInit()
        {
            Response.Write(ResHelper.Format("frameMgr.SetAttemptId({0});\r\n", FramesetUtil.GetString(m_attemptId)));
            Response.Write(ResHelper.Format("frameMgr.SetView({0});\r\n", FramesetUtil.GetString(m_view)));
            Response.Write("frameMgr.SetPostFrame(\"frameHidden\");\r\n");
            Response.Write("frameMgr.SetPostableForm(GetHiddenFrame().contentWindow.document.forms[0]);\r\n");

            // Tell frameMgr to move to new activity
            Response.Write(ResHelper.Format("frameMgr.DoChoice(\"{0}\", true);\r\n", FramesetUtil.GetStringInvariant(m_activityId)));
        }
Example #2
0
        /// <summary>
        /// Gets the string to use to redirect the current response to ChangeActivity page.
        /// </summary>
        /// <returns></returns>
        private string GetRedirectLocation()
        {
            string url = ResHelper.Format("./ChangeActivity.aspx?{0}={1}&{2}={3}&{4}={5}",
                                          FramesetQueryParameter.View, FramesetUtil.GetString(Session.View),
                                          FramesetQueryParameter.AttemptId, FramesetUtil.GetStringInvariant(Session.AttemptId.GetKey()),
                                          FramesetQueryParameter.ActivityId, FramesetUtil.GetStringInvariant(Session.CurrentActivityId));
            UrlString urlStr = new UrlString(url);

            return(urlStr.ToAscii());
        }
Example #3
0
        /// <summary>
        /// Initialize information for the hidden controls and script. This sets up the information to create hidden fields in the form
        /// and to update the framesetMgr on page load.
        /// </summary>
        private void InitHiddenControlInfo(RenderContext context, StringBuilder onLoadScript)
        {
            // Should only do this if this is LRM content. Other content does not allow writing to the page.
            if (Session.CurrentActivityResourceType != ResourceType.Lrm)
            {
                return;
            }

            IDictionary <string, string> controls = context.FormHiddenControls;

            // Write the script to define frameMgr in script.
            WriteFindFrameMgr(onLoadScript);

            // If the session is attempt-based, then write attempt information
            if (Session != null)
            {
                controls.Add(HiddenFieldNames.AttemptId, FramesetUtil.GetStringInvariant(Session.AttemptId.GetKey()));
                onLoadScript.AppendFormat("frameMgr.SetAttemptId(document.getElementById({0}).value);\r\n",
                                          JScriptString.QuoteString(HiddenFieldNames.AttemptId, false));
            }

            // If the session has ended (that is, is suspended, completed or abandoned), then we're
            // done. Just return.
            if (SessionIsEnded)
            {
                return;
            }

            // Write view to display.

            controls.Add(HiddenFieldNames.View, FramesetUtil.GetString(Session.View));
            onLoadScript.AppendFormat("frameMgr.SetView(document.getElementById({0}).value);\r\n",
                                      JScriptString.QuoteString(HiddenFieldNames.View, false));

            // Write frame to post.
            controls.Add(HiddenFieldNames.PostFrame, "frameContent");
            onLoadScript.AppendFormat("frameMgr.SetPostFrame(document.getElementById({0}).value);\r\n",
                                      JScriptString.QuoteString(HiddenFieldNames.PostFrame, false));

            // Set contentFrameUrl to be null. This prevents the content frame from being re-loaded.
            onLoadScript.Append("frameMgr.SetContentFrameUrl(null);\r\n");

            // 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 (ActivityHasChanged)
            {
                string initNewActivity = "false";
                if (Session.HasCurrentActivity)
                {
                    initNewActivity = (CurrentActivityRequiresRte ? "true" : "false");
                }
                onLoadScript.AppendFormat("frameMgr.InitNewActivity( {0} );\r\n", initNewActivity);
            }

            // Write the current activity Id. Write -1 if there isn't one.
            controls.Add(HiddenFieldNames.ActivityId, (Session.HasCurrentActivity ? FramesetUtil.GetStringInvariant(Session.CurrentActivityId) : "-1"));
            onLoadScript.AppendFormat("frameMgr.SetActivityId(document.getElementById({0}).value);\r\n",
                                      JScriptString.QuoteString(HiddenFieldNames.ActivityId, false));

            // 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
            StringBuilder sb = new StringBuilder(10);

            sb.Append((Session.ShowNext) ? "T" : "F");
            sb.Append(";");
            sb.Append((Session.ShowPrevious) ? "T" : "F");
            sb.Append(";");
            sb.Append((Session.ShowAbandon) ? "T" : "F");
            sb.Append(";");
            sb.Append((Session.ShowExit) ? "T" : "F");
            sb.Append(";");
            sb.Append((Session.ShowSave) ? "T" : "F");
            sb.Append(";");
            onLoadScript.AppendFormat("frameMgr.SetNavVisibility( {0}, {1}, {2}, {3}, {4});\r\n",
                                      (Session.ShowNext ? "true" : "false"),
                                      (Session.ShowPrevious ? "true" : "false"),
                                      (Session.ShowAbandon ? "true" : "false"),
                                      (Session.ShowExit ? "true" : "false"),
                                      (Session.ShowSave ? "true" : "false"));
            controls.Add(HiddenFieldNames.ShowUI, sb.ToString());

            context.Script = onLoadScript.ToString();
        }
Example #4
0
        /// <summary>Write initialization code for frameset manager. </summary>
        /// <remarks>
        /// This method is called in three possible cases:
        /// 1. An error condition occurred
        /// 2. The submit page is being displayed. Note that in this case, since the submit page is registered as displaying an
        /// error condition, HasError will be true.
        /// 3. The current activity has changed and we display this page mainly so that the 'please wait' information can be
        /// displayed and the client can issue a GET request to load the new activity.
        /// </remarks>
        public void WriteFrameMgrInit()
        {
            // Write frame to post. When displaying an error (which is the case, since we are here) the hidden frame is posted next
            Response.Write("frameMgr.SetPostFrame('frameHidden');\r\n");
            Response.Write("frameMgr.SetPostableForm(window.top.frames[MAIN_FRAME].document.getElementById(HIDDEN_FRAME).contentWindow.document.forms[0]);\r\n");

            if (HasError || SubmitPageDisplayed)
            {
                // Set the content frame URL to be null. This means the content frame will not be re-loaded by the frameMgr.
                Response.Write("frameMgr.SetContentFrameUrl(null); \r\n");
            }

            // If there is no session, we can't do anything else
            if (Session == null)
            {
                return;
            }

            if ((ActivityHasChanged) && (!SubmitPageDisplayed))
            {
                // Reload the content frame with the new activity.
                Response.Write(String.Format(CultureInfo.CurrentCulture, "frameMgr.SetContentFrameUrl(\"{0}\"); \r\n", GetContentFrameUrl()));

                // The new activity may be scorm content, so reinitialize the rte, if needed
                Response.Write(ResHelper.Format("frameMgr.InitNewActivity( {0} );\r\n", (CurrentActivityRequiresRte ? "true" : "false")));
            }

            Response.Write(ResHelper.Format("frameMgr.SetAttemptId('{0}');\r\n", FramesetUtil.GetStringInvariant(Session.AttemptId.GetKey())));

            // Write view to display.
            Response.Write(String.Format(CultureInfo.CurrentCulture, "frameMgr.SetView('{0}');\r\n", FramesetUtil.GetString(Session.View)));

            // Write the current activity Id. Write -1 if there isn't one.
            string activityId;

            if (SubmitPageDisplayed)
            {
                activityId = SubmitId;
            }
            else
            {
                activityId = (Session.HasCurrentActivity ? FramesetUtil.GetStringInvariant(Session.CurrentActivityId) : "-1");
            }
            Response.Write(String.Format(CultureInfo.InvariantCulture, "frameMgr.SetActivityId({0});\r\n",
                                         JScriptString.QuoteString(activityId, true)));

            // Write nav visibility, in case it's changed since the hidden frame was rendered
            if (SubmitPageDisplayed)
            {
                // If the submit page is being displayed, don't show UI elements
                Response.Write(String.Format(CultureInfo.CurrentCulture, "frameMgr.SetNavVisibility( {0}, {1}, {2}, {3}, {4});",
                                             ("false"), // showNext
                                             ("false"), // showPrevious
                                             ("false"), // showAbandon
                                             ("false"), // showExit
                                             (Session.ShowSave ? "true" : "false")));

                // If the submit page is now being displayed, make sure the frameset isn't waiting for another commit
                Response.Write("frameMgr.WaitForContentCompleted(0);\r\n");
            }
            else
            {
                Response.Write(String.Format(CultureInfo.CurrentCulture, "frameMgr.SetNavVisibility( {0}, {1}, {2}, {3}, {4});\r\n",
                                             (Session.ShowNext ? "true" : "false"),
                                             (Session.ShowPrevious ? "true" : "false"),
                                             (Session.ShowAbandon ? "true" : "false"),
                                             (Session.ShowExit ? "true" : "false"),
                                             (Session.ShowSave ? "true" : "false")));
            }

            // Register that the frame loading is complete. This is required so as to notify the frameset of activity id, and
            // other UI status.
            Response.Write(String.Format(CultureInfo.InvariantCulture, "frameMgr.RegisterFrameLoad({0});\r\n ",
                                         JScriptString.QuoteString("frameContent", false)));

            if (m_isPostedPage)
            {
                // Set PostIsComplete. THIS MUST BE THE LAST VALUE SET!
                Response.Write("frameMgr.PostIsComplete();");
            }
        }