コード例 #1
0
        void CompleteAssignment(StoredLearningSession newSession, AssignmentSaver saver)
        {
            LearnerAssignmentState newStatus = LearnerAssignmentState.Completed;
            bool?isFinal = false;

            if (Assignment.AutoReturn)
            {
                newStatus = LearnerAssignmentState.Final;
                isFinal   = true;
            }


            if (newSession == null)
            {
                float?finalPoints = null;
                if (Status == LearnerAssignmentState.Active && Assignment.IsELearning)
                {
                    finalPoints = FinishSession();
                }

                Save(newStatus, isFinal, NonELearningStatus(AttemptStatus.Completed), finalPoints, saver);
            }
            else
            {
                Save(newStatus, isFinal, NonELearningStatus(AttemptStatus.Completed), newSession.TotalPoints, saver);
            }

            Status = newStatus;
        }
コード例 #2
0
        private void SetUpDisplayValues(LearnerAssignmentState learnerAssignmentStatus)
        {
            lblTitle.Text       = Server.HtmlEncode(AssignmentProperties.Title);
            lblDescription.Text = SlkUtilities.ClickifyLinks(SlkUtilities.GetCrlfHtmlEncodedText(AssignmentProperties.Description));

            SetUpAssignmentSiteLink();
            SetUpScoreAndGradeDisplayValues(learnerAssignmentStatus);

            SPTimeZone timeZone = SPWeb.RegionalSettings.TimeZone;

            lblStartValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.StartDate));
            if (AssignmentProperties.DueDate.HasValue)
            {
                lblDueValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.DueDate.Value));
            }

            if (LearnerAssignmentProperties.InstructorComments.Length != 0)
            {
                lblCommentsValue.Text = SlkUtilities.GetCrlfHtmlEncodedText(LearnerAssignmentProperties.InstructorComments);
            }
            else
            {
                tgrComments.Visible = false;
            }

            lblStatusValue.Text = Server.HtmlEncode(SlkUtilities.GetLearnerAssignmentState(learnerAssignmentStatus));

            DisplayCustomProperties();
            DisplayMixes();
        }
コード例 #3
0
        Exception InvalidTransitionException(LearnerAssignmentState oldStatus, LearnerAssignmentState newStatus)
        {
            SlkCulture culture = new SlkCulture();
            string     message = culture.Format(culture.Resources.LearnerAssignmentTransitionNotSupported, oldStatus, newStatus);

            return(new InvalidOperationException(message));
        }
コード例 #4
0
        /// <summary>Process a request for a view. If not allowed, register an error and return false.</summary>
        public bool ProcessViewRequest(SessionView view, LearningSession session)
        {
            LearnerAssignmentProperties la = GetLearnerAssignment();

            LearnerAssignmentState state = la.Status == null ? LearnerAssignmentState.NotStarted : la.Status.Value;

            return(ProcessViewRequest(state, view));
        }
コード例 #5
0
        /// <summary>Set the score and grade display values.</summary>
        private void SetUpScoreAndGradeDisplayValues(LearnerAssignmentState learnerAssignmentStatus)
        {
            if (AssignmentProperties.HidePoints)
            {
                RowScore.Visible = false;
            }
            else
            {
                if (LearnerAssignmentProperties.SuccessStatus == SuccessStatus.Passed &&
                    LearnerAssignmentProperties.FinalPoints.HasValue &&
                    LearnerAssignmentProperties.FinalPoints.Value == 0.0
                    )
                {
                    lblScoreValue.Text = string.Empty;
                }
                else
                {
                    if (learnerAssignmentStatus != LearnerAssignmentState.Final)
                    {
                        if (AssignmentProperties.PointsPossible.HasValue)
                        {
                            lblScoreValue.Text = PageCulture.Format(PageCulture.Resources.LobbyPointsNoValuePointsPossible, AssignmentProperties.PointsPossible);
                        }
                        else
                        {
                            lblScoreValue.Text = PageCulture.Format(PageCulture.Resources.LobbyPointsNoValue, LearnerAssignmentProperties.FinalPoints);
                        }
                    }
                    else
                    {
                        string finalPoints = PageCulture.Resources.LobbyPointsNoValue;
                        if (LearnerAssignmentProperties.FinalPoints.HasValue)
                        {
                            finalPoints = LearnerAssignmentProperties.FinalPoints.Value.ToString(CultureInfo.CurrentCulture);
                        }

                        if (AssignmentProperties.PointsPossible.HasValue)
                        {
                            lblScoreValue.Text = PageCulture.Format(PageCulture.Resources.LobbyPointsValuePointsPossible, finalPoints, AssignmentProperties.PointsPossible);
                        }
                        else
                        {
                            lblScoreValue.Text = PageCulture.Format(PageCulture.Resources.LobbyPointsValue, finalPoints);
                        }
                    }
                }
            }

            if (SlkStore.Settings.UseGrades)
            {
                labelGradeValue.Text = LearnerAssignmentProperties.Grade;
            }
            else
            {
                RowGrade.Visible = false;
            }
        }
