Exemplo n.º 1
0
        public virtual Collection <string> FinishSetValue()
        {
            List <string> errors = new List <string>();

            foreach (Objective obj in this.mPendingObjectives)
            {
                try
                {
                    this.mDm.Objectives.Add(obj);
                }
                catch (Exception e)
                {
                    errors.Add(
                        ResHelper.GetMessage(
                            Localization.GetMessage("CONV_SetValueObjective"), e.Message));
                }
            }

            foreach (Interaction interaction in this.mPendingInteractions)
            {
                try
                {
                    this.mDm.Interactions.Add(interaction);
                }
                catch (Exception e)
                {
                    errors.Add(
                        ResHelper.GetMessage(
                            Localization.GetMessage("CONV_SetValueInteraction"), e.Message));
                }
            }

            return(new Collection <string>(errors));
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.mHelper = new ChangeActivityHelper(this.Request, this.Response);
                this.mHelper.ProcessPageLoad(
                    this.ProcessViewParameter,
                    this.ProcessAttemptIdParameter,
                    this.TryGetActivityId,
                    this.RegisterError,
                    this.GetErrorInfo,
                    this.GetMessage);
                this.mPageLoadSuccessful = (!this.HasError);
            }
            catch (Exception e2)
            {
                this.RegisterError(
                    ResHelper.GetMessage(Localization.GetMessage("FRM_UnknownExceptionTitle")),
                    ResHelper.GetMessage(Localization.GetMessage("FRM_UnknownExceptionMsg"), HttpUtility.HtmlEncode(e2.Message)),
                    false);
                this.mPageLoadSuccessful = false;

                // Clear any existing response information so that the error gets rendered correctly.
                this.Response.Clear();
            }
        }
Exemplo n.º 3
0
        public virtual Collection <string> FinishSetValue()
        {
            List <string> errors = new List <string>();

            foreach (Objective obj in m_pendingObjectives)
            {
                try
                {
                    m_dm.Objectives.Add(obj);
                }
                catch (Exception e)
                {
                    errors.Add(ResHelper.GetMessage(FramesetResources.CONV_SetValueObjective, e.Message));
                }
            }

            foreach (Interaction interaction in m_pendingInteractions)
            {
                try
                {
                    m_dm.Interactions.Add(interaction);
                }
                catch (Exception e)
                {
                    errors.Add(ResHelper.GetMessage(FramesetResources.CONV_SetValueInteraction, e.Message));
                }
            }

            return(new Collection <string>(errors));
        }
Exemplo n.º 4
0
        public bool GetActivityInfo(bool showErrorPage, out long activityId)
        {
            // This will only be called in Review view, in which case, m_contentPathParts is...

            // m_contentPathParts[1] = view, m_contentPathParts[2] = attemptId, m_contentPathParts[3] = activityId to display, m_contentPathParts[4] and beyond is resource path

            // activity id must be provided
            activityId = -1;
            bool isValid = false;

            if (m_contentPathParts.Length >= 4)
            {
                string strActivityId = m_contentPathParts[3];
                if (long.TryParse(strActivityId, out activityId))
                {
                    if (activityId > 0)
                    {
                        isValid = true;
                    }
                }
            }
            if (!isValid)
            {
                if (showErrorPage)
                {
                    RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("CON_ContentCannotBeDisplayedTitle")),
                                  ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("CON_ContentCannotBeDisplayedMsg")), false);
                }
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        public bool GetAttemptInfo(bool showErrorPage, out AttemptItemIdentifier attemptId)
        {
            attemptId = null;

            long attemptKey;
            bool isValid = false;

            // For views based on an attempt, AttemptId is required
            // It must be a positive long value.
            if (m_contentPathParts.Length >= 3)
            {
                if (long.TryParse(m_contentPathParts[2], out attemptKey))
                {
                    if (attemptKey > 0)
                    {
                        attemptId = new AttemptItemIdentifier(attemptKey);
                        isValid   = true;
                    }
                }
            }
            if (!isValid)
            {
                if (showErrorPage)
                {
                    RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("CON_ContentCannotBeDisplayedTitle")),
                                  ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("CON_ContentCannotBeDisplayedMsg")), false);
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        // Translate the value (eg, "passed") into a LessonStatus value
        private LessonStatus GetLessonStatus(string value)
        {
            switch (value)
            {
            case "passed":
                return(LessonStatus.Passed);

            case "completed":
                return(LessonStatus.Completed);

            case "failed":
                return(LessonStatus.Failed);

            case "incomplete":
                return(LessonStatus.Incomplete);

            case "browsed":
                return(LessonStatus.Browsed);

            case "not attempted":
                return(LessonStatus.NotAttempted);

            default:
                throw new InvalidOperationException(
                          ResHelper.GetMessage(
                              Localization.GetMessage("CONV_SetValueInvalidValue"),
                              value,
                              this.CurrentElementName));
            }
        }
