예제 #1
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));
        }
예제 #2
0
 public ActionResult edit(string id)
 {
     return(new JsonNetResult(_db.GetAttempt(id)));
 }