コード例 #6
0
        /// <summary>Returns the assignment.</summary>
        public void Return(AssignmentSaver saver)
        {
            CheckUserIsInstructor();

            StoredLearningSession session = null;

            // Check the status
            switch (Status)
            {
            case LearnerAssignmentState.NotStarted:
                // Force collection & return
                session = CreateAttemptIfRequired(false);
                break;

            case LearnerAssignmentState.Active:
                // Force collection & return
                break;

            case LearnerAssignmentState.Completed:
                break;

            case LearnerAssignmentState.Final:
                // No need to return
                return;

            default:
                // New status added
                break;
            }

            LearnerAssignmentState newStatus = LearnerAssignmentState.Final;

            if (session == null)
            {
                Save(newStatus, true, NonELearningStatus(AttemptStatus.Completed), null, saver);
            }
            else
            {
                Save(newStatus, true, NonELearningStatus(AttemptStatus.Completed), session.TotalPoints, saver);
            }

            Status = newStatus;

            if (Assignment.EmailChanges)
            {
                saver.SendReturnEmail(User, this);
            }

            if (Assignment.IsNonELearning)
            {
                saver.UpdateDropBoxPermissions(newStatus, User);
            }
        }
コード例 #7
0
 /// <summary>Updates the drop box permissions.</summary>
 /// <param name="state">The state the assignment is moving to.</param>
 /// <param name="user">The SLK user.</param>
 public void UpdateDropBoxPermissions(LearnerAssignmentState state, SlkUser user)
 {
     if (properties.IsNonELearning)
     {
         if (store != null)
         {
             cachedDropBoxUpdates.Add(new DropBoxUpdate(state, user.SPUser));
         }
         else
         {
             UpdateDropBoxPermissionsNow(state, user.SPUser);
         }
     }
 }
コード例 #8
0
ファイル: Data.cs プロジェクト: rpwillis/mlg
        private string GetAssignmentStatus(LearnerAssignmentState assignmentState)
        {
            switch (assignmentState)
            {
            case LearnerAssignmentState.Active:
                return("Active");

            case LearnerAssignmentState.Completed:
                return("Completed");

            case LearnerAssignmentState.Final:
                return("Final");

            case LearnerAssignmentState.NotStarted:
                return("Not Started");
            }
            return("Not determined");
        }
コード例 #9
0
        void Save(LearnerAssignmentState newStatus, bool?isFinal, AttemptStatus?nonELearningStatus, float?finalPoints, AssignmentSaver saver)
        {
            if (fullSave)
            {
                if (saver == null)
                {
                    throw new ArgumentNullException("saver");
                }

                bool  ignoreFinalPoints = finalPoints != null ? false : IgnoreFinalPoints;
                float?pointsToSend      = IgnoreFinalPoints == false ? FinalPoints : finalPoints;
                Assignment.Store.SaveLearnerAssignment(LearnerAssignmentId, ignoreFinalPoints, pointsToSend, InstructorComments, Grade, isFinal, nonELearningStatus, saver.CurrentJob);
            }
            else
            {
                bool saveFinalPoints = (finalPoints != null || newStatus == LearnerAssignmentState.Active);
                Assignment.Store.ChangeLearnerAssignmentState(LearnerAssignmentId, isFinal, nonELearningStatus, saveFinalPoints, finalPoints);
            }
        }
