示例#1
0
        public ActionResult TakeQuiz(int QuizID)
        {
            Quizze Quiz = db.Quizzes.Where(q => q.QuizID == QuizID).FirstOrDefault();

            if (Quiz == null)
            {
                RedirectToAction("Index", "Home");
            }
            int classID = Quiz.ClassID;

            if (test(classID) != null)
            {
                return(test(classID));
            }
            var  idid = User.Identity.GetUserId();
            User user = db.Users.Where(a => a.IdentityID == idid).FirstOrDefault();

            StudentQuizze HasTaken = db.StudentQuizzes.Where(q => q.QuizID == Quiz.QuizID && q.UserID == user.UsersID).FirstOrDefault();

            if (HasTaken != null)
            {
                return(RedirectToAction("Index", "Class", new { classId = classID }));
            }
            StudentVM student = getSVM(classID);

            student.StudentQuiz        = new StudentQuizze();
            student.StudentQuiz.QuizID = QuizID;
            student.Quiz           = Quiz;
            student.questionList   = db.QuizQuestions.Where(q => q.QuizID == QuizID).ToList();
            student.answerList     = db.MultChoiceAnswers.Where(q => q.QuizQuestion.QuizID == QuizID).ToList();
            student.StudentAnswers = new List <StudentAnswer>();

            return(View("TakeQuiz", "_StudentLayout", student));
        }
示例#2
0
        /// <summary>
        /// Loads the QuizList View, displaying all available quizzes for the student
        /// </summary>
        /// <param name="classID">ID of Class</param>
        /// <returns>The QuizList View</returns>
        public ActionResult QuizList(int classID)
        {
            if (test(classID) != null)
            {
                return(test(classID));
            }
            var  idid = User.Identity.GetUserId();
            User user = db.Users.Where(a => a.IdentityID == idid).FirstOrDefault();

            StudentVM student = getSVM(classID);

            student.Quizzes         = db.Quizzes.Where(q => q.ClassID == classID).ToList();
            student.StudentQuizzes  = db.StudentQuizzes.Where(q => q.Quizze.ClassID == classID && q.UserID == user.UsersID).ToList();
            student.QuizListQuizzes = new List <QuizListQuiz>();
            QuizListQuiz  temp  = null;
            StudentQuizze TQuiz = null;

            foreach (Quizze q in student.Quizzes)
            {
                temp  = new QuizListQuiz();
                TQuiz = db.StudentQuizzes.Where(sq => sq.QuizID == q.QuizID && sq.UserID == user.UsersID).FirstOrDefault();
                if (TQuiz != null)
                {
                    temp.Quiz        = q;
                    temp.Taken       = true;
                    temp.StudentQuiz = TQuiz;
                    student.QuizListQuizzes.Add(temp);
                }
                else
                {
                    if (q.IsHidden == false && q.StartTime.CompareTo(DateTime.Now) < 0 && q.EndTime.CompareTo(DateTime.Now) > 0)
                    {
                        temp.Quiz        = q;
                        temp.Taken       = false;
                        temp.StudentQuiz = new StudentQuizze();
                        student.QuizListQuizzes.Add(temp);
                    }
                }
            }
            return(View("QuizList", "_StudentLayout", student));
        }
