Ejemplo n.º 1
0
    /// <summary>
    /// Binds data to the page.
    /// </summary>
    /// <param name="topicID"></param>
    private void BindQuestions()
    {
        LessonBL  lessonBL = new LessonBL();
        DataTable table    = lessonBL.GetLesson(LessonID);

        lblLessonTitle.Text = table.Rows[0].Field <string>("Title");


        AnswerBL answerBL = new AnswerBL();


        // Check that the number of questions are 5 before binding to labels.
        if (Questions.Rows.Count == 5)
        {
            lblViewQ0.Text  = Questions.Rows[0].Field <string>("Question");
            ViewState["Q0"] = Questions.Rows[0].Field <int>("TopicID");

            // Get the question answer and distractors.
            chkQuizList0.DataSource     = answerBL.GetAnswersByQuestionID(Questions.Rows[0].Field <int>("QuestionID"));
            chkQuizList0.DataTextField  = "Text";
            chkQuizList0.DataValueField = "Correct";
            chkQuizList0.DataBind();

            lblViewQ1.Text              = Questions.Rows[1].Field <string>("Question");
            ViewState["Q1"]             = Questions.Rows[1].Field <int>("TopicID");
            chkQuizList1.DataSource     = answerBL.GetAnswersByQuestionID(Questions.Rows[1].Field <int>("QuestionID"));
            chkQuizList1.DataTextField  = "Text";
            chkQuizList1.DataValueField = "Correct";
            chkQuizList1.DataBind();

            lblViewQ2.Text              = Questions.Rows[2].Field <string>("Question");
            ViewState["Q2"]             = Questions.Rows[2].Field <int>("TopicID");
            chkQuizList2.DataSource     = answerBL.GetAnswersByQuestionID(Questions.Rows[2].Field <int>("QuestionID"));
            chkQuizList2.DataTextField  = "Text";
            chkQuizList2.DataValueField = "Correct";
            chkQuizList2.DataBind();

            lblViewQ3.Text              = Questions.Rows[3].Field <string>("Question");
            ViewState["Q3"]             = Questions.Rows[3].Field <int>("TopicID");
            chkQuizList3.DataSource     = answerBL.GetAnswersByQuestionID(Questions.Rows[3].Field <int>("QuestionID"));
            chkQuizList3.DataTextField  = "Text";
            chkQuizList3.DataValueField = "Correct";
            chkQuizList3.DataBind();

            lblViewQ4.Text              = Questions.Rows[4].Field <string>("Question");
            ViewState["Q4"]             = Questions.Rows[4].Field <int>("TopicID");
            chkQuizList4.DataSource     = answerBL.GetAnswersByQuestionID(Questions.Rows[4].Field <int>("QuestionID"));
            chkQuizList4.DataTextField  = "Text";
            chkQuizList4.DataValueField = "Correct";
            chkQuizList4.DataBind();
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Retrieves the answers of a question.
    /// </summary>
    /// <param name="questionID"></param>
    /// <returns></returns>
    private DataTable GetAnswers(int questionID)
    {
        AnswerBL answerBL = new AnswerBL();

        return(answerBL.GetAnswersByQuestionID(questionID));
    }