Beispiel #1
0
        /// <summary>
        /// Posts a new grade
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public GradeDTO AddGrade(AddGradeViewModel model)
        {
            // get the student from the ssn, throw exception if they don't exist
            Person student = _persons.GetStudentBySSN(model.SSN);

            // get the assignment from the assignmentID, throw exception if it doesn't exist
            Assignment assignment = _assignments.GetAssignmentByID(model.AssignmentID);

            // Checking if the grade already exists
            var studentGrade = _grades.All().SingleOrDefault(grade => grade.AssignmentID == model.AssignmentID && grade.StudentSSN == model.SSN);

            if (studentGrade != null)
            {
                throw new ArgumentException(ErrorCodes.ASSIGNMENT_GRADE_ALREADY_EXISTS);
            }

            Grade grad = new Grade
            {
                AssignmentID = model.AssignmentID,
                StudentSSN   = model.SSN,
                GradeValue   = model.GradeValue
            };

            _grades.Add(grad);

            _uow.Save();

            GradeDTO gradeTransfer = grad.GetGradeDTO();

            gradeTransfer.AssignmentName = assignment.Name;
            gradeTransfer.StudentID      = student.ID;

            return(gradeTransfer);
        }
Beispiel #2
0
 public void EditGrade(BaseViewItemHomeworkExamGrade grade, bool whatIf = false)
 {
     ShowPopup(AddGradeViewModel.CreateForEdit(this, new AddGradeViewModel.EditParameter()
     {
         Item           = grade,
         IsInWhatIfMode = whatIf
     }));
 }
Beispiel #3
0
        public async Task <ActionResult> AddGrade(int courseId, string studentId)
        {
            AddGradeViewModel addGradeViewModel = new AddGradeViewModel();

            addGradeViewModel.CourseId  = courseId;
            addGradeViewModel.StudentId = studentId;

            return(View(addGradeViewModel));
        }
        public void AddGrade()
        {
            try
            {
                MainScreenViewModel.ShowPopup(AddGradeViewModel.CreateForAdd(MainScreenViewModel, new AddGradeViewModel.AddParameter()
                {
                    Class          = Class,
                    IsInWhatIfMode = true
                }));
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
Beispiel #5
0
        public async void Add()
        {
            await TryHandleUserInteractionAsync("Add", async (cancellationToken) =>
            {
                if (Class.WeightCategories.SelectMany(i => i.Grades).Count() >= 5 && !await PowerPlannerApp.Current.IsFullVersionAsync())
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    PowerPlannerApp.Current.PromptPurchase(PowerPlannerResources.GetString("MessageFreeGradesLimitReached"));
                    return;
                }

                MainScreenViewModel.ShowPopup(AddGradeViewModel.CreateForAdd(MainScreenViewModel, new AddGradeViewModel.AddParameter()
                {
                    Class = Class
                }));
            });
        }
Beispiel #6
0
        public void AddGrade()
        {
            // Arrange:
            AddGradeViewModel gradeModel = new AddGradeViewModel
            {
                GradeValue   = 8,
                SSN          = "2233882299",
                AssignmentID = 4
            };

            // Act:
            GradeDTO addedGrade = _service.AddGrade(gradeModel);

            // Assert:
            Assert.AreEqual(gradeModel.SSN, addedGrade.StudentSSN);
            Assert.AreEqual(gradeModel.GradeValue, addedGrade.GradeValue);
            Assert.AreEqual(gradeModel.AssignmentID, addedGrade.AssignmentID);
        }
Beispiel #7
0
        public async Task <ActionResult> AddGrade(AddGradeViewModel addGradeViewModel)
        {
            if (ModelState.IsValid)
            {
                Grade grade = new Grade();
                grade.Course         = db.Courses.Find(addGradeViewModel.CourseId);
                grade.GradingTeacher = grade.Course.Teacher;
                grade.Mark           = addGradeViewModel.Mark;
                grade.Student        = db.Users.Find(addGradeViewModel.StudentId);
                grade.CreationDate   = DateTime.Now;

                db.Grades.Add(grade);
                db.SaveChanges();

                return(RedirectToAction("EditGrades", new { courseId = addGradeViewModel.CourseId, studentId = addGradeViewModel.StudentId }));
            }

            return(View(addGradeViewModel));
        }
        public async void ConvertToGrade()
        {
            await TryHandleUserInteractionAsync("ConvertToGrade", async (cancellationToken) =>
            {
                // For free version, block assigning grade if number of graded items exceeds 5
                if (Item.GetClassOrNull().WeightCategories.SelectMany(i => i.Grades).Where(i => i.GradeReceived != PowerPlannerSending.Grade.UNGRADED).Count() >= 5 &&
                    !await PowerPlannerApp.Current.IsFullVersionAsync())
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    PowerPlannerApp.Current.PromptPurchase(PowerPlannerResources.GetString("MessageFreeGradesLimitReached"));
                    return;
                }

                var model = AddGradeViewModel.CreateForEdit(MainScreenViewModel, new Grade.AddGradeViewModel.EditParameter()
                {
                    Item             = Item,
                    OnSaved          = delegate { this.RemoveViewModel(); },
                    IsUnassignedItem = true
                });

                MainScreenViewModel.ShowPopup(model);
            });
        }
 public GradeDTO addGrade(AddGradeViewModel model)
 {
     return(_assignmentService.AddGrade(model));
 }
Beispiel #10
0
 public AddGradeDialog(AddGradeViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }