internal RightsEnum CanApprove(GradeViewModel grade) { if (!grade.IsReadyToApprove) { return(RightsEnum.GradeError); } if (grade.ApprovalStage == ApprovalStage.Open && CanInstructorApprove(grade.Teacher)) { return(RightsEnum.Success); } else if (grade.ApprovalStage == ApprovalStage.Instructor && HasClassroomRights) { return(RightsEnum.Success); } else if (grade.ApprovalStage == ApprovalStage.Classroom && HasOfficeRights) { return(RightsEnum.Success); } return(RightsEnum.StageError); }
public void LoadGrade(string studentName, GradeViewModel grade) { _studentName = studentName; _grade = grade; IsEnabled = (RightsEnum.Success == UserViewModel.CurrentUser.CanEdit(_grade)); if (CourseViewModel.HasSpecialGrade(grade.Subject)) { entSpecialGrade.Visibility = System.Windows.Visibility.Visible; staSpecialGrade.Visibility = System.Windows.Visibility.Visible; } Maintenance.LetterGrades.Keys.ToList().ForEach(g => cmbLetterGrade.Items.Add(g)); Maintenance.Comments.ToList().ForEach(g => cmbComment.Items.Add(g)); cmbComment.SelectedIndex = 0; staStudent.Content = studentName; staCourse.Content = _grade.Subject + " for " + _grade.MarkingPeriod + " " + _grade.Group + " with " + _grade.Teacher; cmbLetterGrade.Text = _grade.LetterGrade; entSpecialGrade.Text = _grade.SpecialGrade; var comment = _grade.Comment; foreach (var c in Maintenance.Comments) { var formattedComment = Maintenance.FormatCommentFromList(c); if (string.IsNullOrWhiteSpace(formattedComment)) continue; if (comment.StartsWith(formattedComment)) { cmbComment.Text = c; comment = comment.Substring(formattedComment.Length).Trim(); break; } } entComment.Text = comment; }
internal RightsEnum CanUnApprove(GradeViewModel grade) { var rv = RightsEnum.None; if (grade.ApprovalStage == ApprovalStage.Open) rv = RightsEnum.StageError; else if (_user.Role == RoleEnum.SuperUser) rv = RightsEnum.Success; else if (grade.ApprovalStage == ApprovalStage.Office) rv = RightsEnum.StageError; else if (grade.ApprovalStage == ApprovalStage.None || grade.ApprovalStage == ApprovalStage.Open) rv = RightsEnum.StageError; else if (grade.ApprovalStage == ApprovalStage.Classroom && HasOfficeRights) rv = RightsEnum.Success; else if (grade.ApprovalStage == ApprovalStage.Instructor && HasClassroomRights) rv = RightsEnum.Success; else rv = RightsEnum.UserError; return rv; }
internal RightsEnum CanApprove(GradeViewModel grade) { if (!grade.IsReadyToApprove) return RightsEnum.GradeError; if (grade.ApprovalStage == ApprovalStage.Open && CanInstructorApprove(grade.Teacher)) return RightsEnum.Success; else if (grade.ApprovalStage == ApprovalStage.Instructor && HasClassroomRights) return RightsEnum.Success; else if (grade.ApprovalStage == ApprovalStage.Classroom && HasOfficeRights) return RightsEnum.Success; return RightsEnum.StageError; }
public RightsEnum CanEdit(GradeViewModel grade) { if (grade.ApprovalStage == ApprovalStage.Office) return RightsEnum.StageError; if (HasOfficeRights) return RightsEnum.Success; if (grade.ApprovalStage == ApprovalStage.Classroom) return RightsEnum.UserError; if (HasClassroomRights) return RightsEnum.Success; if (grade.ApprovalStage == ApprovalStage.Instructor) return RightsEnum.UserError; if (Name == grade.Teacher) return RightsEnum.Success; return RightsEnum.UserError; }
public EditGradeWindow(string studentName, GradeViewModel grade) { InitializeComponent(); gradeEditor.LoadGrade(studentName, grade); }
public EditGrade(string studentName, GradeViewModel grade) : this() { LoadGrade(studentName, grade); }