public Quiz() { quizPaper = new QuizPaper(); numberOfQuestions = 1; r = new Random(); questionPrototype = new List <String>(); }
public Evaluator(QuizPaper q) { this.quiz = q; numberOfQuestions = 0; correctAnswers = 0; attemptedQuestions = 0; percentageCorrect = 0; quizID = null; averageTime = 0; userID = null; evaluateQuiz(); }
protected void markForReview_Click(object sender, EventArgs e) { quiz = (ArithmeticHelper.QuizPaper)Cache[userID]; try { ArithmeticHelper.Question q = quiz.questionaire[quiz.presentQuestion]; q.markedForReview = true; quiz.questionaire[quiz.presentQuestion] = q; dataBindQuestionList(); Cache[userID] = quiz; } catch (SystemException) { Response.Redirect("Error.aspx"); } }
protected void next_Click(object sender, EventArgs e) { quiz = (ArithmeticHelper.QuizPaper)Cache[userID]; setTime(); previous.Enabled = true; previous0.Enabled = true; if (++quiz.presentQuestion == (quiz.questionaire.Count - 1)) { next.Enabled = false; next0.Enabled = false; } ArithmeticHelper.Question q = quiz.questionaire[quiz.presentQuestion]; q.markedForReview = false; quiz.questionaire[quiz.presentQuestion] = q; setLabels(); setVisibility(); Cache[userID] = quiz; }
protected void questionSelected(object sender, GridViewCommandEventArgs e) { if (e.CommandName != "selected") { return; } quiz = (ArithmeticHelper.QuizPaper)Cache[userID]; setTime(); quiz.presentQuestion = Convert.ToInt16(e.CommandArgument) + questionView.PageIndex * questionView.PageSize; ArithmeticHelper.Question q = quiz.questionaire[quiz.presentQuestion]; q.markedForReview = false; quiz.questionaire[quiz.presentQuestion] = q; if (quiz.presentQuestion == quiz.questionaire.Count - 1) { next.Enabled = false; next0.Enabled = false; } else { next0.Enabled = true; next.Enabled = true; } if (quiz.presentQuestion == 0) { previous0.Enabled = false; previous.Enabled = false; } else { previous.Enabled = true; previous0.Enabled = true; } setLabels(); setVisibility(); Cache[userID] = quiz; }
protected void options_SelectedIndexChanged(object sender, EventArgs e) { quiz = (ArithmeticHelper.QuizPaper)Cache[userID]; setTime(); quiz.questionsAnswered++; ArithmeticHelper.Question q = quiz.questionaire[quiz.presentQuestion]; q.setSelectedOption(options.SelectedIndex); if (q.selectedOption == q.options.IndexOf(q.answer)) { q.correct = 1; } else { q.correct = 0; } quiz.questionaire[quiz.presentQuestion] = q; result.ImageUrl = ImageURLS[quiz.questionaire.ElementAt(quiz.presentQuestion).correct]; time.Text = " Time : " + quiz.questionaire.ElementAt(quiz.presentQuestion).time + " (sec) "; setAnswerColor(); setVisibility(); Cache[userID] = quiz; }
public void updateQuiz(String quizID) { String answer, questionid, questionText; Question question; List <String> option; quizPaper = quizEngine.generateQuizPaper(@quizID, 1); selectQuestions = @"SELECT QuestionID FROM QuizQuestions WHERE (QuizID = '" + @quizID + @"') ORDER BY QOrder"; questionID = readQuestionID(); for (int i = 0; i < questionID.Count; i++) { questionid = questionID.ElementAt(i); question = quizPaper.questionaire.ElementAt(i); answer = question.answer; option = question.options; questionText = question.question; updateQuestionText(questionid, questionText); updateAnswer(questionid, answer); updateOptions(questionid, option); } }
protected void Page_Load(object sender, EventArgs e) { try { if (PreviousPage != null && PreviousPage.IsCrossPagePostBack == true) { String quizID; int num; ContentPlaceHolder c = (ContentPlaceHolder)PreviousPage.Master.FindControl("PageArea"); //System.Web.UI.WebControls.Panel c = (System.Web.UI.WebControls.Panel)PreviousPage.Master.FindControl("MainPanel"); quizName.Text = ((System.Web.UI.WebControls.Label)c.FindControl("quizName")).Text; quizID = ((System.Web.UI.WebControls.Label)c.FindControl("quizID")).Text; num = Convert.ToInt16(((System.Web.UI.WebControls.DropDownList)c.FindControl("numberOfQuestionsBox")).SelectedValue); userID = Session.SessionID + (new Random().Next()).ToString(); ViewState["userID"] = userID; if (quizID == "5968EB4B-C486-435e-B3A2-DEE504E6EFC9" || quizID == "E9AE0DB9-AD58-43e2-AFCD-7E407A549A75" || quizID == "66DD0945-258B-4016-B341-779496328F6D" || quizID == "86E245E0-C54E-4ada-AF27-B9044ADC08F2" || quizID == "3F691386-6107-4166-B5CF-F48532F1A6C7" || quizID == "498B1CD1-6F5B-4766-A08E-56EC007B8FF5") { ViewState["QuizType"] = "Time"; } else if (quizID == "75DD4361-B58B-4cc9-8572-00E0F7809F78" || quizID == "9371C7DB-A24B-4be1-9FEE-6B7A85DB400B" || quizID == "FF6D685A-ECE6-4c0c-A946-A22F3323ACAD" || quizID == "8629C229-097B-450e-B152-B6FBCD580C6A") { ViewState["QuizType"] = "Functions"; } else if (quizID == "F7AB6F95-69D3-4611-BED8-362857A3A65C" || quizID == "C850925C-A661-4990-93F3-2365988C8DFC" || quizID == "BA16694F-3034-49b2-B339-DB32AC84B674") { ViewState["QuizType"] = "Percentage"; } else if (quizID == "768022B5-9141-4574-9EB1-72D185F0FAF6" || quizID == "14E4FDF1-D8C9-4a95-A3E0-F856A2958330" || quizID == "E53B688A-37B4-4fa1-92C1-92BA6E80304F") { ViewState["QuizType"] = "Fractions"; } else if (quizID == "832A7AEC-5E92-42d7-BC76-CCFAE786D9A5" || quizID == "F4FC1BB7-6CFC-439a-9B8A-261251124622" || quizID == "CFA6B36D-95F3-4641-BFC7-D1C5C50068BC") { ViewState["QuizType"] = "Rounding"; } else if (quizID == "0EB2C22A-DDF4-4565-B97D-293795C31655") { ViewState["QuizType"] = "Discount"; } else { ViewState["QuizType"] = "Arithmetic"; } quiz = new ArithmeticHelper.QuizEngine().generateQuizPaper(quizID, num); previous.Enabled = false; previous0.Enabled = false; setLabels(); setVisibility(); quiz.stopWatch.Start(); Cache[userID] = quiz; } else if (Page.IsPostBack) { userID = ViewState["userID"].ToString(); quiz = (ArithmeticHelper.QuizPaper)Cache[userID]; if (quiz == null) { throw new SystemException(); } } else { Response.Redirect("MainPage.aspx"); } if (Request.Cookies["StudentMode"] == null) { Cache.Remove(userID); Response.Redirect("EnableCookie.aspx"); } } catch (SystemException) { Response.Redirect("Error.aspx"); } }