public ActionResult Grades(Guid activityId) { if (!UserIsInRole("Professor")) { return(RedirectToAction("Index", "Home")); } var activity = _activityQuery.Handle(new ActivityInputGetById { ActivityId = activityId }).Activity; var students = _studentQuery.Handle(new StudentInputListByDiscipline { DisciplineId = activity.Discipline.Id }).Students; var grades = new GiveGradeListViewModel { DisciplineId = activity.Discipline.Id, ActivityName = activity.Description, ActivityValue = activity.Value, }; foreach (var student in students) { var grade = _activityEvaluationQuery.Handle(new ActivityInputGetByStudent { ActivityId = activityId, StudentId = student.Id }).Activity; grades.Students.Add(new GiveGradeListItem { ActivityId = activity.Id, Student = $"{student.FirstName} {student.LastName}", Grade = grade == null ? "0" : grade.Grade.ToString(), StudentId = student.Id }); } return(View(grades)); }
public void ShouldGetByIdStudentWithSuccess() { var result = handler.Handle(commandGetById); Assert.IsTrue(result.Student.Id == student.Id); Assert.IsTrue(result.Student.CPF.Number == student.CPF.Number); }
public ActionResult Index(Guid disciplineId) { if (!UserIsInRole("Professor")) { return(RedirectToAction("Index", "Home")); } var students = _studentQuery.Handle(new StudentInputListByDiscipline { DisciplineId = disciplineId }).Students; var exams = _activityQuery.Handle(new ExamInputGetByDiscipline { DisciplineId = disciplineId, Semester = new UseCases.Shared.Semester() }).Activities; if (exams.Count() == 0) { CreateExams(disciplineId); exams = _activityQuery.Handle(new ExamInputGetByDiscipline { DisciplineId = disciplineId, Semester = new UseCases.Shared.Semester() }).Activities; } var grades = new ExamListViewModel { DisciplineId = disciplineId, DisciplineName = exams.First().Discipline.Name }; foreach (var student in students) { var studentGrades = new Dictionary <string, decimal>(); foreach (var exam in exams) { var result = _activityEvaluationQuery.Handle(new ActivityInputGetByStudent { ActivityId = exam.Id, StudentId = student.Id }).Activity; decimal grade = 0; if (result == null) { _activityEvaluationCommand.Handle(new ActivityInputGiveGrade { ActivityId = exam.Id, Grade = 0, StudentId = student.Id, Value = exam.Value }); } else { grade = result.Grade; } studentGrades.Add(exam.Description, grade); } var item = new ExamListItem { Student = $"{student.FirstName} {student.LastName}", StudentId = student.Id, Exam1 = studentGrades.Single(x => x.Key == new Exam1(Guid.Empty).Description).Value, Exam2 = studentGrades.Single(x => x.Key == new Exam2(Guid.Empty).Description).Value, Exam3 = studentGrades.Single(x => x.Key == new Exam3(Guid.Empty).Description).Value, FinalExam = studentGrades.Single(x => x.Key == new FinalExam(Guid.Empty).Description).Value }; grades.Students.Add(item); } return(View(grades)); }
// GET: Enrollment/Create public ActionResult Create(ChooseStudentViewModel student) { if (!UserIsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } var result = _studentQuery.Handle(new StudentInputGetByCPF { StudentCPF = student.StudentCPF }).Student; if (result == null) { ModelState.AddModelError("StudentCPF", "CPF Inválido"); student.Courses = GetComboboxCourse(); return(View("ChooseStudent", student)); } var disciplines = _disciplineQuery.Handle(new DisciplineInputGetNotConcluded { CourseId = student.SelectedCourse, StudentId = result.Id }).Disciplines; var portfolio = new CreateEnrollmentViewModel { Disciplines = disciplines.Select(x => new Checkbox { Text = x.Name, Value = x.Id.ToString() }), StudentId = result.Id }; return(View(portfolio)); }
// GET: Student public ActionResult Index() { if (!UserIsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } var result = _studentQuery.Handle(new StudentInputList()); StudentListViewModel students = new StudentListViewModel() { Students = result.Students.Select(x => new StudentListItem { City = x.City, Course = x.Course.Name, CPF = x.CPF.Number, Email = x.Email.Address, FirstName = x.FirstName, LastName = x.LastName, Id = x.Id.ToString() }) }; return(View(students)); }