public void OpenFormEditCourse(int id) { var course = _courseServices.GetCourseById(id); IList <Lecturer> lecturers; IList <Student> students; getLecturersAndStudents(out lecturers, out students); var courseForm = new CourseForm(this, course, lecturers, students); courseForm.Show(); }
public ScoredCourse GetScoreData(int studentId, int courseId) { var scoreServcies = new ScoreServices(_scrRep, _corRep, _usrRep); var courseServices = new CourseServices(_corRep, _usrRep, _comRep); var course = courseServices.GetCourseById(courseId); var scores = scoreServcies.GetScorebyStudentAndCourse(studentId, courseId); var scoresViewModel = new List <SimpleScore>(); foreach (var score in scores) { scoresViewModel.Add(new SimpleScore(score)); } scoresViewModel.Sort((m1, m2) => m1.ComponentName.CompareTo(m2.ComponentName)); var scoredCourse = new ScoredCourse() { Name = course.Name, ScoreList = scoresViewModel }; return(scoredCourse); }
public ActionResult Component(int id) { if (Session["userId"] == null) { return(RedirectToAction("Index", "Home")); } var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository); var course = courseServices.GetCourseById(id); ViewBag.Title = course.Name; ViewBag.Email = Session["email"]; ViewBag.Id = course.Id; if (course == null) { return(RedirectToAction("Index", "Home")); } IList <ComponentViewModel> components = new List <ComponentViewModel>(); foreach (var component in course.Components) { components.Add(new ComponentViewModel(component)); } return(View(components)); }
public ActionResult StudentsEnrolled(int id, bool?error) { if (Session["userId"] == null) { return(RedirectToAction("Index", "Home")); } ViewBag.Email = Session["email"]; if (error == true) { ModelState.AddModelError("prag_error", "Nemoguće unjeti više bodova od maksimalnog broj bodova po komponenti!"); } var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository); var course = courseServices.GetCourseById(id); ViewBag.Title = course.Name; var studentServices = new StudentServices(_userRepository); var scoreServices = new ScoreServices(_scoreRepository, _courseRepository, _userRepository); IList <Student> enrolledStudents = studentServices.GetStudentsByCourse(course); IList <StudentEnrollementViewModel> enroll = new List <StudentEnrollementViewModel>(); foreach (Student s in enrolledStudents) { IList <Score> score = scoreServices.GetScorebyStudentAndCourse(s.Id, course.Id); enroll.Add(new StudentEnrollementViewModel(score)); } return(View(enroll)); }
/// <summary> /// /// </summary> /// <param name="id">Course id</param> /// <returns></returns> public ActionResult ScoreInfo(int id) { if (Session["userId"] == null) { return(RedirectToAction("Index", "Home")); } ViewBag.Email = Session["email"]; ViewBag.Title = "Bodovi"; var studentId = (int)Session["userId"]; var scoreServcies = new ScoreServices(_scoreRepository, _courseRepository, _userRepository); var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository); var course = courseServices.GetCourseById(id); var scores = scoreServcies.GetScorebyStudentAndCourse(studentId, id); var scoresViewModel = new List <ScoreViewModel>(); foreach (var score in scores) { scoresViewModel.Add(new ScoreViewModel(score)); } scoresViewModel.Sort((m1, m2) => m1.ComponentName.CompareTo(m2.ComponentName)); var scoredCourse = new ScoredCourseViewModel() { Name = course.Name, scoreList = scoresViewModel }; return(View(scoredCourse)); }
public ActionResult CreateComponent(ComponentViewModel comp) { var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository); var course = courseServices.GetCourseById(comp.Id); var componentServices = new ComponentServices(_componentRepository, _courseRepository); var component = componentServices.CreateComponent(comp.Name, comp.CourseId, comp.MinimumPointsToPass, comp.MaximumPoints); return(RedirectToAction("Component", "Lecturer", new { id = comp.CourseId })); }
public ActionResult CreateComponent(int id) { if (Session["userId"] == null) { return(RedirectToAction("Index", "Home")); } ViewBag.Title = "Nova komponenta"; ViewBag.Email = Session["email"]; var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository); var course = courseServices.GetCourseById(id); Component newComponent = new Component() { Course = course }; return(View(new ComponentViewModel(newComponent))); }
public ActionResult ComponentStatistics(int id) { if (Session["userId"] == null) { return(RedirectToAction("Index", "Home")); } ViewBag.Email = Session["email"]; ViewBag.Title = "Statistics"; var courseService = new CourseServices(_courseRepository, _userRepository, _componentRepository); var componentService = new ComponentServices(_componentRepository, _courseRepository); var scoreService = new ScoreServices(_scoreRepository, _courseRepository, _userRepository); var course = courseService.GetCourseById(id); IList <Component> comp = new List <Component>(); foreach (var c in course.Components) { comp.Add(c); } IList <ComponentStatisticsViewModel> results = new List <ComponentStatisticsViewModel>(); foreach (var c in comp) { var scores = scoreService.GetByComponent(c.Id); float sum = 0; float maxSum = 0; foreach (var s in scores) { sum += s.Value; maxSum += c.MaximumPoints; } results.Add(new ComponentStatisticsViewModel(c.Name, (float)sum / maxSum, c.MaximumPoints, c.Course.Id)); } return(View(results)); }