コード例 #1
0
        /// <summary>
        /// Initializes a new quiz object; necessary in case the control has not yet loaded.  This will discared any existing quiz.
        /// </summary>
        public void InitQuiz()
        {
            if (m_AirportQuiz == null)
            {
                m_AirportQuiz = new AirportQuiz {
                    BluffCount = m_BluffCount
                };

                ViewState[keyQuiz] = m_AirportQuiz;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // set up a timeout function, in case the timer goes.
            Page.ClientScript.RegisterClientScriptBlock(GetType(), "TimeOut", "function TimeOutExpired() {" + Page.ClientScript.GetPostBackEventReference(new PostBackOptions(btnSkip)) + ";}", true);

            if (!IsPostBack)
            {
                InitQuiz();
            }
            else
            {
                m_AirportQuiz = (AirportQuiz)ViewState[keyQuiz];

                // We've been getting this a few times; Session could have timed out, so reset things.
                if (m_AirportQuiz == null)
                {
                    InitQuiz();
                }

                if (mvQuiz.ActiveViewIndex == 1)  // taking the quiz
                {
                    Boolean fCorrectAnswer = (rbGuesses.SelectedIndex == m_AirportQuiz.CurrentQuestion.CorrectAnswerIndex);

                    if (m_AirportQuiz.CurrentQuestion.CorrectAnswerIndex >= 0)
                    {
                        pRunningScore.Visible = true;
                        lblCorrect.Visible    = fCorrectAnswer;
                        lblIncorrect.Visible  = !fCorrectAnswer;

                        lblPreviousAnswer.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.LocalizedText.AirportGameCorrectAnswer, m_AirportQuiz.CurrentQuestion.Answers[m_AirportQuiz.CurrentQuestion.CorrectAnswerIndex].FullName);
                    }

                    if (fCorrectAnswer)
                    {
                        m_AirportQuiz.CorrectAnswerCount += 1;
                    }

                    if (m_AirportQuiz.CorrectAnswerCount > 0)
                    {
                        lblRunningScore.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.LocalizedText.AirportGameAnswerStatus, m_AirportQuiz.CorrectAnswerCount);
                    }
                }
            }
        }