/// <summary>
 /// Create a new QuestionMcq object.
 /// </summary>
 /// <param name="questionID">Initial value of the QuestionID property.</param>
 public static QuestionMcq CreateQuestionMcq(global::System.Int32 questionID)
 {
     QuestionMcq questionMcq = new QuestionMcq();
     questionMcq.QuestionID = questionID;
     return questionMcq;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the QuestionMcqs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToQuestionMcqs(QuestionMcq questionMcq)
 {
     base.AddObject("QuestionMcqs", questionMcq);
 }
Esempio n. 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ExamDbModel.ExamDbEntities x = new ExamDbModel.ExamDbEntities();

        int index = int.Parse(RadioButtonList1.SelectedValue);
        ExamDbModel.Question que=new ExamDbModel.Question();
        que.QuestionText= txtQuestion.Text;
        que.ChapterID= int.Parse(txtChapter.SelectedValue);
        x.AddToQuestions(que);
        x.SaveChanges();
        switch (index)
        {
            case 0:
                //Blank
                ExamDbModel.QuestionBlank blank = new ExamDbModel.QuestionBlank();

                blank.CorrectAnswer = BlankAns.Text;
                blank.QuestionID = que.QuestionID;
                x.AddToQuestionBlanks(blank);
                x.SaveChanges();
                Label1.Text = "BlankRequestion is added";

                //Fill the grid
                BindBlanks();
                break;
            case 1:
                //Bool

                ExamDbModel.QuestionBool boool = new ExamDbModel.QuestionBool();
                boool.QuestionID = que.QuestionID;
                boool.Answer1 = BoolAns1.Text;
                boool.Answer2 = BoolAns2.Text;
                boool.CorrectAnswer = BoolAns.Checked;
                x.AddToQuestionBools(boool);
                x.SaveChanges();

                Label1.Text = "BoolQequestion is added";
                BindBool();
                break;
            case 2:
                //MCQ

                ExamDbModel.QuestionMcq mcq = new ExamDbModel.QuestionMcq();
                mcq.QuestionID = que.QuestionID;
                mcq.Answer1 = McaA1.Text;
                mcq.Answer2 = McqA2.Text;
                mcq.Answer3 = McqA3.Text;
                mcq.Answer4 = McqA4.Text;
                mcq.CorrectAnswer = McqCorrect.Text;

                x.AddToQuestionMcqs(mcq);
                x.SaveChanges();

                Label1.Text = "MCQQuestion is added";
                BindMCQ();
                break;

        }
    }