Пример #1
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.Controller is OSBLEController)
            {
                OSBLEController controller = filterContext.Controller as OSBLEController;

                //AC: Will fail when session clears
                try
                {
                    if (controller.ActiveCourseUser.AbstractCourse is Community)
                    {
                        filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index", area = "" }));
                    }
                }
                catch (Exception ex)
                {
                    OSBLEContext db  = new OSBLEContext();
                    ActivityLog  log = new ActivityLog()
                    {
                        Sender  = typeof(NotForCommunity).ToString(),
                        Message = "IP " + filterContext.HttpContext.Request.UserHostAddress + " encountered exception: " + ex.ToString()
                    };
                    //AC: turned off to save space / improve performance

                    /*
                     * db.ActivityLogs.Add(log);
                     * db.SaveChanges();
                     * */
                }
            }
        }
Пример #2
0
        public override DynamicDictionary BuildTableForTeam(IAssignmentTeam assignmentTeam)
        {
            dynamic data = Builder.BuildTableForTeam(assignmentTeam);

            data.studentRubricsReceived = new DynamicDictionary();
            List <bool> hasRubricList = new List <bool>();
            List <int>  authorTeamIds = new List <int>();

            foreach (TeamMember tm in assignmentTeam.Team.TeamMembers)
            {
                AssignmentTeam previousTeam = OSBLEController.GetAssignmentTeam(assignmentTeam.Assignment.PreceedingAssignment,
                                                                                tm.CourseUser);
                authorTeamIds.Add(previousTeam.TeamID);

                using (OSBLEContext db = new OSBLEContext())
                {
                    hasRubricList.Add((from e in db.RubricEvaluations
                                       where e.AssignmentID == assignmentTeam.AssignmentID &&
                                       e.RecipientID == previousTeam.TeamID &&
                                       e.Evaluator.AbstractRoleID == (int)CourseRole.CourseRoles.Student &&
                                       e.IsPublished
                                       select e.ID).Count() > 0);
                }
            }

            data.studentRubricsReceived.assignmentID = assignmentTeam.AssignmentID;

            data.studentRubricsReceived.hasRubricList = hasRubricList;
            data.studentRubricsReceived.authorTeamIDs = authorTeamIds;

            return(data);
        }
        public override DynamicDictionary BuildTableForTeam(IAssignmentTeam assignmentTeam)
        {
            dynamic data = Builder.BuildTableForTeam(assignmentTeam);

            data.TeacherReceivedCritical             = new DynamicDictionary();
            data.TeacherReceivedCritical.ReviewTeams = ReviewTeams;

            AssignmentTeam assignTeam         = assignmentTeam as AssignmentTeam;
            Assignment     assignment         = assignTeam.Assignment;
            Assignment     previousAssignment = assignment.PreceedingAssignment;

            List <CourseUser> CourseUsersInReviewTeam = (from tm in assignTeam.Team.TeamMembers
                                                         orderby tm.CourseUser.UserProfile.LastName, tm.CourseUser.UserProfile.FirstName
                                                         select tm.CourseUser).ToList();
            List <CriticalReviewsReceivedTeam> reviewers = new List <CriticalReviewsReceivedTeam>();

            string           submissionFolder;
            List <DateTime?> timeStamp = new List <DateTime?>();

            foreach (CourseUser cu in CourseUsersInReviewTeam)
            {
                bool           addedTimeStamp         = false;
                AssignmentTeam previousAssignmentTeam = OSBLEController.GetAssignmentTeam(assignment.PreceedingAssignment, cu);
                foreach (AssignmentTeam at in assignment.AssignmentTeams)
                {
                    submissionFolder = FileSystem.GetTeamUserSubmissionFolderForAuthorID(false, assignment.Course, assignment.ID, at, previousAssignmentTeam.Team);
                    DirectoryInfo DI = new DirectoryInfo(submissionFolder);
                    if (DI.Exists)
                    {
                        timeStamp.Add(DI.LastAccessTime);
                        addedTimeStamp = true;
                        data.TeacherReceivedCritical.IsPdfReviewAssignment = false;
                        break;
                    }
                    else if (previousAssignment.HasDeliverables && previousAssignment.Deliverables[0].DeliverableType == DeliverableType.PDF)
                    {
                        //AC Note: I have no clue what is going on here.  I'm inserting this code for Annodate-based PDF assignments.
                        //I'm not sure if it makes the most sense for it to go here, but it works, so...
                        data.TeacherReceivedCritical.IsPdfReviewAssignment = true;
                        reviewers = reviewers.Union(ReviewTeams.Where(rt => rt.CourseUser.ID == cu.ID)).ToList();

                        //AC: stuff that was here before
                        timeStamp.Add(DateTime.UtcNow);
                        addedTimeStamp = true;
                        break;
                    }
                }
                if (addedTimeStamp == false)
                {
                    timeStamp.Add(null);
                }
            }

            data.TeacherReceivedCritical.Reviewers     = reviewers;
            data.TeacherReceivedCritical.TimeStampList = timeStamp;
            data.TeacherReceivedCritical.CourseUsers   = CourseUsersInReviewTeam;
            data.TeacherReceivedCritical.Assignment    = assignment;
            return(data);
        }
