예제 #1
0
        public bool CreateItem(StudentQuizResult item)
        {
            _context.StudentQuizResults.AddObject(item);

            SaveChanges();
            return(true);
        }
예제 #2
0
        public static StudentQuizResult StudentResult(int id)
        {
            var result = new StudentQuizResult();

            result.Id            = id;
            result.DateOpen      = DateTime.Now.AddDays(-1);
            result.DateUpdate    = DateTime.Now;
            result.PointsTotal   = id + 2;
            result.PointsStudent = id + 1;

            return(result);
        }
예제 #3
0
        public GenericOperationResult <StudentQuizResult> ProcessResults(Quiz takenQuiz, string studentName)
        {
            var result = OperationResult.GetGenericResultObject <StudentQuizResult>();

            try
            {
                //create a new student quiz result
                var studentQuizResult = new StudentQuizResult();

                //get the actual quiz and student that took the quiz
                var actualQuiz = _quizRepository.GetItem(takenQuiz.Id);
                var student    = _userService.GetUser(studentName);

                //compare the results
                var compareResults = CompareQuizes(actualQuiz, takenQuiz);

                // get the measurments from the compared result and the actual quiz
                var totalPoints   = actualQuiz.Questions.Sum(x => x.Points);
                var studentPoints = compareResults.StudentPoints;

                // populate the student quiz result object
                var date = DateTime.Now;
                studentQuizResult.DateUpdate       = date;
                studentQuizResult.DateOpen         = date;
                studentQuizResult.QuizId           = actualQuiz.Id;
                studentQuizResult.StudentId        = student.UserID;
                studentQuizResult.PointsTotal      = totalPoints;
                studentQuizResult.PointsStudent    = studentPoints;
                studentQuizResult.CorrectQuestions = compareResults.CorrectQuestions;
                studentQuizResult.DetailResult     =
                    DetailResultSerializer.SerializeDetailedQuizResultToXml(compareResults.QuizDetailResults);

                //store the new student quiz result object
                _studentQuizResultRepository.CreateItem(studentQuizResult);

                ProcessStudentRank(student.UserName);

                var actualStudentQuizResult =
                    _studentQuizResultRepository.GetAllItems().Where(
                        x => x.StudentId == student.UserID && x.QuizId == actualQuiz.Id && x.DateUpdate >= date).FirstOrDefault();

                result.SetSuccess();
                result.SetData(actualStudentQuizResult);
                return(result);
            }
            catch (Exception e)
            {
                result.SetException();
                result.AddMessage(e.Message);
                result.AddExceptionMessage(e.Message);
                return(result);
            }
        }
예제 #4
0
        public bool UpdateItem(StudentQuizResult item)
        {
            var oldItem = GetItem(item.Id);

            oldItem.QuizId        = item.QuizId;
            oldItem.StudentId     = item.StudentId;
            oldItem.DateUpdate    = item.DateUpdate;
            oldItem.DateOpen      = item.DateOpen;
            oldItem.PointsTotal   = item.PointsTotal;
            oldItem.PointsStudent = item.PointsStudent;

            return(true);
        }
예제 #5
0
        public QuizResultViewModel(string studentName, StudentQuizResult quizResult)
        {
            if (!String.IsNullOrWhiteSpace(studentName) && quizResult != null)
            {
                StudentUserName = studentName;

                QuizName = quizResult.Quiz.Name;
                QuizId   = quizResult.Quiz.Id;

                TotalPoints      = quizResult.PointsTotal;
                StudentPoints    = quizResult.PointsStudent;
                CorrectQuestions = quizResult.CorrectQuestions == null ? 0 : (int)quizResult.CorrectQuestions;

                if (quizResult.DetailResult != null)
                {
                    DetailedResults = DetailResultSerializer.DesirializeFromXml(quizResult.DetailResult);
                }
            }
        }
예제 #6
0
 public bool DeleteItem(StudentQuizResult item)
 {
     return(DeleteItem(item.Id));
 }
예제 #7
0
        public bool CreateItem(StudentQuizResult item)
        {
            _context.Add(item);

            return(true);
        }