Exemplo n.º 7
0
        // Set the score field (eg, "raw") on a Score object.
        protected override void SetScoreSubField(string scoreField, string value, Score score)
        {
            float scoreValue;

            if (!float.TryParse(value, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out scoreValue))
            {
                throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueInvalidValue, value, CurrentElementName));
            }

            switch (scoreField)
            {
            case "raw":
            {
                score.Raw = scoreValue;
            }
            break;

            case "min":
            {
                score.Minimum = scoreValue;
            }
            break;

            case "max":
            {
                score.Maximum = scoreValue;
            }
            break;

            default:
                throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueInvalidName, CurrentElementName));
            }
        }
Exemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         this.mHiddenHelper = new HiddenHelper(this.Request, this.Response, this.FramesetPath);
         this.mHiddenHelper.ProcessPageLoad(
             this.PStore,
             this.GetSessionTitle,
             this.ProcessViewParameter,
             this.ProcessAttemptIdParameter,
             AppendContentFrameDetails,
             this.RegisterError,
             this.GetErrorInfo,
             this.ProcessSessionEnd,
             this.ProcessViewRequest,
             this.GetMessage,
             this.IsPostBack);
     }
     catch (ThreadAbortException)
     {
         // Do nothing -- thread is leaving.
     }
     catch (Exception ex)
     {
         this.ClearError();
         this.RegisterError(
             ResHelper.GetMessage(Localization.GetMessage("FRM_UnknownExceptionTitle")),
             ResHelper.GetMessage(Localization.GetMessage("FRM_UnknownExceptionMsg"), HttpUtility.HtmlEncode(ex.Message.Replace("\r\n", " "))),
             false);
     }
 }
Exemplo n.º 9
0
        // Set cmi.objectives.n.<x> values. SubElementName is n.<x>
        private void SetObjectives(string subElementName, string value)
        {
            string[] elementParts = subElementName.Split('.');

            if (elementParts.Length < 2)
            {
                throw new InvalidOperationException(
                          ResHelper.GetMessage(
                              Localization.GetMessage("CONV_SetValueInvalidName"),
                              this.CurrentElementName));
            }

            int index;

            if (!int.TryParse(elementParts[0], out index))
            {
                throw new InvalidOperationException(
                          ResHelper.GetMessage(
                              Localization.GetMessage("CONV_SetValueInvalidName"),
                              this.CurrentElementName));
            }

            Objective objective;

            if (index < this.ObjectivesByIndex.Count)
            {
                // It's already in the list, so find the object
                objective = this.ObjectivesByIndex[index];
            }
            else
            {
                // It's a new objective. Add it to the list of pending objectives.
                objective = this.DataModel.CreateObjective();
                this.PendingObjectives.Add(objective);
                this.ObjectivesByIndex.Add(index, objective);
            }

            switch (elementParts[1])
            {
            case "id":
                objective.Id = value;
                break;

            case "score":
                this.SetScoreSubField(elementParts[2], value, objective.Score);
                break;

            case "status":
                objective.Status = this.GetLessonStatus(value);
                break;

            default:
                throw new InvalidOperationException(
                          ResHelper.GetMessage(
                              Localization.GetMessage("CONV_SetValueInvalidName"),
                              this.CurrentElementName));
            }
        }