コード例 #10
0
        /// <summary>reactivates the assignment.</summary>
        public void Reactivate(AssignmentSaver saver)
        {
            CheckUserIsInstructor();

            // Check the status
            switch (Status)
            {
            case LearnerAssignmentState.NotStarted:
                throw InvalidTransitionException(LearnerAssignmentState.NotStarted, LearnerAssignmentState.Active);

            case LearnerAssignmentState.Active:
                return;     // Already active

            case LearnerAssignmentState.Completed:
                break;

            case LearnerAssignmentState.Final:
                break;

            default:
                // New status added
                break;
            }

            LearnerAssignmentState newStatus = LearnerAssignmentState.Active;

            if (Assignment.IsELearning)
            {
                ReactivateSession();
            }
            else
            {
                saver.UpdateDropBoxPermissions(newStatus, User);
            }

            Save(newStatus, false, NonELearningStatus(AttemptStatus.Active), null, saver);
            Status = newStatus;

            if (Assignment.EmailChanges)
            {
                saver.SendReactivateEmail(User);
            }
        }
コード例 #11
0
        /// <summary>Starts the assignment.</summary>
        public void Start()
        {
            CheckUserIsLearner();

            // Check the status
            switch (Status)
            {
            case LearnerAssignmentState.NotStarted:
                break;

            case LearnerAssignmentState.Active:
                return;

            case LearnerAssignmentState.Completed:
                throw InvalidTransitionException(LearnerAssignmentState.Completed, LearnerAssignmentState.Active);

            case LearnerAssignmentState.Final:
                throw InvalidTransitionException(LearnerAssignmentState.Final, LearnerAssignmentState.Active);

            default:
                // New status added
                break;
            }

            StoredLearningSession session = CreateAttemptIfRequired(false);

            LearnerAssignmentState newStatus = LearnerAssignmentState.Active;

            if (session == null)
            {
                Save(newStatus, null, NonELearningStatus(AttemptStatus.Active), null, null);
            }
            else
            {
                Save(newStatus, null, NonELearningStatus(AttemptStatus.Active), null, null);
            }

            Status = newStatus;
        }
コード例 #12
0
        private void SetUpForAssignmentState(LearnerAssignmentState learnerAssignmentStatus)
        {
            AssignmentView view = AssignmentView.Execute;

            switch (learnerAssignmentStatus)
            {
            case LearnerAssignmentState.NotStarted:
                SetUpForNotStarted();
                break;

            case LearnerAssignmentState.Active:
                if (initialViewForOfficeWebApps)
                {
                    SetUpForNotStarted();
                }
                else
                {
                    SetUpForActive();
                }
                break;

            case LearnerAssignmentState.Completed:
                SetUpForCompleted();
                break;

            case LearnerAssignmentState.Final:
                SetUpForFinal();
                view = AssignmentView.StudentReview;
                break;

            default:
                break;
            }

            SetUpButtons(view);
        }
コード例 #13
0
        /// <summary>Updates the drop box permissions.</summary>
        /// <param name="state">The state the assignment is moving to.</param>
        /// <param name="user">The user.</param>
        void UpdateDropBoxPermissionsNow(LearnerAssignmentState state, SPUser user)
        {
            // If user is null, it's a deleted user so no need to update.
            if (user != null)
            {
                bool createdManager = false;
                if (dropBoxManager == null)
                {
                    dropBoxManager = new DropBoxManager(properties);
                    createdManager = true;
                }

                switch (state)
                {
                case LearnerAssignmentState.Active:
                    // Reactivated
                    dropBoxManager.ApplyReactivateAssignmentPermission(user);
                    break;

                case LearnerAssignmentState.Completed:
                    // Collected
                    dropBoxManager.ApplyCollectAssignmentPermissions(user);
                    break;

                case LearnerAssignmentState.Final:
                    // Return
                    dropBoxManager.ApplyReturnAssignmentPermission(user);
                    break;
                }

                if (createdManager)
                {
                    dropBoxManager = null;
                }
            }
        }
コード例 #14
0
 public DropBoxUpdate(LearnerAssignmentState state, SPUser user)
 {
     State = state;
     User  = user;
 }
コード例 #15
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;
            }
        }