Пример #4
0
        public override DynamicDictionary BuildTableForTeam(IAssignmentTeam assignmentTeam)
        {
            //discussionTeam is a put together DiscussionTeam that has a new non-db saved team for its team
            //This new team has only 1 team members (the individual we want to create a row for).
            //but, the TeamID is the real team ID used in the database. This is done in DiscussionAssignmentIndex.cshtml
            dynamic data = Builder.BuildTableForTeam(assignmentTeam);

            data.LatePenaltyPercent = OSBLEController.GetLatePenaltyAsString(assignmentTeam);
            return(data);
        }
Пример #5
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.Controller is OSBLEController)
            {
                OSBLEController controller = filterContext.Controller as OSBLEController;

                if (!controller.ActiveCourseUser.AbstractRole.CanSeeAll)
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index", area = "" }));
                }
            }
        }
Пример #6
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.Controller is OSBLEController)
            {
                OSBLEController controller = filterContext.Controller as OSBLEController;

                if ((controller.CurrentUser == null) || (!controller.CurrentUser.CanCreateCourses))
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index", area = "" }));
                }
            }
        }
Пример #7
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.Controller is OSBLEController)
            {
                OSBLEController controller = filterContext.Controller as OSBLEController;

                CourseUser cu = controller.ActiveCourseUser;

                // Course allows Instructors to post events, community allows Leaders to post events.
                if (!(cu.AbstractRole.CanModify || cu.AbstractCourse.AllowEventPosting))
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index", area = "" }));
                }
            }
        }