Exemplo n.º 10
0
 private static string GetRteTimeSpan(int hours, int min, int sec, int ms)
 {
     return(ResHelper.GetMessage(
                "{0}:{1}:{2}.{3}",
                RteIntValue(hours, "D4"),
                RteIntValue(min, "D2"),
                RteIntValue(sec, "D2"),
                RteIntValue(ms, "D2")));
 }
Exemplo n.º 11
0
        [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]    // parameter is validated
        protected void VerifyElementNameTokens(int numberRequired, string[] nameTokens)
        {
            FramesetUtil.ValidateNonNullParameter("nameTokens", nameTokens);

            if (nameTokens.Length < numberRequired)
            {
                throw new InvalidOperationException(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("CONV_SetValueInvalidName"), m_currentElementName));
            }
        }
Exemplo n.º 12
0
        [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]    // parameter is validated
        protected void VerifyElementNameTokens(int numberRequired, string[] nameTokens)
        {
            FramesetUtil.ValidateNonNullParameter("nameTokens", nameTokens);

            if (nameTokens.Length < numberRequired)
            {
                throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueInvalidName, m_currentElementName));
            }
        }
Exemplo n.º 13
0
        // Given an rte-formated timespan, return a TimeSpan object.
        protected override TimeSpan TimeSpanFromRte(string rteTimeSpan)
        {
            // Format is (HH)HH:MM:SS(.SS) where () represents optional elements

            MatchCollection matches = Regex.Matches(rteTimeSpan, @"^(\d{2,4}):(\d\d):(\d\d)(?:\.(\d{1,2}))?$");

            if (matches.Count != 1)
            {
                throw new InvalidOperationException(
                          ResHelper.GetMessage(
                              Localization.GetMessage("CONV_SetValueInvalidValue"),
                              rteTimeSpan,
                              this.CurrentElementName));
            }

            GroupCollection groups = matches[0].Groups;

            if (groups.Count != 5)
            {
                throw new InvalidOperationException(
                          ResHelper.GetMessage(
                              Localization.GetMessage("CONV_SetValueInvalidValue"),
                              rteTimeSpan,
                              this.CurrentElementName));
            }

            TimeSpan retVal;

            try
            {
                int hours = int.Parse(groups[1].Value, NumberFormatInfo.InvariantInfo);
                int mins  = int.Parse(groups[2].Value, NumberFormatInfo.InvariantInfo);
                int secs  = int.Parse(groups[3].Value, NumberFormatInfo.InvariantInfo);

                if (!string.IsNullOrEmpty(groups[4].Value))
                {
                    int ms = int.Parse(groups[4].Value, NumberFormatInfo.InvariantInfo);
                    retVal = new TimeSpan(0, hours, mins, secs, ms);
                }
                else
                {
                    retVal = new TimeSpan(hours, mins, secs);
                }

                return(retVal);
            }
            catch (FormatException)
            {
                throw new InvalidOperationException(
                          ResHelper.GetMessage(
                              Localization.GetMessage("CONV_SetValueInvalidValue"),
                              rteTimeSpan,
                              this.CurrentElementName));
            }
        }
Exemplo n.º 14
0
        private void SetLearnerPreferences(string subElementName, string value)
        {
            switch (subElementName)
            {
            case "audio":
            {
                int level;
                if (Int32.TryParse(value, out level))
                {
                    DataModel.Learner.AudioLevel = (float)level;
                    return;
                }
                // couldn't parse it...
                throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueInvalidValue, value, CurrentElementName));
            }

            case "language":
            {
                DataModel.Learner.Language = value;
                return;
            }

            case "speed":
            {
                int deliverySpeed;
                if (Int32.TryParse(value, out deliverySpeed))
                {
                    DataModel.Learner.DeliverySpeed = (float)deliverySpeed;
                    return;
                }
                // couldn't parse it
                throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueInvalidValue, value, CurrentElementName));
            }

            case "text":
            {
                try
                {
                    AudioCaptioning captioning;
                    captioning = (AudioCaptioning)Enum.Parse(typeof(AudioCaptioning), value);
                    DataModel.Learner.AudioCaptioning = captioning;
                    return;
                }
                catch
                {
                    throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueInvalidValue, value, CurrentElementName));
                }
            }
            }

            // If we got here, the element name wasn't valid
            throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueInvalidName, CurrentElementName));
        }
