Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public void GetScorebyStudentAndCourseTest_DefaultScore()
        {
            Mock <IUserRepository>   usrRepMock = new Mock <IUserRepository>();
            Mock <ICourseRepository> corRepMock = new Mock <ICourseRepository>();
            Mock <IScoreRepository>  scrRepMock = new Mock <IScoreRepository>();


            var componentList = new List <Component>();

            componentList.Add(new Component());

            Mock <Course> courseMock = new Mock <Course>();

            courseMock.Setup(c => c.Components).Returns(componentList);

            corRepMock.Setup(c => c.GetById(It.IsAny <int>())).Returns(courseMock.Object);
            usrRepMock.Setup(c => c.GetById(It.IsAny <int>())).Returns(student);
            scrRepMock.Setup(c => c.GetByStudentIdAndComponentId(It.IsAny <Student>(), It.IsAny <Component>())).Returns <Score>(null);
            scrRepMock.Setup(c => c.CreateOrUpdate(It.IsAny <Score>())).Returns(new Score()
            {
                Value = 0
            });

            var scoreService = new ScoreServices(scrRepMock.Object, corRepMock.Object, usrRepMock.Object);

            var scores = scoreService.GetScorebyStudentAndCourse(1, 1);

            Assert.IsNotNull(scores);
            Assert.IsFalse(scores.Count == 0);
            Assert.AreEqual(0, scores[0].Value);
        }