Пример #8
0
        public override DynamicDictionary BuildHeader(Assignment assignment)
        {
            dynamic header = Builder.BuildHeader(assignment);

            header.AssignmentDetails = new DynamicDictionary();


            RubricEvaluation rubricEvaluation = null;


            //Getting the assignment team for Student, and if its non-null then we take that team ID and find the RubricEvaluation
            //that they were the recipient of.
            AssignmentTeam at     = OSBLEController.GetAssignmentTeam(assignment, Student);
            int            teamId = 0;

            if (at != null)
            {
                teamId = at.TeamID;

                using (OSBLEContext db = new OSBLEContext())
                {
                    //Only want to look at evaluations where Evaluator.AbstractRole.CanGrade is true, otherwise
                    //the rubric evaluation is a  student rubric (not interested in them here)
                    rubricEvaluation = (from re in db.RubricEvaluations
                                        where re.AssignmentID == assignment.ID &&
                                        re.Evaluator.AbstractRole.CanGrade &&
                                        re.RecipientID == teamId
                                        select re).FirstOrDefault();
                }
            }

            //If the Rubric has been evaluated and is published, calculate the rubric grade % to display to the student
            if (rubricEvaluation != null && rubricEvaluation.IsPublished)
            {
                header.AssignmentDetails.hasGrade     = true;
                header.AssignmentDetails.assignmentID = assignment.ID;
                header.AssignmentDetails.cuID         = Student.ID;

                header.AssignmentDetails.DisplayValue = "View Graded Rubric " + RubricEvaluation.GetGradeAsPercent(rubricEvaluation.ID);
            }
            else
            {
                header.AssignmentDetails.DisplayValue = "Not Graded";
                header.AssignmentDetails.hasGrade     = false;
            }
            return(header);
        }
        public override DynamicDictionary BuildHeader(Assignment assignment)
        {
            dynamic header = Builder.BuildHeader(assignment);

            header.Assignment = assignment;
            header.CRdownload = new DynamicDictionary();

            header.CRdownload.hasPublished    = assignment.IsCriticalReviewPublished;
            header.CRdownload.publishedDate   = assignment.CriticalReviewPublishDate;
            header.CRdownload.hasRubricToView = false;

            //get student's team

            AssignmentTeam assignmentTeam = null;

            assignmentTeam                      = OSBLEController.GetAssignmentTeam(assignment.PreceedingAssignment, Student);
            header.CRdownload.teamID            = assignmentTeam.TeamID;
            header.CRdownload.hasRecievedReview = false;

            //PDF reviews don't get sent to the file system (they get sent to annotate)
            //so we can't check the file system for review items.
            //yc: but we can check to see if the file has been submitted into annotate
            //dbo.annotatedocumentreferences has a field osbledocumentcode, and we have the date it was "uploaded"
            //it follows the format:#-#-#-filename.PDF == courseID-PreviousAssignmentid-teamthatisreviewingreviewing-filename.PDF
            //we also have dbo.reviewteams that show if some one has reviewed your assignment
            Assignment previousAssignment = assignment.PreceedingAssignment;
            //yc: locate all reivew teams
            ReviewTeam reviewers          = null;
            bool       foundAnnotateEntry = false;

            using (OSBLEContext db = new OSBLEContext())
            {
                if (assignmentTeam != null)
                {
                    reviewers = (from rte in db.ReviewTeams
                                 where rte.AuthorTeamID == assignmentTeam.TeamID
                                 select rte).FirstOrDefault();
                }

                if (reviewers != null)
                {
                    //if a review team exists, determin if the annoation exisits
                    string lookup = assignment.CourseID.ToString() + "-" + previousAssignment.ID.ToString() + "-" +
                                    assignmentTeam.TeamID.ToString() + "-";
                    AnnotateDocumentReference d = (from adr in db.AnnotateDocumentReferences
                                                   where adr.OsbleDocumentCode.Contains(lookup)
                                                   select adr).FirstOrDefault();
                    if (d != null && (assignment.DueDate < DateTime.Now || assignment.IsCriticalReviewPublished))
                    {
                        foundAnnotateEntry = true;
                    }
                }
            }
            if (foundAnnotateEntry)//(
            //previousAssignment.HasDeliverables
            //&& previousAssignment.Deliverables[0].DeliverableType == DeliverableType.PDF
            //&& previousAssignment.Deliverables.Count == 1
            //)
            {
                header.CRdownload.hasRecievedReview = true;
            }
            else
            {
                if (assignmentTeam != null)
                {
                    //get list of all teams reviewing student
                    List <AssignmentTeam> reviewersOfStudent = (from rt in assignment.ReviewTeams
                                                                join at in assignment.AssignmentTeams
                                                                on rt.ReviewTeamID equals at.TeamID
                                                                where rt.AuthorTeamID == assignmentTeam.TeamID
                                                                select at).ToList();
                    //check each team for a submission
                    foreach (AssignmentTeam at in reviewersOfStudent)
                    {
                        //if(at.GetSubmissionTime() != null)
                        if (FileSystem.GetSubmissionTime(at, assignmentTeam.Team) != null)
                        {
                            header.CRdownload.hasRecievedReview = true;
                            break;
                        }
                    }
                }

                //check if there is at one student rubric that has been filled out for the current user
                if (assignment.HasStudentRubric)
                {
                    using (OSBLEContext db = new OSBLEContext())
                    {
                        header.CRdownload.hasRubricToView = (from e in db.RubricEvaluations
                                                             where e.AssignmentID == assignment.ID &&
                                                             e.RecipientID == assignmentTeam.TeamID &&
                                                             e.Evaluator.AbstractRoleID == (int)CourseRole.CourseRoles.Student &&
                                                             e.DatePublished != null
                                                             select e.ID).Count() > 0;
                    }
                }
            }
            header.CRdownload.student      = Student;
            header.CRdownload.assignmentID = assignment.ID;

            return(header);
        }
