예제 #1
0
        // PUT api/QuestionAdmin/5
        public HttpResponseMessage PutQuestion(int id, Question question)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != question.QuestionId)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            db.Entry(question).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
예제 #2
0
        public static Candidateviewmodal RegisterUser(Candidateviewmodal model)
        {
            using (QuizContext cntxt = new QuizContext())
            {
                if (!cntxt.Candidates.Any(o => o.CandidateName == model.CandidateName))
                {
                    Candidate cndate = new Candidate();
                    cndate.CandidateName  = model.CandidateName;
                    cndate.Password       = model.Password;
                    cndate.CandidateEmail = model.EmailID;
                    cndate.AddedDate      = DateTime.Now;
                    cntxt.Candidates.Add(cndate);
                    cntxt.SaveChanges();
                    CandidateLogin cndlog = new CandidateLogin();
                    cndlog.CandidateId = cndate.CandidateId;
                    cndlog.LogDate     = DateTime.Now;
                    cntxt.CandidateLogins.Add(cndlog);

                    cntxt.SaveChanges();
                    model.isValidUser  = true;
                    model.LoginMessage = "Candidate Sucessfully Added";
                    model.isValidUser  = true;
                    model.CandidateId  = model.CandidateId;
                }
                else
                {
                    model.isValidUser  = false;
                    model.LoginMessage = "User Name Already Used;Try another name ";
                }
            }

            return(model);
        }
예제 #3
0
        private void PerSectionSave()
        {
            var answers = new List <Answer>();

            foreach (var sectionSave in _session.Saves)
            {
                foreach (var questionIdAnswers in sectionSave.Value.Answers)
                {
                    var answer = _helper.ExamineQuestion(
                        _cx.Questions.Find(questionIdAnswers.Key), questionIdAnswers.Value);

                    answers.Add(answer);
                }
            }

            _attempt.Mark = _helper.ExamineQuiz(_attempt.Quiz, answers, _session);

            _cx.QuizAttempts.Add(_attempt);
            foreach (var item in answers)
            {
                item.Attempt = _attempt;
            }
            _cx.Answers.AddRange(answers);

            _cx.SaveChanges();

            Attempt = _attempt;
        }
예제 #4
0
 public void Delete(Answer answer)
 {
     if (answer != null)
     {
         db.Answers.Remove(answer);
         db.SaveChanges();
     }
 }
예제 #5
0
 public void Delete(User user)
 {
     if (user != null)
     {
         db.Users.Remove(user);
         db.SaveChanges();
     }
 }
예제 #6
0
 public void Delete(Quize quiz)
 {
     if (quiz != null)
     {
         db.Quizes.Remove(quiz);
         db.SaveChanges();
     }
 }
 public void Delete(QuizUserStats quizUserStats)
 {
     if (quizUserStats != null)
     {
         db.QuizUserStats.Remove(quizUserStats);
         db.SaveChanges();
     }
 }
예제 #8
0
 public void Delete(QuizCategory category)
 {
     if (category != null)
     {
         db.QuizCategories.Remove(category);
         db.SaveChanges();
     }
 }
 public void Delete(QuizQuestion question)
 {
     if (question != null)
     {
         db.QuizQuestions.Remove(question);
         db.SaveChanges();
     }
 }