示例#3
0
        /// <summary>
        /// Loads The Review Quiz View, with the relevant Quiz Information
        /// </summary>
        /// <param name="StudentQuizID">ID of Student Quiz</param>
        /// <param name="ClassID">ID of Class</param>
        /// <returns>The Review Quiz View</returns>
        public ActionResult ReviewQuiz(int StudentQuizID, int ClassID)
        {
            if (test(ClassID) != null)
            {
                return(test(ClassID));
            }
            StudentVM           student     = getSVM(ClassID);
            StudentQuizze       StudentQuiz = db.StudentQuizzes.Where(sq => sq.SQID == StudentQuizID).FirstOrDefault();
            Quizze              Quiz        = db.Quizzes.Where(q => q.QuizID == StudentQuiz.QuizID).FirstOrDefault();
            List <QuizQuestion> Questions   = db.QuizQuestions.Where(q => q.QuizID == Quiz.QuizID).ToList();

            student.ReviewQuestions = new List <QuizReview>();
            MultChoiceAnswer Answer         = null;
            QuizReview       ReviewQuestion = null;
            StudentAnswer    SAnswer        = null;

            student.Quiz = Quiz;
            foreach (QuizQuestion Q in Questions)
            {
                ReviewQuestion = new QuizReview();
                ReviewQuestion.QuestionText = Q.QuestionText;
                ReviewQuestion.Points       = Q.Points;
                ReviewQuestion.QuestionID   = Q.QuestionID;
                SAnswer = db.StudentAnswers.Where(sa => sa.QuestionID == Q.QuestionID && sa.SQID == StudentQuiz.SQID).FirstOrDefault();
                Answer  = db.MultChoiceAnswers.Where(a => a.QuestionID == Q.QuestionID).FirstOrDefault();
                ReviewQuestion.StudentPoints = SAnswer.StudentPoints;
                ReviewQuestion.StudentAnswer = SAnswer.AnswerNumber;
                ReviewQuestion.Answer1       = Answer.Answer1;
                ReviewQuestion.Answer2       = Answer.Answer2;
                ReviewQuestion.Answer3       = Answer.Answer3;
                ReviewQuestion.Answer4       = Answer.Answer4;
                ReviewQuestion.CorrectAnswer = Answer.CorrectAnswer;
                student.ReviewQuestions.Add(ReviewQuestion);
            }


            return(View("ReviewQuiz", "_StudentLayout", student));
        }
示例#4
0
        public ActionResult AnswerQuiz([Bind(Include = "QuestionID,AnswerNumber")] List <StudentAnswer> StudentAnswers,
                                       [Bind(Include = "QuizID")] StudentQuizze StudentQuiz)
        {
            int       QuizID     = StudentQuiz.QuizID;
            int       ClassID    = db.Quizzes.Where(q => q.QuizID == QuizID).FirstOrDefault().ClassID;
            StudentVM student    = getSVM(ClassID);
            var       IdentityID = User.Identity.GetUserId();

            StudentQuiz.UserID    = db.Users.Where(a => a.IdentityID == IdentityID).FirstOrDefault().UsersID;
            StudentQuiz.CanReview = true;

            StudentQuiz.GradeID = db.Grades.Where(i => i.QuizID == QuizID).FirstOrDefault().GradeID;

            db.AddStudentQuiz(StudentQuiz);
            db.SaveChanges();
            int PointTotal = 0;

            foreach (StudentAnswer a in StudentAnswers)
            {
                if (a.AnswerNumber == db.MultChoiceAnswers.Where(an => an.QuestionID == a.QuestionID).FirstOrDefault().CorrectAnswer)
                {
                    a.StudentPoints = db.QuizQuestions.Where(q => q.QuestionID == a.QuestionID).FirstOrDefault().Points;
                }
                else
                {
                    a.StudentPoints = 0;
                }
                PointTotal += a.StudentPoints;
                a.SQID      = StudentQuiz.SQID;
                db.AddStudentAnswer(a);
                db.SaveChanges();
            }
            StudentQuiz.TotalPoints = PointTotal;
            db.SetModified(StudentQuiz);
            db.SaveChanges();
            return(RedirectToAction("QuizList", "Students", new { classID = ClassID }));
        }
示例#5
0
 public void RemoveStudentQuiz(StudentQuizze q)
 {
 }
示例#6
0
 public void AddStudentQuiz(StudentQuizze q)
 {
 }
示例#7
0
 public void RemoveStudentQuiz(StudentQuizze q)
 {
     db.StudentQuizzes.Remove(q);
 }
示例#8
0
 public void AddStudentQuiz(StudentQuizze q)
 {
     db.StudentQuizzes.Add(q);
 }