コード例 #16
0
        public RenderedCell[] RenderQueryRowCells(DataRow dataRow, int[,] columnMap, SPWebResolver spWebResolver, SPTimeZone timeZone)
        {
            if (dataRow == null)
            {
                throw new ArgumentNullException("dataRow");
            }
            if (columnMap == null)
            {
                throw new ArgumentNullException("columnMap");
            }

            RenderedCell[] renderedCells     = new RenderedCell[m_columnDefinitions.Count];
            int            iColumnDefinition = 0;

            foreach (ColumnDefinition columnDefinition in m_columnDefinitions)
            {
                // set <cellValue> to the rendered value to be displayed in this cell (i.e. this
                // column of this row); set <cellSortKey> to the cell's sort key value (i.e. the value
                // to use for sorting); set <cellId> to the LearningStoreItemIdentifier associated
                // with this cell (null if none); set <cellToolTip> to the tooltip associated with
                // this cell (null if none)
                object cellValue, cellSortKey;
                LearningStoreItemIdentifier cellId;
                string cellToolTip;
                string text, textNotRounded;
                Guid?  cellSiteGuid = null, cellWebGuid = null;
                string cellWebUrl   = null;
                bool   renderAsLink = false;
                switch (columnDefinition.RenderAs)
                {
                case ColumnRenderAs.Default:

                    cellValue = dataRow[columnMap[iColumnDefinition, 0]];
                    if (cellValue is DBNull)
                    {
                        cellValue   = (columnDefinition.NullDisplayString ?? String.Empty);
                        cellSortKey = String.Empty;
                        cellId      = null;
                        cellToolTip = null;
                    }
                    else
                    {
                        if ((cellId = cellValue as LearningStoreItemIdentifier) != null)
                        {
                            cellValue = cellSortKey = cellId.GetKey();
                        }
                        else
                        {
                            cellSortKey = cellValue;
                        }
                        if (columnDefinition.ToolTipFormat != null)
                        {
                            cellToolTip = culture.Format(columnDefinition.ToolTipFormat, cellValue);
                        }
                        else
                        {
                            cellToolTip = null;
                        }
                        if (columnDefinition.CellFormat != null)
                        {
                            text        = FormatValue(cellValue, columnDefinition.CellFormat);
                            cellValue   = text;
                            cellSortKey = text.ToLower(culture.Culture);
                        }
                    }
                    break;

                case ColumnRenderAs.UtcAsLocalDateTime:

                    cellValue = dataRow[columnMap[iColumnDefinition, 0]];
                    if (cellValue is DBNull)
                    {
                        cellValue   = (columnDefinition.NullDisplayString ?? String.Empty);
                        cellSortKey = String.Empty;
                        cellId      = null;
                        cellToolTip = null;
                    }
                    else
                    {
                        DateTime dateTime;
                        try
                        {
                            dateTime = timeZone.UTCToLocalTime((DateTime)cellValue);
                        }
                        catch (InvalidCastException)
                        {
                            throw new SlkSettingsException(columnDefinition.LineNumber, culture.Resources.SlkUtilitiesViewColumnNameNonDateTime);
                        }
                        cellValue = cellSortKey = dateTime;
                        if (columnDefinition.CellFormat != null)
                        {
                            cellValue = FormatValue(dateTime, columnDefinition.CellFormat);
                        }
                        cellId = null;
                        if (columnDefinition.ToolTipFormat != null)
                        {
                            cellToolTip = culture.Format(columnDefinition.ToolTipFormat, dateTime);
                        }
                        else
                        {
                            cellToolTip = null;
                        }
                    }
                    break;

                case ColumnRenderAs.SPWebTitle:
                case ColumnRenderAs.SPWebName:

                    renderAsLink = (columnDefinition.RenderAs == ColumnRenderAs.SPWebName);
                    cellWebGuid  = GetQueryCell <Guid>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0);
                    cellSiteGuid = GetQueryCell <Guid>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1);
                    if (spWebResolver != null)
                    {
                        spWebResolver(cellWebGuid.Value, cellSiteGuid.Value, out text, out cellWebUrl);
                    }
                    else
                    {
                        text = null;
                    }

                    if (text == null)
                    {
                        text = cellWebGuid.Value.ToString();
                    }

                    cellValue   = text;
                    cellSortKey = text.ToLower(culture.Culture);
                    cellId      = null;
                    if (columnDefinition.ToolTipFormat != null)
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, text);
                    }
                    else
                    {
                        cellToolTip = null;
                    }

                    break;

                case ColumnRenderAs.Link:

                    text        = GetQueryCell <string>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0);
                    cellId      = GetQueryCell <LearningStoreItemIdentifier>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1);
                    cellValue   = text;
                    cellSortKey = text.ToLower(culture.Culture);
                    if (columnDefinition.ToolTipFormat != null)
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, text);
                    }
                    else
                    {
                        cellToolTip = null;
                    }
                    break;

                case ColumnRenderAs.LearnerAssignmentStatus:

                    bool unused;
                    LearnerAssignmentState learnerAssignmentState =
                        (LearnerAssignmentState)GetQueryCell <int>(dataRow, columnMap,
                                                                   columnDefinition, iColumnDefinition, 0, out unused);
                    text        = SlkUtilities.GetLearnerAssignmentState(learnerAssignmentState);
                    cellValue   = text;
                    cellSortKey = learnerAssignmentState;
                    cellId      = null;
                    if (columnDefinition.ToolTipFormat != null)
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, text);
                    }
                    else
                    {
                        cellToolTip = null;
                    }
                    break;

                case ColumnRenderAs.IfEmpty:
                    cellToolTip = null;
                    bool   noColumn1;
                    object column1 = GetQueryCell <object>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0, out noColumn1);
                    bool   noColumn2;
                    object column2 = GetQueryCell <object>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1, out noColumn2);

                    if (noColumn1 == false)
                    {
                        cellValue = column1;
                        if (noColumn2 == false)
                        {
                            if (columnDefinition.ToolTipFormat != null)
                            {
                                cellToolTip = culture.Format("{0} ({1})", cellValue, column2);
                            }
                        }
                    }
                    else if (noColumn2)
                    {
                        cellValue = culture.Resources.SlkUtilitiesPointsNoValue;
                    }
                    else
                    {
                        cellValue = column2;
                    }

                    cellId      = null;
                    cellSortKey = cellValue.ToString().ToLower(culture.Culture);
                    if (string.IsNullOrEmpty(cellToolTip))
                    {
                        cellToolTip = cellValue.ToString();
                    }

                    break;

                case ColumnRenderAs.ScoreAndPossible:

                    // get <finalPoints> and <pointsPossible> from <dataRow>
                    bool  noFinalPoints;
                    float finalPoints = GetQueryCell <float>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0, out noFinalPoints);
                    bool  noPointsPossible;
                    float pointsPossible = GetQueryCell <float>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1, out noPointsPossible);

                    // round to two decimal places
                    float finalPointsRounded    = (float)Math.Round(finalPoints, 2);
                    float pointsPossibleRounded = (float)Math.Round(pointsPossible, 2);

                    // format the result
                    if (!noFinalPoints)
                    {
                        // FinalPoints is not NULL
                        text           = culture.Format(culture.Resources.SlkUtilitiesPointsValue, FormatValue(finalPointsRounded, columnDefinition.CellFormat));
                        textNotRounded = culture.Format(culture.Resources.SlkUtilitiesPointsValue, finalPoints);
                    }
                    else
                    {
                        // FinalPoints is NULL
                        text           = culture.Resources.SlkUtilitiesPointsNoValue;
                        textNotRounded = culture.Resources.SlkUtilitiesPointsNoValue;
                    }
                    if (!noPointsPossible)
                    {
                        // PointsPossible is not NULL
                        text = culture.Format(culture.Resources.SlkUtilitiesPointsPossible, text,
                                              FormatValue(pointsPossibleRounded, columnDefinition.CellFormat));
                        textNotRounded = culture.Format(culture.Resources.SlkUtilitiesPointsPossible, textNotRounded,
                                                        pointsPossible);
                    }
                    cellValue = text;
                    cellId    = null;
                    if ((columnDefinition.ToolTipFormat != null) &&
                        (!noFinalPoints || !noPointsPossible))
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, textNotRounded);
                    }
                    else
                    {
                        cellToolTip = null;
                    }

                    // set <cellSortKey>
                    if (!noFinalPoints)
                    {
                        if (!noPointsPossible)
                        {
                            cellSortKey = ((double)finalPoints) / pointsPossible;
                        }
                        else
                        {
                            cellSortKey = (double)finalPoints;
                        }
                    }
                    else
                    {
                        cellSortKey = (double)0;
                    }
                    break;

                case ColumnRenderAs.Submitted:

                    int countCompletedOrFinal = GetQueryCell <int>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0);
                    int countTotal            = GetQueryCell <int>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1);
                    text        = culture.Format(culture.Resources.SlkUtilitiesSubmitted, countCompletedOrFinal, countTotal);
                    cellValue   = text;
                    cellId      = null;
                    cellToolTip = null;
                    cellSortKey = countCompletedOrFinal;
                    break;

                default:

                    throw new SlkSettingsException(columnDefinition.LineNumber, culture.Resources.SlkUtilitiesUnknownRenderAsValue, columnDefinition.RenderAs);
                }

                // add to <renderedCells>
                RenderedCell renderedCell;
                if (cellSiteGuid != null)
                {
                    renderedCell = new WebNameRenderedCell(cellValue, cellSortKey, cellId, cellToolTip, columnDefinition.Wrap, cellSiteGuid.Value, cellWebGuid.Value, cellWebUrl);
                    ((WebNameRenderedCell)renderedCell).RenderAsLink = renderAsLink;
                }
                else
                {
                    renderedCell = new RenderedCell(cellValue, cellSortKey, cellId, cellToolTip, columnDefinition.Wrap);
                }
                renderedCells[iColumnDefinition++] = renderedCell;
            }

            return(renderedCells);
        }