Exemplo n.º 15
0
        public bool GetViewInfo(bool showErrorPage, out SessionView view)
        {
            // make compiler happy
            view = SessionView.Execute;

            // Get the parts of the content path (parameter PF) value
            // pfParts[0] = "", pfParts[1] = view, pfParts[2] = extra view data, everything else is path or extra data for attempt views
            this.mContentPathParts = this.mContentPath.Split(new[] { '/' });

            // First section is view -- it must exist in all cases.
            string strView = this.mContentPathParts[1];

            if (string.IsNullOrEmpty(strView))
            {
                if (showErrorPage)
                {
                    this.RegisterError(
                        ResHelper.GetMessage(Localization.GetMessage("FRM_ParameterRequiredTitle"), FramesetQueryParameter.View),
                        ResHelper.GetMessage(Localization.GetMessage("FRM_ParameterRequiredMsg"), FramesetQueryParameter.View),
                        false);
                }
                return(false);
            }

            try
            {
                view = (SessionView)Enum.Parse(typeof(SessionView), strView, true);
                if (!Enum.IsDefined(typeof(SessionView), view))
                {
                    if (showErrorPage)
                    {
                        this.RegisterError(
                            ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View),
                            ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, strView),
                            false);
                    }
                    return(false);
                }
            }
            catch (ArgumentException)
            {
                if (showErrorPage)
                {
                    this.RegisterError(
                        ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View),
                        ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, strView),
                        false);
                }
                return(false);
            }
            this.mView = view;
            return(true);
        }
Exemplo n.º 16
0
 public bool TryGetRequiredParameter(bool showErrorPage, string name, out string value)
 {
     value = m_request.QueryString[name];
     if (String.IsNullOrEmpty(value))
     {
         if (showErrorPage)
         {
             RegisterError(ResHelper.GetMessage(FramesetResources.FRM_ParameterRequiredTitle, name),
                           ResHelper.GetMessage(FramesetResources.FRM_ParameterRequiredMsg, name), false);
         }
         return(false);
     }
     return(true);
 }
Exemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Get the path to the content. This may be part of the url (if we are running without
                // an http module) or a URL parameter (with http module). We run in both modes because
                // VS.NET does not parse URLs of the form: /.../Content.aspx/0/1/foo.gif correctly without
                // the assistance of the module.
                this.mContentPath = this.GetContentPath();
                bool isPosted = false;
                if (string.CompareOrdinal(this.Request.HttpMethod, "POST") == 0)
                {
                    isPosted = true;
                }

                this.mContentHelper = new ContentHelper(this.Request, this.Response, this.FramesetPath);
                this.mContentHelper.ProcessPageLoad(
                    this.PStore,
                    string.IsNullOrEmpty(this.mContentPath),
                    isPosted,
                    this.GetViewInfo,
                    this.GetAttemptInfo,
                    this.GetActivityInfo,
                    this.GetResourcePath,
                    AppendContentFrameDetails,
                    this.UpdateRenderContext,
                    this.ProcessPostedData,
                    this.ProcessViewRequest,
                    this.ProcessPostedDataComplete,
                    this.RegisterError,
                    this.GetErrorInfo,
                    this.GetMessage);
            }
            catch (ThreadAbortException)
            {
                // response ended. Do nothing.
                return;
            }
            catch (Exception e2)
            {
                this.ClearError();
                this.RegisterError(
                    ResHelper.GetMessage(Localization.GetMessage("FRM_UnknownExceptionTitle")),
                    ResHelper.GetMessage(Localization.GetMessage("FRM_UnknownExceptionMsg"), HttpUtility.HtmlEncode(e2.Message.Replace("\r\n", " "))),
                    false);

                // Clear any existing response information so that the error gets rendered correctly.
                this.Response.Clear();
            }
        }