Пример #10
0
        public override DynamicDictionary BuildHeader(Assignment assignment)
        {
            dynamic header = Builder.BuildHeader(assignment);

            header.Submission      = new DynamicDictionary();
            header.IsAnnotatable   = new bool();
            header.DeliverableType = assignment.Deliverables.FirstOrDefault().Type;

            DateTime?submissionTime = null;

            //get id of current student's team
            List <TeamMember> allMembers = assignment.AssignmentTeams.SelectMany(at => at.Team.TeamMembers).ToList();
            TeamMember        member     = allMembers.Where(m => m.CourseUserID == Student.ID).FirstOrDefault();

            header.Submission.allowSubmit = true;

            //get submission time:
            foreach (AssignmentTeam team in assignment.AssignmentTeams)
            {
                //if the team matches with the student
                if (team.TeamID == member.TeamID)
                {
                    submissionTime = team.GetSubmissionTime();
                    break;
                }
            }

            if (submissionTime == null)
            {
                header.Submission.hasSubmitted = false;
            }
            else
            {
                header.Submission.hasSubmitted   = true;
                header.Submission.SubmissionTime = submissionTime.Value.ToString();
            }

            header.Submission.assignmentID = assignment.ID;

            FileCache Cache = FileCacheHelper.GetCacheInstance(OsbleAuthentication.CurrentUser);

            //Same functionality as in the other controller.
            //did the user just submit something?  If so, set up view to notify user
            if (Cache["SubmissionReceived"] != null && Convert.ToBoolean(Cache["SubmissionReceived"]) == true)
            {
                header.Submission.SubmissionReceived = true;
                Cache["SubmissionReceived"]          = false;
            }
            else
            {
                header.Submission.SubmissionReceived = false;
                Cache["SubmissionReceived"]          = false;
            }


            //handle link for viewing annotated documents
            RubricEvaluation rubricEvaluation = null;

            //Getting the assignment team for Student, and if its non-null then we take that team ID and find the RubricEvaluation
            //that they were the recipient of.
            AssignmentTeam ateam  = OSBLEController.GetAssignmentTeam(assignment, Student);
            int            teamId = 0;

            if (ateam != null)
            {
                teamId = ateam.TeamID;
                header.Submission.authorTeamID = teamId;

                using (OSBLEContext db = new OSBLEContext())
                {
                    //Only want to look at evaluations where Evaluator.AbstractRole.CanGrade is true, otherwise
                    //the rubric evaluation is a  student rubric (not interested in them here)
                    rubricEvaluation = (from re in db.RubricEvaluations
                                        where re.AssignmentID == assignment.ID &&
                                        re.Evaluator.AbstractRole.CanGrade &&
                                        re.RecipientID == teamId
                                        select re).FirstOrDefault();
                    //if annotatable
                    if (assignment.IsAnnotatable)
                    {
                        //yc: determine if there has been an annotation for this document
                        //there will be an issue with linking from a critical review untill further discussion on how to handle this
                        //when an instructor grades this, the reviewerid of the annoation is the teamid
                        string lookup = assignment.CourseID.ToString() + "-" + assignment.ID.ToString() + "-" +
                                        teamId.ToString() + "-";
                        AnnotateDocumentReference d = (from adr in db.AnnotateDocumentReferences
                                                       where adr.OsbleDocumentCode.Contains(lookup)
                                                       select adr).FirstOrDefault();
                        if (d != null && assignment.DueDate < DateTime.UtcNow)
                        {
                            header.IsAnnotatable = true;
                        }
                        else
                        {
                            header.IsAnnotatable = false;
                        }
                    }
                    else
                    {
                        header.IsAnnotatable = false;
                    }
                }
            }

            //If the Rubric has been evaluated and is published, calculate the rubric grade % to display to the student
            if (rubricEvaluation != null && rubricEvaluation.IsPublished)
            {
                header.IsPublished = true;
            }
            else
            {
                header.IsPublished = false;
            }



            return(header);
        }