예제 #10
0
        static void Quiz1(QuizContext context)
        {
            Quiz quiz1 = new Quiz();

            quiz1.Title = "ASP.NET Test";
            context.Quiz.Add(quiz1);
            context.SaveChanges();

            Question q1 = new Question();

            q1.QuizId        = quiz1.ID;
            q1.Text          = "What class does the ASP.NET Web Form class inherit from by default?";
            q1.CorrectAnswer = "System.Web.UI.Page";
            q1.Answer1       = "System.Web.UI.Form";
            q1.Answer2       = "System.Web.GUI.Page";
            q1.Answer3       = "System.Web.Form";
            context.Questions.Add(q1);


            q1               = new Question();
            q1.QuizId        = quiz1.ID;
            q1.Text          = "We can manage states in asp.net application using";
            q1.CorrectAnswer = "All";
            q1.Answer1       = "Session Objects";
            q1.Answer2       = "Application Objects";
            q1.Answer3       = "Viewstate";
            context.Questions.Add(q1);

            q1               = new Question();
            q1.QuizId        = quiz1.ID;
            q1.Text          = "When writing ASP code, what are the correct delimiters to use?";
            q1.CorrectAnswer = "<% code %>";
            q1.Answer1       = "< code >";
            q1.Answer2       = "<% code >";
            q1.Answer3       = "";
            context.Questions.Add(q1);

            q1               = new Question();
            q1.QuizId        = quiz1.ID;
            q1.Text          = "What does Response.End will do?";
            q1.CorrectAnswer = "It will stop the server process";
            q1.Answer1       = "None of the options";
            q1.Answer2       = "It will stop the client process";
            q1.Answer3       = "";
            context.Questions.Add(q1);

            q1               = new Question();
            q1.QuizId        = quiz1.ID;
            q1.Text          = "When does Garbage collector run?";
            q1.CorrectAnswer = "When application is running low of memory";
            q1.Answer1       = "It runs random";
            q1.Answer2       = " When application is running for more than 15 minutes";
            q1.Answer3       = "None of the above";
            context.Questions.Add(q1);
            context.SaveChanges();
        }
        public async Task <IActionResult> PutQuizItem([FromBody] QuizItem quizItem)
        {
            var dbItem = _context.QuizItem.Find(quizItem.QuizItemId);

            _context.Entry(dbItem).State = EntityState.Detached;
            if (dbItem == null)
            {
                return(BadRequest());
            }
            _context.Entry(quizItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                if (quizItem.Answers != null && quizItem.Answers.Any())
                {
                    var oldAnswers = _context.QuizAnswers.Where(a => a.QuizItemId == quizItem.QuizItemId);
                    _context.QuizAnswers.RemoveRange(oldAnswers);
                    _context.SaveChanges();
                    foreach (var item in quizItem.Answers)
                    {
                        var answer = new QuizAnswer
                        {
                            Answer     = item,
                            QuizItemId = quizItem.QuizItemId
                        };
                        _context.QuizAnswers.Add(answer);
                    }
                    await _context.SaveChangesAsync();
                }

                if (quizItem.Options != null && quizItem.Options.Any())
                {
                    var oldOptions = _context.QuizOptions.Where(a => a.QuizItemId == quizItem.QuizItemId);
                    _context.QuizOptions.RemoveRange(oldOptions);
                    _context.SaveChanges();
                    foreach (var item in quizItem.Options)
                    {
                        var option = new QuizOption
                        {
                            Option     = item,
                            QuizItemId = quizItem.QuizItemId
                        };
                        _context.QuizOptions.Add(option);
                    }
                    await _context.SaveChangesAsync();
                }
            }

            catch (DbUpdateConcurrencyException)
            {
            }

            return(Ok("Updated successfully!"));
        }
예제 #12
0
        public ActionResult Create(Question question)
        {
            if (ModelState.IsValid)
            {
                db.Questions.Add(question);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(question));
        }
