Esempio n. 1
0
        public HttpResponseMessage Update(AssignmentView view)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var original = this._context.assignments.FirstOrDefault(a => a.id == view.id);
                    original.updated = DateTime.UtcNow;
                    AutoMapper.Mapper.CreateMap <Assignment, Assignment>();
                    AutoMapper.Mapper.Map <Assignment, Assignment>(view.convert(this._context), original);
                    this._context.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
                }

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, view);
                //response.Headers.Location = new Uri(Url.Link("Default", new { id = performer.performerID }));
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Esempio n. 2
0
        private void SetUpSlkBeginButtonAction(AssignmentView view)
        {
            if (AssignmentProperties.IsNoPackageAssignment)
            {
                slkButtonBegin.Visible = false;
            }
            else
            {
                string openFrameset = String.Format(CultureInfo.InvariantCulture, "javascript:SlkOpenFramesetWindow('Frameset/Frameset.aspx?{0}={1}&{2}={3}');",
                                                    FramesetQueryParameter.SlkView, view, FramesetQueryParameter.LearnerAssignmentId, LearnerAssignmentGuidId);

                if (AssignmentProperties.IsNonELearning && LearnerAssignmentProperties.Status.Value != LearnerAssignmentState.Final)
                {
                    if (assignmentFile == null)
                    {
                        slkButtonBegin.NavigateUrl = string.Format(CultureInfo.InvariantCulture, "{0}window.location='{1}&{2}=true';", openFrameset, CurrentUrl, startQueryStringName);
                    }
                    else
                    {
                        SetupFileAction(assignmentFile, slkButtonBegin, true);
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(slkButtonBegin.OnClientClick) && string.IsNullOrEmpty(slkButtonBegin.NavigateUrl))
                    {
                        slkButtonBegin.OnClientClick = openFrameset;
                        slkButtonBegin.NavigateUrl   = openFrameset;
                    }
                }
                slkButtonBegin.ImageUrl = Constants.ImagePath + Constants.NewDocumentIcon;
            }
        }
Esempio n. 3
0
        public HttpResponseMessage Create(AssignmentView view)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var original = view.convert(this._context);
                    original.created = DateTime.UtcNow;
                    this._context.assignments.Add(original);
                    this._context.SaveChanges();
                    view = new AssignmentView(original);

                    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, view);
                    //response.Headers.Location = new Uri(Url.Link("Default", new { id = performer.performerID }));
                    return(response);
                }
                catch (Exception ex)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Esempio n. 4
0
        public ActionResult EditAssignment(int id) //assignmentId
        {
            var assignmentView = new AssignmentView();
            var assignment     = _gradeBookRepository.GetAssignment(id);

            assignmentView.ClassName     = _teacherRepository.GetCourseById(assignment.ClassId).Name;
            assignmentView.NewAssignment = assignment;
            return(View(assignmentView));
        }
Esempio n. 5
0
        public ActionResult AddAssignment(int id) //takes in classId
        {
            var assignment    = new AssignmentView();
            var newAssignment = new Assignment();

            assignment.NewAssignment         = newAssignment;
            assignment.NewAssignment.ClassId = id;
            assignment.ClassName             = _teacherRepository.GetCourseById(id).Name;

            return(View(assignment));
        }
Esempio n. 6
0
 public ActionResult AddAssignment(AssignmentView assignmentView)
 {
     if (ModelState.IsValid)
     {
         _gradeBookRepository.CreateAssignment(assignmentView.NewAssignment);
         return(RedirectToAction("EditAssignment", new { id = assignmentView.NewAssignment.AssignmentId }));
     }
     // var newEntry = new AssignmentView();
     // newEntry.NewAssignment = assignment;
     assignmentView.ClassName = _teacherRepository.GetCourseById(assignmentView.NewAssignment.ClassId).Name;
     return(View(assignmentView));
 }
Esempio n. 7
0
        public ActionResult EditAssignment(AssignmentView assignmentView) //assignmentId
        {
            _gradeBookRepository.EditAssignment(assignmentView.NewAssignment);
            int classId   = 0;
            var gradeBook = new GradeBook();
            var course    = new Course();

            classId = _gradeBookRepository.GetAssignment(assignmentView.NewAssignment.AssignmentId).ClassId;

            course                   = _teacherRepository.GetCourseById(classId);
            gradeBook.Course         = course;
            gradeBook.AssignmentList = _gradeBookRepository.GetListOfAssignmentsById(classId);


            return(View("GradeBookDisplay", gradeBook));
        }
