Exemple #1
0
        protected void slkButtonDelete_Click(object sender, EventArgs e)
        {
            try
            {
                // Delete corresponding assignment folder from the drop box if exists
                if (AssignmentProperties.PackageFormat == null)
                {
                    DropBoxManager dropBoxMgr = new DropBoxManager(AssignmentProperties);
                    dropBoxMgr.DeleteAssignmentFolder();
                }

                SlkStore.DeleteAssignment(AssignmentProperties.Id);
                Response.Redirect(SPWeb.ServerRelativeUrl, true);
            }
            catch (ThreadAbortException)
            {
                // Calling Response.Redirect throws a ThreadAbortException which will
                // flag an error in the next step if we don't do this.
                throw;
            }
            catch (Exception exception)
            {
                errorBanner.AddException(SlkStore, new SafeToDisplayException(PageCulture.Resources.LobbyDeleteException));
                SlkStore.LogException(exception);
            }
        }
Exemple #2
0
        protected void slkButtonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    LearnerAssignmentProperties.Submit();
                    LearnerAssignmentProperties.SaveLearnerComment(LearnerComments.Text);
                }
                catch (InvalidOperationException)
                {
                    // state transition isn't supported
                    errorBanner.AddException(SlkStore, new SafeToDisplayException(PageCulture.Resources.LobbyCannotChangeState));
                }

                // Clear the object so it will refresh from the database
                LearnerAssignmentProperties = null;
            }
            catch (LearningStoreConstraintViolationException exception)
            {
                // any exceptions here will be handled in PreRender
                errorBanner.AddException(SlkStore, new SafeToDisplayException(PageCulture.Resources.LobbySubmitException));
                SlkStore.LogException(exception);
            }
        }
        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] // all exceptions caught and written to server event log
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                CheckPlayAssignment();
                SlkUtilities.RetryOnDeadlock(delegate()
                {
                    Response.Clear();
                    ClearError();

                    m_framesetHelper = new FramesetHelper();
                    m_framesetHelper.ProcessPageLoad(SlkStore.PackageStore, TryGetSessionView, TryGetAttemptId, ProcessViewRequest);

                    // If this is not e-learning content, then we have to write the content directly to response.
                    if (!HasError && !m_isELearning)
                    {
                        SendNonElearningContent();
                        Response.End();
                    }
                });
            }
            catch (ThreadAbortException)
            {
                // response ended. Do nothing.
                return;
            }
            catch (FileNotFoundException)
            {
                Response.StatusCode        = 404;
                Response.StatusDescription = "Not Found";

                RegisterError(SlkFrameset.FRM_DocumentNotFoundTitleHtml, SlkFrameset.FRM_DocumentNotFound, false);
            }
            catch (UserNotFoundException)
            {
                Response.StatusCode        = 500;
                Response.StatusDescription = "Internal Server Error";

                // This probably indicates the site allows anonymous access and the user is not signed in.
                RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle, SlkFrameset.FRM_SignInRequiredMsgHtml, false);
            }
            catch (HttpException ex)
            {
                // Do not set response codes

                SlkStore.LogException(ex);
                RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle, SlkFrameset.FRM_AssignmentNotAvailableMsgHtml, false);
            }
            catch (Exception ex)
            {
                Response.StatusCode        = 500;
                Response.StatusDescription = "Internal Server Error";

                SlkStore.LogException(ex);
                RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle, SlkFrameset.FRM_AssignmentNotAvailableMsgHtml, false);
            }
        }
 /// <summary>
 /// Loads the grading list control
 /// </summary>
 private void LoadGradingList()
 {
     try
     {
         gradingList.AssignmentProperties = AssignmentProperties;
         gradingList.Initialize(SlkStore.Settings);
     }
     catch (InvalidOperationException exception)
     {
         SlkStore.LogException(exception);
         throw new SafeToDisplayException(PageCulture.Resources.GradingInvalidAssignmentId, AssignmentId);
     }
 }
