protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (RadioButtonList1.SelectedIndex == -1 || RadioButtonList1.SelectedIndex == -1 || RadioButtonList3.SelectedIndex == -1 || RadioButtonList4.SelectedIndex == -1 || RadioButtonList5.SelectedIndex == -1)
            {
                ScriptManager.RegisterClientScriptBlock(btnSubmit, this.GetType(), "alertMessage", "alert('Submit unsuccessfully!')", true);
            }
            else
            {
                int userid = Convert.ToInt32(Session["UserID"]);

                int Lesson010101 = Convert.ToInt32(RadioButtonList1.SelectedValue);
                int Lesson010102 = Convert.ToInt32(RadioButtonList2.SelectedValue);
                int Lesson010103 = Convert.ToInt32(RadioButtonList3.SelectedValue);
                int Lesson010104 = Convert.ToInt32(RadioButtonList4.SelectedValue);
                int Lesson010105 = Convert.ToInt32(RadioButtonList5.SelectedValue);

                lessonbl = new LessonBL();

                lessonbl.updateRate(userid, "010101", Lesson010101);
                lessonbl.updateRate(userid, "010102", Lesson010102);
                lessonbl.updateRate(userid, "010103", Lesson010103);
                lessonbl.updateRate(userid, "010104", Lesson010104);
                lessonbl.updateRate(userid, "010105", Lesson010105);

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Submit successfully!')", true);

                Response.Redirect("Lesson01/index.htm");
            }
        }
Beispiel #2
0
    /// <summary>
    /// Retrieve Lesson data by lesson ID.
    /// </summary>
    /// <param name="ID"></param>
    /// <returns></returns>
    private DataTable GetLesson(int ID)
    {
        LessonBL  lessonBL = new LessonBL();
        DataTable table    = lessonBL.GetLesson(LessonID);

        return(table);
    }
Beispiel #3
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();
        }
    }
    /// <summary>
    /// Create side navigation menu.
    /// </summary>
    private void BindSideMenu()
    {
        // Create an instance of lesson business logic.
        LessonBL lesson = new LessonBL();

        // Get all lessons available in table "Lesson"
        DataTable lessons = lesson.GetLessons();

        // Create an instance of UserLesson business logic.
        UserLessonBL userLesson = new UserLessonBL();

        DataTable userLessonTable = null;

        // If records are present in table Lesson.
        if (lessons.Rows.Count > 0)
        {
            // Loop through the lessons rows.
            foreach (DataRow row in lessons.Rows)
            {
                // Create a list item.
                HtmlGenericControl listItem = new HtmlGenericControl("li");

                // Create a link Button.
                LinkButton linkB = new LinkButton();

                // Get the lesson ID from the record.
                int lessonID = Convert.ToInt32(row["ID"]);

                // Get the record from "User_Lesson" table that contains the user ID and Lesson ID
                userLessonTable = userLesson.GetRecord(UserID, lessonID);

                // If the record is blank, means that the lesson is not complete by the user, so put a white very good image.
                if (userLessonTable.Rows.Count == 0)
                {
                    linkB.Text = "<img src=http://localhost:3787/image/c1.jpg> " + row[1].ToString();
                }
                // If the record does not contain a complete date it also means that the lesson is not complete.
                else if (userLessonTable.Rows[0].Field <DateTime?>("DateCompleted") == null)
                {
                    linkB.Text = "<img src=http://localhost:3787/image/c1.jpg> " + row[1].ToString();
                }
                // If there is the record with a complete date mark the link button with a green very good sign.
                else
                {
                    linkB.Text = "<img src=http://localhost:3787/image/c2.jpg> " + row[1].ToString();
                }

                // Add runat server attribute to the link button.
                linkB.Attributes.Add("runat", "server");
                // Pass the lesson ID to the link button.
                linkB.CommandArgument = lessonID.ToString();
                // Add the Redirect event.
                linkB.Click += new EventHandler(Redirect);

                // Add the link button to the list item.
                listItem.Controls.Add(linkB);

                // Add the list item to the unsorted list.
                navSideMenu.Controls.Add(listItem);
            }
        }
    }