Esempio n. 8
0
        public void LoadAssignments()
        {
            _view.Clear();

            foreach (Assignment assignment in EmployeeSchedule.Assignments)
            {
                if (assignment.route.Duration > 0)
                {
                    RouteView routeView = new RouteView(assignment.route);
                    _view.AddRoute(routeView);
                }

                AssignmentView assignmentView = new AssignmentView(assignment);
                _view.AddAssignment(assignmentView);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Returns the SlkRole tied to the requested assignment view.
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        protected static SlkRole GetSlkRole(AssignmentView view)
        {
            switch (view)
            {
            case AssignmentView.Execute:
                return(SlkRole.Learner);

            case AssignmentView.Grading:
                return(SlkRole.Instructor);

            case AssignmentView.InstructorReview:
                return(SlkRole.Instructor);

            case AssignmentView.StudentReview:
                return(SlkRole.Learner);
            }
            // This would be bad
            return(SlkRole.None);
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the SessionView that corresponds to the AssignmentView.
        /// </summary>
        protected static SessionView GetSessionView(AssignmentView assignView)
        {
            switch (assignView)
            {
            case AssignmentView.Execute:
                return(SessionView.Execute);

            case AssignmentView.Grading:
                //return SessionView.RandomAccess;
                return(SessionView.Review);

            case AssignmentView.InstructorReview:
                return(SessionView.Review);

            case AssignmentView.StudentReview:
                return(SessionView.Review);
            }
            // default value -- this would be an error
            return(SessionView.Execute);
        }
Esempio n. 11
0
        private void SetUpButtons(AssignmentView view)
        {
            SetUpSlkBeginButtonAction(view);

            // Set up delete button
            if (AssignmentProperties.CreatedById.Equals(LearnerAssignmentProperties.LearnerId) && !AssignmentProperties.HasInstructors)
            {
                slkButtonDelete.Text          = PageCulture.Resources.LobbyDeleteAssignmentText;
                slkButtonDelete.ToolTip       = PageCulture.Resources.LobbyDeleteToolTip;
                slkButtonDelete.OnClientClick = PageCulture.Format("javascript: return confirm('{0}');",
                                                                   PageCulture.Resources.LobbyDeleteMessage);
                slkButtonDelete.ImageUrl = Constants.ImagePath + Constants.DeleteIcon;
            }
            else
            {
                slkButtonDelete.Visible = false;
            }

            // Set up submit button
            if (AssignmentProperties.HasInstructors)
            {
                slkButtonSubmit.Text          = PageCulture.Resources.LobbySubmitText;
                slkButtonSubmit.ToolTip       = PageCulture.Resources.LobbySubmitToolTip;
                slkButtonSubmit.OnClientClick = PageCulture.Format("javascript: return confirm('{0}');", PageCulture.Resources.LobbySubmitMessage);
                slkButtonSubmit.ImageUrl      = Constants.ImagePath + Constants.SubmitIcon;
            }
            else
            {
                slkButtonSubmit.Text          = PageCulture.Resources.LobbyMarkasCompleteText;
                slkButtonSubmit.ToolTip       = PageCulture.Resources.LobbyMarkasCompleteToolTip;
                slkButtonSubmit.OnClientClick = PageCulture.Format("javascript: return confirm('{0}');", PageCulture.Resources.LobbyMarkasCompleteMessage);
                slkButtonSubmit.ImageUrl      = Constants.ImagePath + Constants.MarkCompleteIcon;
            }

            slkButtonBegin.AccessKey  = PageCulture.Resources.LobbyBeginAccessKey;
            slkButtonDelete.AccessKey = PageCulture.Resources.LobbyDeleteAccessKey;
            slkButtonSubmit.AccessKey = PageCulture.Resources.LobbySubmitAccessKey;
        }
Esempio n. 12
0
        /// <summary>
        /// Helper function to process the AssignmentView parameter. This method assumes the parameter is required. If it does not
        /// exist or is not a valid value and showErrorPage=true, the error page is shown and the method returns false.
        /// If false is returned, the caller should ignore the value of <paramref name="view"/>.
        /// </summary>
        /// <param name="showErrorPage"></param>
        /// <param name="view"></param>
        /// <returns></returns>
        public bool TryProcessAssignmentViewParameter(bool showErrorPage, out AssignmentView view)
        {
            string viewParam;

            // Default value to make compiler happy
            view = AssignmentView.Execute;

            if (!TryGetRequiredParameter(FramesetQueryParameter.SlkView, out viewParam))
            {
                return(false);
            }

            try
            {
                // Get the view enum value
                view = (AssignmentView)Enum.Parse(typeof(AssignmentView), viewParam, true);
                if ((view < AssignmentView.Execute) || (view > AssignmentView.Grading))
                {
                    if (showErrorPage)
                    {
                        RegisterError(ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterTitle, FramesetQueryParameter.SlkView),
                                      ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterMsg, FramesetQueryParameter.SlkView, viewParam), false);
                    }
                    return(false);
                }
            }
            catch (ArgumentException)
            {
                if (showErrorPage)
                {
                    RegisterError(ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterTitle, FramesetQueryParameter.SlkView),
                                  ResHelper.GetMessage(FramesetResources.FRM_InvalidParameterMsg, FramesetQueryParameter.SlkView, viewParam), false);
                }
                return(false);
            }
            return(true);
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        public void AssignmentsMenu()
        {
            Console.Clear();
            Console.WriteLine("Select an option from Assignments menu: ");
            Console.Write("0.Back to Main Menu\n1.Insert\n2.Display\n3.Exit\n\n------\n>");
            int temp = Integer(0, 3);

            switch (temp)
            {
            case 0:
            {
                MainMenu();
                break;
            }

            case 1:
            {
                Console.Clear();
                Console.WriteLine("Select an option from Insert menu: ");
                Console.Write("0.Back to Main Menu\n1.Create new Assignment" +
                              "\n2.Assign an Assignment to a course" +
                              "\n3.Assign an Assignment to a student" +
                              "\n4.Exit\n\n------\n>");
                int temp1 = Integer(0, 3);
                switch (temp1)
                {
                case 0: { MainMenu(); break; }

                case 1:
                {
                    new AssignmentService().Create();
                    Console.Write("Press any button to continue...");
                    Console.ReadKey();
                    MainMenu();
                    break;
                }

                case 2:
                {
                    Console.Clear();
                    List <Assignment> assignments    = new AssignmentService().SetList();
                    AssignmentView    assignmentView = new AssignmentView();
                    assignmentView.Display(assignments);
                    do
                    {
                        Console.Write("Choose an assignment id to insert in a course:\nPress 0 to go back\n\n------\n>");
                        temp = IntegerId <Assignment>(assignments);
                        if (temp == 0)
                        {
                            Console.WriteLine("Process Terminated"); MainMenu();
                        }

                        Assignment assignment = assignments.FirstOrDefault(x => x.AssignmentId == temp);
                        Console.Clear();
                        new Course_Assignment().InsertCourseByAssignment(assignment);
                        Console.Write("Do you want to add other assignment to other course?:<Y> or <N>?:\n>");
                    } while (YesOrNo());
                    MainMenu();
                    break;
                }

                case 3:
                {
                    Console.Clear();
                    List <Assignment> assignments    = new AssignmentService().SetList();
                    AssignmentView    assignmentView = new AssignmentView();
                    assignmentView.Display(assignments);
                    do
                    {
                        Console.Write("Choose an assignment id to insert in a student:\nPress 0 to go back\n\n------\n>");
                        IntegerId <Assignment>(assignments);
                        if (temp == 0)
                        {
                            Console.WriteLine("Process Terminated"); MainMenu();
                        }
                        Assignment assignment = assignments.FirstOrDefault(x => x.AssignmentId == temp);
                        Console.Clear();
                        new Grade().InsertAssignmentPerCoursePerStudent(assignment);
                        Console.Write("Do you want to add other assignment to other student?:<Y> or <N>?:\n>");
                    } while (YesOrNo());
                    Console.ReadLine();
                    MainMenu();
                    break;
                }



                case 4:
                {
                    Console.WriteLine("Are you sure want to close the program? <Y> or <N>?");
                    if (Console.ReadKey(true).Key == ConsoleKey.Y)
                    {
                        Console.WriteLine("\nExiting...\n");
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        StudentsMenu();
                        break;
                    }
                }
                }
                break;
            }

            case 2:
            {
                Console.Clear();
                List <Assignment> assignments    = new AssignmentService().SetList();
                AssignmentView    assignmentView = new AssignmentView();
                assignmentView.Display(assignments);
                Console.Write("If you want more info about each assignment please type its id:\nPress 0 to go back\n\n------\n>");
                temp = IntegerId <Assignment>(assignments);
                if (temp != 0)
                {
                    assignments = new AssignmentService().SetListAnalytic(assignments);
                }
                while (temp != 0)
                {
                    Assignment assignment = assignments.FirstOrDefault(x => x.AssignmentId == temp);
                    assignmentView.DisplayById(assignment);
                    Console.Write("Press any button to continue...");
                    Console.ReadKey();
                    Console.Clear();
                    assignmentView.Display(assignments);
                    Console.Write("If you want more info about each assignmnet please type its id:\nPress 0 to go back\n\n------\n>");
                    temp = IntegerId <Assignment>(assignments);
                }
                MainMenu();
                break;
            }

            case 3:
            {
                Console.WriteLine("Are you sure want to close the program? <Y> or <N>?");
                if (Console.ReadKey(true).Key == ConsoleKey.Y)
                {
                    Console.WriteLine("\nExiting...\n");
                    break;
                }
                else
                {
                    Console.Clear();
                    AssignmentsMenu();
                    break;
                }
            }
            }
        }
        public const string Src = "Src";    // the page name that opened this page

        public static string GetValueAsParameter(AssignmentView view)
        {
            return(view.ToString());
        }
Esempio n. 16
0
 public void SetView(AssignmentView view)
 {
     _view = view;
 }