Ejemplo n.º 1
0
        public ActionResult Edit(ClassViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    GlobalStaticVars.StaticCore.ModifyClass(model.Class);
                }

                return View("InstructorClassHome", model);
            }
            catch (Exception e)
            {
                return RedirectToAction("ServerError", "Error");
            }
        }
Ejemplo n.º 2
0
        public ActionResult Home(int id)
        {
            try
            {
                ClassData cls = GlobalStaticVars.StaticCore.GetClassById(id);
                //If the current user is the instructor for the class...
                if (WebSecurity.CurrentUserId == cls.Instructor.Id)
                {
                    Session["ClassId"] = id;
                    Session["UserType"] = UserType.Instructor;

                    ClassViewModel model = new ClassViewModel();
                    model.Class = cls;
                    model.Sets = GlobalStaticVars.StaticCore.GetSetsForClass(id);

                    //Add in the unassigned set that captures any problems not assigned to any sets
                    ProblemSetData unassigned = new ProblemSetData(-1);
                    unassigned.Name = "Unassigned Problems";
                    unassigned.Class = new ClassData(id);
                    model.Sets.Add(unassigned);

                    return View("InstructorClassHome", model);
                }
                //If the current user is a student in the class...
                else if (GlobalStaticVars.StaticCore.IsStudent(WebSecurity.CurrentUserId, id))
                {
                    Session["ClassId"] = id;
                    Session["UserType"] = UserType.Student;

                    Tuple<List<ProblemSetData>, List<ProblemSetData>, List<ProblemSetData>> sets =
                        GlobalStaticVars.StaticCore.GetSetsForStudent(WebSecurity.CurrentUserId, id);
                    ViewBag.UnlockedSets = sets.Item1;
                    ViewBag.LockedSets = sets.Item2;
                    ViewBag.SolvedSets = sets.Item3;
                    return View("StudentClassHome", cls);
                }

                Session.Clear();
                return RedirectToAction("Home");
            }
            catch (Exception e)
            {
                return RedirectToAction("ServerError", "Error");
            }
        }