Esempio n. 1
0
        public ActionResult QuickNav()
        {
            string componentName = Request.Form["ComponentName"];

            manager = new AssignmentWizardComponentManager(CurrentUser);
            IWizardBaseController componentToFind = manager.GetComponentByName(componentName);

            //start at the beginning
            while (manager.GetPreviousComponent() != null)
            {
                ;
            }

            //empty component name = start at the beginning (component selection)
            if (componentName.Length == 0)
            {
                return(RedirectToRoute(AssignmentWizardAreaRegistration.AssignmentWizardRoute,
                                       new
                {
                    controller = "Home",
                    action = "SelectComponent",
                    assignmentId = manager.ActiveAssignmentId
                }
                                       ));
            }

            //from the beginning, find the component that we want to jump to
            bool found = false;

            while (!found)
            {
                if (manager.ActiveComponent == null)
                {
                    found = true;
                }
                else if (manager.ActiveComponent.ControllerName.CompareTo(componentToFind.ControllerName) == 0)
                {
                    found = true;
                }
                else
                {
                    manager.GetNextComponent();
                }
            }

            //redirect to the component
            return(RedirectToRoute(AssignmentWizardAreaRegistration.AssignmentWizardRoute,
                                   new
            {
                controller = componentToFind.ControllerName,
                action = "Index"
            }
                                   ));
        }
Esempio n. 2
0
        private void ActivateSelectedComponents()
        {
            manager.DeactivateAllComponents();
            string componentPrefix = "component_";

            foreach (string key in Request.Form.AllKeys)
            {
                if (key.Substring(0, componentPrefix.Length) == componentPrefix)
                {
                    IWizardBaseController comp = manager.GetComponentByName(Request.Form[key]);
                    comp.IsSelected = true;
                }
            }

            //if we're loading a previous assignment, we need to go through and
            //remove links to any unselected items
            if (manager.ActiveAssignmentId != 0)
            {
                Assignment assignment = db.Assignments.Find(manager.ActiveAssignmentId);

                //RUBRICS
                if (manager.UnselectedComponents.Contains(manager.GetComponentByType(typeof(RubricController))))
                {
                    if (assignment.HasRubric)
                    {
                        db.Rubrics.Remove(assignment.Rubric);
                    }
                    assignment.Rubric   = null;
                    assignment.RubricID = null;
                }

                //STUDENT RUBRICS
                if (manager.UnselectedComponents.Contains(manager.GetComponentByType(typeof(StudentRubricController))))
                {
                    if (assignment.HasStudentRubric)
                    {
                        db.Rubrics.Remove(assignment.StudentRubric);
                    }
                    assignment.StudentRubric   = null;
                    assignment.StudentRubricID = null;
                }

                //COMMENT CATEGORIES
                if (manager.UnselectedComponents.Contains(manager.GetComponentByType(typeof(CommentCategoryController))))
                {
                    assignment.CommentCategory   = null;
                    assignment.CommentCategoryID = null;
                }

                //DELIVERABLES
                if (manager.UnselectedComponents.Contains(manager.GetComponentByType(typeof(DeliverablesController))))
                {
                    assignment.Deliverables = null;
                }

                //ABET
                if (manager.UnselectedComponents.Contains(manager.GetComponentByType(typeof(ABETController))))
                {
                    assignment.ABETDepartment = null;
                }

                db.Entry(assignment).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }
        }