Ejemplo n.º 1
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;

        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Questions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToQuestions(Question question)
 {
     base.AddObject("Questions", question);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new Question object.
 /// </summary>
 /// <param name="questionID">Initial value of the QuestionID property.</param>
 public static Question CreateQuestion(global::System.Int32 questionID)
 {
     Question question = new Question();
     question.QuestionID = questionID;
     return question;
 }