Exemple #5
0
        private void HandleNonELearningAssignment()
        {
            if (LearnerAssignmentProperties.Status == LearnerAssignmentState.NotStarted)
            {
                if (AssignmentProperties.IsNoPackageAssignment)
                {
                    startAssignment = true;
                }
                else
                {
                    try
                    {
                        CopyDocumentToDropBox();
                    }
                    catch (SPException)
                    {
                        // Sometimes fails first time
                        try
                        {
                            CopyDocumentToDropBox();
                        }
                        catch (SPException exception)
                        {
                            SlkStore.LogException(exception);
                        }
                    }

                    if (assignmentFile != null && assignmentFile.IsOwaCompatible && SlkStore.Settings.DropBoxSettings.UseOfficeWebApps)
                    {
                        // If using office web apps need to change the status of the assignment as the begin button is just a url rather than a script
                        // which opens the document in another application
                        startAssignment             = true;
                        initialViewForOfficeWebApps = true;
                    }
                }
            }
            else
            {
                if (AssignmentProperties.IsNoPackageAssignment == false)
                {
                    FindDocumentUrl();
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Performs the Query Execution and Execute
        /// </summary>
        /// <param name="queryDef"></param>
        /// <returns>Query Count</returns>
        private int ExecuteQuery(QueryDefinition queryDef)
        {
            try
            {
                // create a job for executing the queries specified by <querySetDef>
                LearningStoreJob job = SlkStore.LearningStore.CreateJob();

                PerformQuery(queryDef, job);

                // execute the job
                DataTable queryResults = job.Execute <DataTable>();
                return(queryResults != null ? queryResults.Rows.Count : -1);
            }
            catch (SqlException ex)
            {
                SlkStore.LogException(ex);
                return(-1);
            }
        }
Exemple #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string querySetName = Request[QueryStringKeys.QuerySet];

                // Only return anything if a query is passed.
                if (string.IsNullOrEmpty(querySetName) == false)
                {
                    // create a job for executing the queries specified by <querySetDef>
                    LearningStoreJob job = SlkStore.LearningStore.CreateJob();

                    // set <querySetDef> to the QuerySetDefinition named <querySetName>
                    QuerySetDefinition querySetDef = SlkStore.Settings.FindQuerySetDefinition(querySetName, true);

                    if (querySetDef == null)
                    {
                        throw new SafeToDisplayException(PageCulture.Resources.AlwpQuerySetNotFound, querySetName);
                    }

                    // create queries corresponding to <querySetDef> and add them to <job>;
                    // set <numberOfQueries> to the number of queries in the query set
                    int numberOfQueries = 0;
                    foreach (QueryDefinition queryDef in querySetDef.Queries)
                    {
                        PerformQuery(queryDef, job);
                        numberOfQueries++;
                    }

                    // execute the job
                    ReadOnlyCollection <object> results = null;
                    try
                    {
                        // execute the job
                        results = job.Execute();
                    }
                    catch (SqlException sqlEx)
                    {
                        //check whether deadlock occured and throw the exception back
                        if (sqlEx.Number == 1205)
                        {
                            throw;
                        }

                        // don't need SlkStore.LogException(ex) because we'll write to the event log again
                        // in RenderQueryCounts
                        results = null;
                    }
                    finally
                    {
                        RenderQueryCounts(querySetDef, numberOfQueries, results);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
                try
                {
                    SlkStore.LogException(ex);
                }
                catch (Exception exe)
                {
                    Response.Write(exe.ToString());
                }
            }
        }
Exemple #8
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            try
            {
                // setting default title
                pageTitle.Text            = PageCulture.Resources.LobbyBeginAssignmentText;
                pageTitleInTitlePage.Text = PageCulture.Resources.LobbyBeginAssignmentText;

                SetResourceText();

                LearnerAssignmentState learnerAssignmentStatus = LearnerAssignmentProperties.Status.Value;
                startAssignment = (Request.QueryString[startQueryStringName] == "true");

                if (AssignmentProperties.IsNonELearning)
                {
                    HandleNonELearningAssignment();
                }

                if (startAssignment && learnerAssignmentStatus == LearnerAssignmentState.NotStarted)
                {
                    LearnerAssignmentProperties.Start();
                    learnerAssignmentStatus = LearnerAssignmentProperties.Status.Value;
                }

                ClientScript.RegisterClientScriptBlock(this.GetType(), "lblStatusValue", "var lblStatusValue = \"" + lblStatusValue.ClientID + "\";", true);

                StringBuilder clientScript        = new StringBuilder();
                string        submittedJavascript = string.Format("slkSubmittedUrl = '{0}{1}SubmittedFiles.aspx?LearnerAssignmentId=';", SPWeb.Url, Constants.SlkUrlPath);
                clientScript.AppendLine(submittedJavascript);

                string sourceUrl = string.Format("slkSourceUrl = '&source={0}';", HttpUtility.UrlEncode(Page.Request.RawUrl));
                clientScript.AppendLine(sourceUrl);

                ClientScript.RegisterClientScriptBlock(this.GetType(), "openSubmittedFiles", clientScript.ToString(), true);

                if (learnerAssignmentStatus == LearnerAssignmentState.Completed && AssignmentProperties.AutoReturn == true)
                {
                    // assignment was probably changed to be "auto-return" after this learner submitted it; we'll
                    // re-submit now to invoke the auto-return mechanism; note that we use
                    // LearnerAssignmentState.Completed instead of LearnerAssignmentState.Final because
                    // the latter would throw a security-related exception (learner's aren't allowed to move their
                    // learner assignments into Final state) -- using Completed works because
                    // SlkStore.ChangeLearnerAssignmentState performs auto-return even if the current state is
                    // LearnerAssignmentState.Completed
                    LearnerAssignmentProperties.Submit();
                    // Set the property to null so that it will refresh the next time it is referenced
                    LearnerAssignmentProperties = null;
                }

                SetUpDisplayValues(learnerAssignmentStatus);
                SetUpForAssignmentState(learnerAssignmentStatus);

                tgrAutoReturn.Visible = AssignmentProperties.AutoReturn;
                contentPanel.Visible  = true;
            }
            catch (InvalidOperationException ex)
            {
                SlkStore.LogException(ex);
                errorBanner.AddException(SlkStore, new SafeToDisplayException(PageCulture.Resources.LobbyInvalidLearnerAssignmentId, LearnerAssignmentGuidId.ToString()));
                contentPanel.Visible = false;
            }
            catch (ThreadAbortException)
            {
                // Calling Response.Redirect throws a ThreadAbortException which needs to be rethrown
                throw;
            }
            catch (Exception exception)
            {
                errorBanner.AddException(SlkStore, exception);
                contentPanel.Visible = false;
            }
        }