Exemplo n.º 18
0
 public bool TryGetRequiredParameter(bool showErrorPage, string name, out string value)
 {
     value = m_request.QueryString[name];
     if (String.IsNullOrEmpty(value))
     {
         if (showErrorPage)
         {
             RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_ParameterRequiredTitle"), name),
                           ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_ParameterRequiredMsg"), name), false);
         }
         return(false);
     }
     return(true);
 }
Exemplo n.º 19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         m_tocHelper = new TocHelper();
         m_tocHelper.ProcessPageLoad(Response, PStore, ProcessViewParameter,
                                     ProcessAttemptIdParameter, ProcessViewRequest, RegisterError,
                                     FramesetResources.TOC_SubmitAttempt);
     }
     catch (Exception ex)
     {
         RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnexpectedErrorTitle),
                       ResHelper.GetMessage(FramesetResources.FRM_UnexpectedError, HttpUtility.HtmlEncode(ex.Message)), false);
     }
 }
Exemplo n.º 20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         m_tocHelper = new TocHelper();
         m_tocHelper.ProcessPageLoad(Response, PStore, ProcessViewParameter,
                                     ProcessAttemptIdParameter, ProcessViewRequest, RegisterError,
                                     IUDICO.TestingSystem.Localization.getMessage("TOC_SubmitAttempt"));
     }
     catch (Exception ex)
     {
         RegisterError(ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_UnexpectedErrorTitle")),
                       ResHelper.GetMessage(IUDICO.TestingSystem.Localization.getMessage("FRM_UnexpectedError"), HttpUtility.HtmlEncode(ex.Message)), false);
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// Delegate implementation to allow the frameset to take action on a session view request. This allows SLK and
        /// BWP to have different behavior and messages about which requests are not valid.
        /// </summary>
        public bool ProcessViewRequest(SessionView view, LearningSession session)
        {
            this.Completed = false;
            switch (view)
            {
            case SessionView.Execute:
            {
                StoredLearningSession slsSession = session as StoredLearningSession;
                if (slsSession != null)
                {
                    if (slsSession.AttemptStatus == AttemptStatus.Completed)
                    {
                        this.RegisterError(
                            ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidAttemptStatusForViewTitle")),
                            ResHelper.GetMessage(Localization.GetMessage("FRM_ExecuteViewCompletedSessionMsg")),
                            false);
                        this.Completed = true;
                        return(false);
                    }
                    else if (slsSession.AttemptStatus == AttemptStatus.Abandoned)
                    {
                        this.RegisterError(
                            ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidAttemptStatusForViewTitle")),
                            ResHelper.GetMessage(Localization.GetMessage("FRM_ExecuteViewAbandonedSessionMsg")),
                            false);
                        return(false);
                    }
                }
            }
            break;

            case SessionView.Review:
                // BWP does not provide review view
                this.RegisterError(
                    ResHelper.GetMessage(Localization.GetMessage("FRM_ViewNotSupportedTitle")),
                    ResHelper.GetMessage(Localization.GetMessage("FRM_ReviewViewNotSupportedMsg")),
                    false);
                break;

            case SessionView.RandomAccess:
                this.RegisterError(
                    ResHelper.GetMessage(Localization.GetMessage("FRM_ViewNotSupportedTitle")),
                    ResHelper.GetMessage(Localization.GetMessage("FRM_RAViewNotSupportedMsg")),
                    false);
                break;
            }
            return(true);
        }
Exemplo n.º 22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         m_hiddenHelper = new HiddenHelper(Request, Response, FramesetPath);
         m_hiddenHelper.ProcessPageLoad(PStore, GetSessionTitle, ProcessViewParameter, ProcessAttemptIdParameter,
                                        AppendContentFrameDetails, RegisterError, GetErrorInfo, ProcessSessionEnd, ProcessViewRequest,
                                        GetMessage, IsPostBack);
     }
     catch (ThreadAbortException)
     {
         // Do nothing -- thread is leaving.
     }
     catch (Exception ex)
     {
         ClearError();
         RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionTitle),
                       ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionMsg, HttpUtility.HtmlEncode(ex.Message.Replace("\r\n", " "))), false);
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// Write the 'please wait' page to the response. This clears anything else in the response.
        /// </summary>
        private static void WritePleaseWaitToResponse(HttpResponse response)
        {
            response.Clear();
            response.ContentType = "text/html";

            response.Write("<html><head>");
            response.Write("<LINK rel=\"stylesheet\" type=\"text/css\" href=\"./Theme/Styles.css\"/></head>");
            response.Write("<body class=\"ErrorBody\">");

            response.Write("<table border=\"0\" width=\"100%\" id=\"table1\" style=\"border-collapse: collapse\">");
            response.Write("<tr><td class=\"ErrorTitle\">&nbsp;</td></tr>");
            response.Write("<tr><td align=\"center\">");
            response.Write(ResHelper.GetMessage(FramesetResources.CON_PleaseWait));
            response.Write("</td></tr>");
            response.Write("<tr><td class=\"ErrorMessage\">&nbsp;</td></tr>");
            response.Write("</table>");

            response.Write("</body>");
            response.Write("</html>");
        }
