public ActionResult add(Attempt obj)
 {
     obj.ID               = Guid.NewGuid().ToString().ToLower();
     obj.CompanyID        = this.Company.ToLower();
     obj.CreatedBy        = LoggedUserID;
     obj.CreationDate     = Utility.GetCurrentDateInt();
     obj.CreationTime     = Utility.GetCurrentTimeInt();
     obj.ModificationDate = Utility.GetCurrentDateInt();
     obj.ModificationTime = Utility.GetCurrentTimeInt();
     obj.ModifiedBy       = LoggedUserID;
     _db.AddAttempt(obj);
     return(RedirectToAction("index"));
 }
Exemple #2
0
        public ActionResult exam(VMStartExam obj)
        {
            var quiz = GetQuiz(obj.QuizId);

            if (quiz == null || quiz.IsPublished == false)
            {
                return(Content("Invalid exam."));
            }
            if (quiz != null && quiz.IsOnlyInClass && quiz.Otp != obj.Otp)
            {
                return(Content("Invalid OTP."));
            }
            var lang = obj.Lang;

            if (string.IsNullOrWhiteSpace(lang))
            {
                lang = "en";
            }
            service = new QuizService(quiz);
            var attempt = _db.GetAttempt(quiz.ID, LoggedUserID);

            if (attempt != null && !quiz.AllowMultipleAttempts)
            {
                return(Content("You are allow to attempt this exam only once."));
            }

            Attempt objAttempt = new Attempt();

            objAttempt.BatchID          = null;
            objAttempt.CompanyID        = Company;
            objAttempt.CreatedBy        = LoggedUserID;
            objAttempt.CreationDate     = Utility.GetCurrentDateInt();
            objAttempt.CreationTime     = Utility.GetCurrentTimeInt();
            objAttempt.ID               = Guid.NewGuid().ToString().ToLower();
            objAttempt.IsActive         = true;
            objAttempt.ModificationDate = Utility.GetCurrentDateInt();
            objAttempt.ModificationTime = Utility.GetCurrentTimeInt();
            objAttempt.ModifiedBy       = LoggedUserID;
            objAttempt.OtherDetails     = null;
            objAttempt.QuizID           = quiz.ID;
            objAttempt.UserID           = LoggedUserID;

            objAttempt = _db.AddAttempt(objAttempt);

            var data = service.GetQuizData(lang.ToLower(), objAttempt.ID);

            return(View("mcq", data));
        }