コード例 #17
0
        /// <summary>Process a view request to determine if it's valid. The AssignmentView must be set before calling this method.</summary>
        protected bool ProcessViewRequest(LearnerAssignmentState learnerStatus, SessionView sessionView)
        {
            switch (AssignmentView)
            {
            case AssignmentView.Execute:
            {
                // Verify that session view matches what you expect
                if (sessionView != SessionView.Execute)
                {
                    throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml);
                }

                // Can only access active assignments in Execute view
                if (learnerStatus != LearnerAssignmentState.Active)
                {
                    RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle,
                                  SlkFrameset.FRM_AssignmentTurnedInMsgHtml, false);

                    return(false);
                }
                break;
            }

            case AssignmentView.Grading:
            {
                // Verify that session view matches what you expect
                if (sessionView != SessionView.Review)
                {
                    throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml);
                }

                // Grading is not available if the assignment has not been submitted.
                if ((learnerStatus == LearnerAssignmentState.Active) ||
                    (learnerStatus == LearnerAssignmentState.NotStarted))
                {
                    RegisterError(SlkFrameset.FRM_AssignmentNotGradableTitle,
                                  SlkFrameset.FRM_AssignmentCantBeGradedMsgHtml, false);
                    return(false);
                }
                break;
            }

            case AssignmentView.InstructorReview:
            {
                // Verify that session view matches what you expect
                if (sessionView != SessionView.Review)
                {
                    throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml);
                }

                // Only available if student has started the assignment
                if (learnerStatus == LearnerAssignmentState.NotStarted)
                {
                    RegisterError(SlkFrameset.FRM_ReviewNotAvailableTitle,
                                  SlkFrameset.FRM_ReviewNotAvailableMsgHtml, false);
                    return(false);
                }

                break;
            }

            case AssignmentView.StudentReview:
            {
                // Verify that session view matches what you expect
                if (sessionView != SessionView.Review)
                {
                    throw new InvalidOperationException(SlkFrameset.FRM_UnexpectedViewRequestHtml);
                }

                // If the user is an observer and the assignment state is equal to 'Completed' or 'NotStarted',
                // then register error message
                if (SlkStore.IsObserver(SPWeb) && ((learnerStatus == LearnerAssignmentState.Completed) || (learnerStatus == LearnerAssignmentState.NotStarted)))
                {
                    RegisterError(SlkFrameset.FRM_ObserverReviewNotAvailableTitle, SlkFrameset.FRM_ObserverReviewNotAvailableMsgHtml, false);
                    return(false);
                }
                // If requesting student review, the assignment state must be final
                if (!SlkStore.IsObserver(SPWeb) && learnerStatus != LearnerAssignmentState.Final)
                {
                    RegisterError(SlkFrameset.FRM_ReviewNotAvailableTitle,
                                  SlkFrameset.FRM_LearnerReviewNotAvailableMsgHtml, false);
                    return(false);
                }

                break;
            }

            default:
                break;
            }
            return(true);
        }