예제 #13
0
        public ActionResult Create(Answer answer)
        {
            if (ModelState.IsValid)
            {
                db.Answers.Add(answer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(answer));
        }
예제 #14
0
        public ActionResult Create([Bind(Include = "id,Name,Code")] Assessment assessment)
        {
            if (ModelState.IsValid)
            {
                db.Assessments.Add(assessment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assessment));
        }
예제 #15
0
        public ActionResult Create([Bind(Include = "Id,Lemma,Parsing,Explanation")] QuizWord quizWord)
        {
            if (ModelState.IsValid)
            {
                db.QuizWords.Add(quizWord);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quizWord));
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "AnswerId,AnswerText")] Answer answer)
        {
            if (ModelState.IsValid)
            {
                db.Answers.Add(answer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(answer));
        }
예제 #17
0
        public ActionResult Create([Bind(Include = "JobFieldId,JobFieldName")] JobField jobField)
        {
            if (ModelState.IsValid)
            {
                db.JobFields.Add(jobField);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(jobField));
        }
예제 #18
0
        public ActionResult Create([Bind(Include = "CertificationId,CertificationName")] Certification certification)
        {
            if (ModelState.IsValid)
            {
                db.Certifications.Add(certification);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(certification));
        }
        public ActionResult Create([Bind(Include = "LanguageId,LanguageName")] LanguageMaster languageMaster)
        {
            if (ModelState.IsValid)
            {
                db.LanguageMasters.Add(languageMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(languageMaster));
        }
예제 #20
0
        public ActionResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
예제 #21
0
        public ActionResult Create([Bind(Include = "QuizId,StartTime,Duration,EndTime,Score")] Quiz quiz)
        {
            if (ModelState.IsValid)
            {
                db.Quizs.Add(quiz);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quiz));
        }
예제 #22
0
        public ActionResult Create([Bind(Include = "id,Title")] Topic topic)
        {
            if (ModelState.IsValid)
            {
                db.Topics.Add(topic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(topic));
        }
        public ActionResult Create([Bind(Include = "CountryId,CountryName")] CountryMaster countryMaster)
        {
            if (ModelState.IsValid)
            {
                db.CountryMasters.Add(countryMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(countryMaster));
        }
예제 #24
0
        public ActionResult Create([Bind(Include = "KnowledgeAreaId,CertificationId,KnowledgeAreaName,Remark")] KnowledgeArea knowledgeArea)
        {
            if (ModelState.IsValid)
            {
                db.KnowledgeAreas.Add(knowledgeArea);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CertificationId = new SelectList(db.Certifications, "CertificationId", "CertificationName", knowledgeArea.CertificationId);
            return(View(knowledgeArea));
        }
예제 #25
0
        public ActionResult Create([Bind(Include = "JobAreaId,JobAreaName,JobFieldId")] JobFieldArea jobFieldArea)
        {
            if (ModelState.IsValid)
            {
                db.JobFieldAreas.Add(jobFieldArea);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.JobFieldId = new SelectList(db.JobFields, "JobFieldId", "JobFieldName", jobFieldArea.JobFieldId);
            return(View(jobFieldArea));
        }
        public ActionResult Create(AnswerChoice answerchoice)
        {
            if (ModelState.IsValid)
            {
                db.AnswerChoices.Add(answerchoice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "QuestionText", answerchoice.QuestionId);
            return(View(answerchoice));
        }
예제 #27
0
        public ActionResult Create([Bind(Include = "QuestionId,QuestionText,AnswerId")] Question question)
        {
            if (ModelState.IsValid)
            {
                db.Questions.Add(question);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AnswerId = new SelectList(db.Answers, "AnswerId", "AnswerText", question.AnswerId);
            return(View(question));
        }
예제 #28
0
        public ActionResult Create([Bind(Include = "QuestionId,CertificationId,KnowledgeAreaId,LanguageId,FullQuestion,AnswerOption1,AnswerOption2,AnswerOption3,AnswerOption4,CorrectAnswerIndex,Mark,AreaofKnowledge,AnswerExplanation,isDisplayOnly")] Question question)
        {
            if (ModelState.IsValid)
            {
                db.Questions.Add(question);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CertificationId = new SelectList(db.Certifications, "CertificationId", "CertificationName", question.CertificationId);
            ViewBag.KnowledgeAreaId = new SelectList(db.KnowledgeAreas, "KnowledgeAreaId", "KnowledgeAreaName", question.KnowledgeAreaId);
            ViewBag.LanguageId      = new SelectList(db.LanguageMasters, "LanguageId", "LanguageName", question.LanguageId);
            return(View(question));
        }
예제 #29
0
 public ActionResult Create([Bind(Include = "id,Question,A,B,C,D,CorrectAnswer,TopicId")] MCQuestion mCQuestion)
 {
     if (ModelState.IsValid)
     {
         var top = db.Topics.Find(mCQuestion.TopicId);
         mCQuestion.QuestionTopic = top;
         top.Questions.Add(mCQuestion);
         db.MCQuestions.Add(mCQuestion);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Topics = db.Topics.ToList();
     return(View(mCQuestion));
 }
예제 #30
0
        public ActionResult Create([Bind(Include = "QuestionId,QuestionLabel,QuestionType,EmployeeId,LevelId,LanguageId")] Question question)
        {
            if (ModelState.IsValid)
            {
                db.Questions.Add(question);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "LastName", question.EmployeeId);
            ViewBag.LanguageId = new SelectList(db.Languages, "LanguageID", "LanguageName", question.LanguageId);
            ViewBag.LevelId    = new SelectList(db.Levels, "LevelID", "Name", question.LevelId);
            return(View(question));
        }