예제 #1
0
        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();
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        /// <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));
        }
예제 #6
0
        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 }));
        }
예제 #7
0
        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)));
        }
예제 #8
0
        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));
        }