void setQuestion() { Reset(); lbscore.Text = score.ToString(); if (quizzes.Count > 0) { qNumber++; lbnumber.Text = qNumber.ToString(); int quizNumb = _random.Next(0, quizzes.Count); quiz = quizzes[quizNumb]; lbquestion.Text = quiz.Question_Text; op1.Text = quiz.OptionA; op2.Text = quiz.OptionB; op3.Text = quiz.OptionC; op4.Text = quiz.OptionD; if (quizType == "Flag") { pictureBox1.Image = Image.FromFile("flags/" + quiz.Answer + ".png"); } } else { MessageBox.Show("Thank you, Your score is : " + score + ". Your score has been saved..!"); QuizScore qscore = new QuizScore(); qscore.UserId = Global.LoggedInUserId; qscore.Score = score; qscore.QuizDate = DateTime.Now; Entities.QuizScores.Add(qscore); Entities.SaveChanges(); btnMenu.Enabled = true; } }
public void PostQuizScore(int Spelerid, QuizScore Q) { Speler speler = _context.Spelers.FirstOrDefault(sp => sp.Id == Spelerid); if (Q != null) { speler.quizScore = Q; _context.SaveChanges(); } }
public async Task <ActionResult> AddRating(IFormCollection collection, QuizScore qz) { try { Rating rtSelf = qz.rating; rtSelf.UserId = Guid.Parse(_userManager.GetUserId(User)); var result = await _ratingRepo.AddRatingAsync(rtSelf); return(View("AccceptRating")); } catch (Exception) { throw; } }
public JsonResult SaveQuizTry(string[] answerStrings, List <Question> questions, int quizId) { var answers = answerStrings.Select(x => x.Substring(x.IndexOf(' ') + 1)).ToList(); int score = questions.Where((t, i) => t.Answer.Equals(answers[i])).Count(); UserManager <ApplicationUser> userManager = LMSRepo.GetUserManager(); QuizScore scrQuizScore = new QuizScore { Score = score, QuizUser = userManager.FindById(User.Identity.GetUserId()), QuizInformation = LMSRepo.GetQuizInformationById(quizId) }; LMSRepo.AddNewQuizScore(scrQuizScore); return(Json(new { response = score })); }
public void PostQuizScore(int Spelerid, QuizScore Q) { throw new NotImplementedException(); }
public async Task <ActionResult> NextQuestion(string quizName, Guid quizId, int qstnIndex, DateTime date, bool correct, int score) { try { var qstnList = await _questionRepo.GetQuestionsQuiz(quizId); if (correct) { TimeSpan timeDiff = DateTime.Now.Subtract(date); if (timeDiff.TotalSeconds > 30 && timeDiff.TotalSeconds < 0) { } else { if (score >= (qstnList.Count() * 300)) { score = 0; } else { int stp1 = 30 - Convert.ToInt32(timeDiff.TotalSeconds); score = score + (stp1 * 10); } } } else { } fullQuiz fq = new fullQuiz() { quizName = quizName, quizId = quizId, QuestionIndex = qstnIndex }; fq.QuestionIndex += 1; if (fq.QuestionIndex >= qstnList.Count()) { // add score to database Scores newscore = new Scores() { AppUserId = _userManager.GetUserId(User), QuizId = fq.quizId, Date = DateTime.Now }; Quiz qz = await _quizRepo.GetQuizById(fq.quizId); QuizScore qzsc = new QuizScore() { score = newscore, quiz = qz }; ViewBag.score = score; return(View("EndQuiz", qzsc)); } else { var qstnSelf = qstnList.ToList()[fq.QuestionIndex]; var ansListIe = await _answerRepo.GetAnswersForQuestion(qstnSelf.Id); var ansList = ansListIe.ToList(); fq.quizQuestion = qstnSelf; fq.answers = ansList; ViewBag.score = score; return(View("PlayQuiz", fq)); } } catch (Exception) { throw; } }
public ActionResult PostScore(int SpelerId, [FromBody] QuizScore score) { spelerService.PostQuizScore(SpelerId, score); return(Ok()); }
public void PostQuizScore(QuizScore Q) { _context.QuizScores.Add(Q); _context.SaveChanges(); }
public void AddNewScore(QuizScore Q) { _quizScoreRepo.PostQuizScore(Q); }
public void AddNewQuizScore(QuizScore score) { db.QuizScores.Add(score); db.SaveChanges(); }
public void PostQuizScore(int Spelerid, QuizScore Q) { _spelerRepo.PostQuizScore(Spelerid, Q); }
public ActionResult postScore([FromBody] QuizScore Q) { quizScoreService.AddNewScore(Q); return(Ok()); }