Exemplo n.º 24
0
        /// <summary>
        /// Helper function to process the View parameter. This method assumes the parameter is required. If it does not
        /// exist or is not a valid value and showErrorPage=true, the error page is shown and the method returns false.
        /// If false is returned, the caller should ignore the value of <paramref name="view"/>.
        /// </summary>
        /// <param name="showErrorPage">TODO</param>
        /// <param name="view">TODO</param>
        public bool TryProcessViewParameter(bool showErrorPage, out SessionView view)
        {
            string viewParam;

            // Default value to make compiler happy
            view = SessionView.Execute;

            if (!this.TryGetRequiredParameter(FramesetQueryParameter.View, out viewParam))
            {
                return(false);
            }

            try
            {
                // Get the view enum value
                view = (SessionView)Enum.Parse(typeof(SessionView), viewParam, true);
                if ((view < SessionView.Execute) || (view > SessionView.Review))
                {
                    if (showErrorPage)
                    {
                        this.RegisterError(
                            ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View),
                            ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, viewParam),
                            false);
                    }
                    return(false);
                }
            }
            catch (ArgumentException)
            {
                if (showErrorPage)
                {
                    this.RegisterError(
                        ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.View),
                        ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.View, viewParam),
                        false);
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 25
0
        // public bool TryGetSessionView(bool showErrorPage, out SessionView view)
        // {
        // string viewParam;

        // // Default value to make compiler happy
        // view = SessionView.Execute;

        // if (!TryGetRequiredParameter(FramesetQueryParameter.View, out viewParam))
        // return false;

        // try
        // {
        // // Get the view enum value
        // view = (SessionView)Enum.Parse(typeof(SessionView), viewParam, true);
        // if ((view < SessionView.Execute) || (view > SessionView.Review))
        // {
        // if (showErrorPage)
        // {
        // RegisterError(ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterTitle, FramesetQueryParameter.View),
        // ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterMsg, FramesetQueryParameter.View, viewParam), false);
        // }
        // return false;
        // }
        // }
        // catch (ArgumentException)
        // {
        // if (showErrorPage)
        // {
        // RegisterError(ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterTitle, FramesetQueryParameter.View),
        // ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterMsg, FramesetQueryParameter.View, viewParam), false);
        // }
        // return false;
        // }
        // return true;
        // }

        public bool TryGetActivityId(bool showErrorPage, out long activityId)
        {
            string activityIdParam = null;
            bool   isValid         = true;

            activityId = -1;

            if (!this.GetRequiredParameter(FramesetQueryParameter.ActivityId, out activityIdParam))
            {
                return(false);
            }

            // Try converting it to a long value. It must be positive.
            try
            {
                long activityIdKey = long.Parse(activityIdParam, NumberFormatInfo.InvariantInfo);

                if (activityIdKey <= 0)
                {
                    isValid = false;
                }
                else
                {
                    activityId = activityIdKey;
                }
            }
            catch (FormatException)
            {
                isValid = false;
            }

            if (!isValid && showErrorPage)
            {
                this.RegisterError(
                    ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.ActivityId),
                    ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.ActivityId, activityIdParam),
                    false);
            }

            return(isValid);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Helper function to get the AttemptId query parameter. This method assumes the parameter is required. If
        /// it does not exist or is not numeric, the error page is shown. This method does not check LearningStore.
        /// </summary>
        /// <param name="isRequired">If true, the error page is shown if the value is not provided.</param>
        /// <param name="attemptId">The attempt id.</param>
        /// <returns>If false, the value did not exist or was not valid. The application should not continue with
        /// page processing.</returns>
        public bool ProcessAttemptIdParameter(bool showErrorPage, out AttemptItemIdentifier attemptId)
        {
            string attemptParam = null;
            bool   isValid      = true;

            attemptId = null;

            if (!this.GetRequiredParameter(FramesetQueryParameter.AttemptId, out attemptParam))
            {
                return(false);
            }

            // Try converting it to a long value. It must be positive.
            try
            {
                long attemptKey = long.Parse(attemptParam, NumberFormatInfo.InvariantInfo);

                if (attemptKey <= 0)
                {
                    isValid = false;
                }
                else
                {
                    attemptId = new AttemptItemIdentifier(attemptKey);
                }
            }
            catch (FormatException)
            {
                isValid = false;
            }

            if (!isValid && showErrorPage)
            {
                this.RegisterError(
                    ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterTitle"), FramesetQueryParameter.AttemptId),
                    ResHelper.GetMessage(Localization.GetMessage("FRM_InvalidParameterMsg"), FramesetQueryParameter.AttemptId, attemptParam),
                    false);
            }

            return(isValid);
        }