Пример #11
0
        private AssignmentDetailsViewModel BuildHeader(AssignmentDetailsViewModel vm)
        {
            //AC NOTE: Items will be displayed in the order in which they are added
            // to the ViewModel's HeaderViews list.  Organize accordingly.

            Assignment assignment = vm.CurrentAssignment;

            vm.HeaderBuilder = new DefaultBuilder();

            List <TeamEvaluation> teamEvaluations = null;

            using (OSBLEContext db = new OSBLEContext())
            {
                //only need get these when they are needed
                if (assignment.Type == AssignmentTypes.TeamEvaluation)
                {
                    teamEvaluations = db.TeamEvaluations.Where(te => te.TeamEvaluationAssignmentID == assignment.ID).ToList();
                }
            }


            //views common to both students and teachers:
            if (assignment.Type == AssignmentTypes.DiscussionAssignment ||
                assignment.Type == AssignmentTypes.CriticalReviewDiscussion)
            {
                //add initial / final post due date information
                //TODO: this will replace the "posts due" row
                vm.HeaderBuilder = new InitialFinalDueDecorator(vm.HeaderBuilder);
                vm.HeaderViews.Add("InitialFinalDueDecorator");
            }

            //not a team evaluation assignment
            if (assignment.Type != AssignmentTypes.TeamEvaluation && assignment.Type != AssignmentTypes.AnchoredDiscussion)
            {
                //add late policy
                vm.HeaderBuilder = new LatePolicyHeaderDecorator(vm.HeaderBuilder);
                vm.HeaderViews.Add("LatePolicyHeaderDecorator");
            }

            //teacher views
            //AC NOTE: Investigate the differences between CanGrade and CanModify
            if (vm.Client.AbstractRole.CanGrade || vm.Client.AbstractRole.CanModify)
            {
                //add deliverable information if needed
                if (assignment.HasDeliverables && assignment.Type != AssignmentTypes.AnchoredDiscussion)
                {
                    //list deliverables add download link
                    vm.HeaderBuilder = new TeacherDeliverablesHeaderDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("TeacherDeliverablesHeaderDecorator");
                }

                //is a discussion assignment
                if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams)
                {
                    //link to classwide discussion
                    vm.HeaderBuilder = new TeacherDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("TeacherDiscussionLinkDecorator");
                }

                if (assignment.HasRubric)
                {
                    //add link to rubric ViewAsUneditable mode
                    vm.HeaderBuilder = new RubricDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("RubricDecorator");

                    //Show rubric grading progress for assignments with rubrics
                    vm.HeaderBuilder = new RubricGradingProgressDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("RubricGradingProgressDecorator");
                }



                if (assignment.Type == AssignmentTypes.TeamEvaluation)
                {
                    //Show progress of TeamEvaluation, such as "X of Y Team Evaluations completed"
                    vm.HeaderBuilder = new TeamEvalProgressDecorator(vm.HeaderBuilder, teamEvaluations);
                    vm.HeaderViews.Add("TeamEvalProgressDecorator");
                }
                else if (assignment.Type == AssignmentTypes.CriticalReview)
                {
                    vm.HeaderBuilder = new PublishCriticalReviewDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("PublishCriticalReviewDecorator");
                }
                else if (assignment.Type == AssignmentTypes.AnchoredDiscussion)
                {
                    //commented out: for now we don't need anything here for the instructor
                    //in future implementations we may want to let the instructor also review documents with the group, but
                    //how the teams are set up currently it wont work (no team set up for instructor)

                    //link for critical review submission document
                    //vm.HeaderBuilder = new AnchoredDiscussionSubmitDecorator(vm.HeaderBuilder, vm.Client);
                    //vm.HeaderViews.Add("AnchoredDiscussionSubmitDecorator");
                }


                // ABET outcomes - the ABETDepartment property being non-null indicates that
                // this assignment was labeled for ABET outcomes and assessment.
                if (null != assignment.ABETDepartment)
                {
                    vm.HeaderBuilder = new ABETOutcomesDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("ABETOutcomesDecorator");
                }
            }
            else if (vm.Client.AbstractRoleID == (int)OSBLE.Models.Courses.CourseRole.CourseRoles.Observer)
            {
                //has discussion teams?
                if (assignment.HasDiscussionTeams)
                {
                    vm.HeaderBuilder = new DiscussionTeamMemberDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("DiscussionTeamMemberDecorator");
                }


                if (assignment.HasRubric)
                {
                    //add link to rubric ViewAsUneditable mode
                    vm.HeaderBuilder = new RubricDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("RubricDecorator");
                }
                if (assignment.HasDeliverables && assignment.Type != AssignmentTypes.AnchoredDiscussion)
                {
                    //list deliverables add download link
                    vm.HeaderBuilder = new TeacherDeliverablesHeaderDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("TeacherDeliverablesHeaderDecorator");
                }
                else if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams)
                {
                    //link to classwide discussion
                    vm.HeaderBuilder = new StudentDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("StudentDiscussionLinkDecorator");
                }
                else if (assignment.Type == AssignmentTypes.CriticalReview)
                {
                    vm.HeaderBuilder = new TeacherDeliverablesHeaderDecorator(vm.HeaderBuilder);
                    vm.HeaderViews.Add("TeacherDeliverablesHeaderDecorator");
                }
            }
            else if (vm.Client.AbstractRole.CanSubmit) //students
            {
                DateTime due = assignment.DueDate.AddHours(assignment.HoursLateWindow);
                due = due.UTCToCourse(vm.Client.AbstractCourseID);
                DateTime now = DateTime.UtcNow;
                now = now.UTCToCourse(vm.Client.AbstractCourseID);
                bool canSub = (now < due);

                //has discussion teams?
                if (assignment.HasDiscussionTeams)
                {
                    vm.HeaderBuilder = new DiscussionTeamMemberDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("DiscussionTeamMemberDecorator");
                }
                else if (assignment.HasTeams)//else has teams?
                {
                    // add team name and list of members
                    vm.HeaderBuilder = new TeamMembersDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("TeamMembersDecorator");
                }

                //needs to submit?
                if (assignment.HasDeliverables)
                {
                    if (assignment.Type == AssignmentTypes.AnchoredDiscussion)
                    {
                        //link for critical review submission document
                        vm.HeaderBuilder = new AnchoredDiscussionSubmissionDecorator(vm.HeaderBuilder, vm.Client);
                        vm.HeaderViews.Add("AnchoredDiscussionSubmissionDecorator");
                    }
                    else
                    {
                        //add student submission link
                        vm.HeaderBuilder = new StudentSubmissionDecorator(vm.HeaderBuilder, vm.Client);
                        vm.HeaderViews.Add("StudentSubmissionDecorator");
                    }
                }
                else if (assignment.Type == AssignmentTypes.CriticalReview)
                {
                    //critical review submission link
                    vm.HeaderBuilder = new CriticalReviewSubmissionDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("CriticalReviewSubmissionDecorator");

                    //link for student to download their reviewed assignment
                    vm.HeaderBuilder = new CriticalReviewStudentDownloadDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("CriticalReviewStudentDownloadDecorator");
                }
                else if (assignment.Type == AssignmentTypes.AnchoredDiscussion)
                {
                    //link for critical review submission document
                    vm.HeaderBuilder = new AnchoredDiscussionSubmissionDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("AnchoredDiscussionSubmissionDecorator");
                }
                else if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams)
                {
                    //link to classwide discussion
                    vm.HeaderBuilder = new StudentDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("StudentDiscussionLinkDecorator");
                }
                else if (assignment.Type == AssignmentTypes.TeamEvaluation && canSub)
                {
                    vm.HeaderBuilder = new StudentTeamEvalSubmissionDecorator(vm.HeaderBuilder, teamEvaluations, vm.Client);
                    vm.HeaderViews.Add("StudentTeamEvalSubmissionDecorator");
                }

                //rubric?
                if (assignment.HasRubric)
                {
                    RubricEvaluation rubricEvaluation = null;



                    //Getting the assignment team for Student, and if its non-null then we take that team ID and find the RubricEvaluation
                    //that they were the recipient of.
                    AssignmentTeam at     = OSBLEController.GetAssignmentTeam(assignment, vm.Client);
                    int            teamId = 0;
                    if (at != null)
                    {
                        teamId = at.TeamID;

                        using (OSBLEContext db = new OSBLEContext())
                        {
                            //Only want to look at evaluations where Evaluator.AbstractRole.CanGrade is true, otherwise
                            //the rubric evaluation is a  student rubric (not interested in them here)
                            rubricEvaluation = (from re in db.RubricEvaluations
                                                where re.AssignmentID == assignment.ID &&
                                                re.Evaluator.AbstractRole.CanGrade &&
                                                re.RecipientID == teamId
                                                select re).FirstOrDefault();
                        }
                    }
                    //add rubric link
                    if (rubricEvaluation == null)
                    {
                        vm.HeaderBuilder = new RubricDecorator(vm.HeaderBuilder);
                        vm.HeaderViews.Add("RubricDecorator");
                    }
                    //add link to graded rubric link
                    else
                    {
                        vm.HeaderBuilder = new RubricGradeDecorator(vm.HeaderBuilder, vm.Client);
                        vm.HeaderViews.Add("RubricGradeDecorator");
                    }
                }
            }

            else if (vm.Client.AbstractRoleID == (int)CourseRole.CourseRoles.Moderator) //Moderator decorators
            {
                //has discussion teams?
                if (assignment.HasDiscussionTeams)
                {
                    vm.HeaderBuilder = new DiscussionTeamMemberDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("DiscussionTeamMemberDecorator");
                }
                else if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams)
                {
                    //link to classwide discussion
                    vm.HeaderBuilder = new StudentDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client);
                    vm.HeaderViews.Add("StudentDiscussionLinkDecorator");
                }
            }

            if (assignment.Type == AssignmentTypes.CriticalReview ||
                assignment.Type == AssignmentTypes.CriticalReviewDiscussion ||
                assignment.Type == AssignmentTypes.TeamEvaluation)
            {
                vm.HeaderBuilder = new PreviousAssignmentDecorator(vm.HeaderBuilder);
                vm.HeaderViews.Add("PreviousAssignmentDecorator");
            }

            if (assignment.Type == AssignmentTypes.CriticalReviewDiscussion && vm.Client.AbstractRole.CanGrade)
            {
                vm.HeaderBuilder = new DownloadDiscussionItemsDecorator(vm.HeaderBuilder);
                vm.HeaderViews.Add("DownloadDiscussionItemsDecorator");
            }

            return(vm);
        }