Exemplo n.º 27
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         this.mTocHelper = new TocHelper();
         this.mTocHelper.ProcessPageLoad(
             this.Response,
             this.PStore,
             this.ProcessViewParameter,
             this.ProcessAttemptIdParameter,
             this.ProcessViewRequest,
             this.RegisterError,
             Localization.GetMessage("TOC_SubmitAttempt"));
     }
     catch (Exception ex)
     {
         this.RegisterError(
             ResHelper.GetMessage(Localization.GetMessage("FRM_UnexpectedErrorTitle")),
             ResHelper.GetMessage(Localization.GetMessage("FRM_UnexpectedError"), HttpUtility.HtmlEncode(ex.Message)),
             false);
     }
 }
Exemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                m_helper = new ChangeActivityHelper(Request, Response);
                m_helper.ProcessPageLoad(ProcessViewParameter,
                                         ProcessAttemptIdParameter,
                                         TryGetActivityId,
                                         RegisterError,
                                         GetErrorInfo,
                                         GetMessage);
                m_pageLoadSuccessful = (!HasError);
            }
            catch (Exception e2)
            {
                RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionTitle),
                              ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionMsg, HttpUtility.HtmlEncode(e2.Message)), false);
                m_pageLoadSuccessful = false;

                // Clear any existing response information so that the error gets rendered correctly.
                Response.Clear();
            }
        }
Exemplo n.º 29
0
 // SetValue called on any read-only element. subElementName is ignored.
 protected void SetReadOnlyValue()
 {
     throw new InvalidOperationException(
               ResHelper.GetMessage(
                   Localization.GetMessage("CONV_SetValueReadOnly"), this.mCurrentElementName));
 }
Exemplo n.º 30
0
 // SetValue called on any read-only element. subElementName is ignored.
 protected void SetReadOnlyValue()
 {
     throw new InvalidOperationException(ResHelper.GetMessage(FramesetResources.CONV_SetValueReadOnly, m_currentElementName));
 }