Exemplo n.º 1
0
        public ShortAnswerForPresentation(ShortAnswer question, bool answerTime, bool showAnswer)
        {
            this.stringItems = question.Answer;

            InitializeComponent();
            if (answerTime)
            {
                txtAnswer.Text     = question.UserAnswer;
                txtAnswer.ReadOnly = false;
                if (showAnswer)
                {
                    foreach (var i in stringItems)
                    {
                        txtAnswer.ReadOnly = true;
                        var lbl = new Label();
                        lbl.Width    = flowLayoutPanel1.Width;
                        lbl.Text     = i.Value;
                        lbl.AutoSize = true;
                        flowLayoutPanel1.Controls.Add(lbl);
                    }
                }
            }
            else
            {
                txtAnswer.Visible = false;
                foreach (var i in stringItems)
                {
                    var lbl = new Label();
                    lbl.Width    = flowLayoutPanel1.Width - 10;
                    lbl.Text     = i.Value;
                    lbl.AutoSize = true;
                    flowLayoutPanel1.Controls.Add(lbl);
                }
            }
        }
Exemplo n.º 2
0
        private bool RegisterShortAnswerQuestion(irQmDbContext db)
        {
            if (ucShortAnswer1.StringList.Count == 0)
            {
                lblMessage.Text      = "جواب مشخص نشده است";
                lblMessage.ForeColor = Color.Red;

                return(false);
            }
            var q = new ShortAnswer();

            q.Id   = Guid.NewGuid().ToString();
            q.Face = rbFace.Rtf;

            q.RegisterTime = DateTime.UtcNow;
            var tagsInBox = tagsBox1.Tags;
            var tags      = db.Tags.Select(t => t.Value).ToArray();

            foreach (var tg in tagsInBox.Where(t => !(tags.Contains(t))))
            {
                var tag = new Tag();
                tag.Value = tg;
                db.Tags.Add(tag);
            }
            foreach (var t in tagsInBox)
            {
                TagInQuestion <ShortAnswer> tagInQuestion = new TagInQuestion <ShortAnswer>();
                tagInQuestion.QuestionId = q.Id;
                tagInQuestion.TagId      = t;
                db.TagInShortAnswer.Add(tagInQuestion);
            }
            q.Answer = ucShortAnswer1.StringList;

            q.LessonName    = comboLesson.Text.Trim();
            q.CreatorUserId = Globals.CurrentUser.UserId;


            db.ShortAnswerQustions.Add(q);

            db.SaveChanges();


            ucShortAnswer1.New(new List <StringItem> {
                new StringItem(1), new StringItem(2), new StringItem(3)
            });


            return(true);
        }
Exemplo n.º 3
0
        // Saves question to test
        protected void btnSaveQuestion_Click(object sender, EventArgs e)
        {

            // Multiple choice question checked and saved
            if(rblChooseQuestion.SelectedValue == "Multiple Choice")
                if(txtMCQuestion.Text != String.Empty)
                    if (txtMC1.Text != String.Empty || txtMC2.Text != String.Empty || txtMC3.Text != String.Empty || txtMC4.Text != String.Empty)
                    {
                        Question newQuestion = new Question(questionCounter, Int32.Parse(ddlPointValue.SelectedValue), "Multiple Choice");

                        if(rdbMC1.Checked == true)
                        {
                            MultipleChoice newMCQuestion = new MultipleChoice(questionCounter, txtMCQuestion.Text, "A");
                        }
                        else if (rdbMC2.Checked == true)
                        {
                            MultipleChoice newMCQuestion = new MultipleChoice(questionCounter, txtMCQuestion.Text, "B");
                        }
                        else if (rdbMC3.Checked == true)
                        {
                            MultipleChoice newMCQuestion = new MultipleChoice(questionCounter, txtMCQuestion.Text, "C");
                        }
                        else
                        {
                            MultipleChoice newMCQuestion = new MultipleChoice(questionCounter, txtMCQuestion.Text, "D");
                        }

                        MultipleChoiceChoice MCOption1 = new MultipleChoiceChoice(questionCounter, 'A', txtMC1.Text);
                        MultipleChoiceChoice MCOption2 = new MultipleChoiceChoice(questionCounter, 'A', txtMC2.Text);
                        MultipleChoiceChoice MCOption3 = new MultipleChoiceChoice(questionCounter, 'A', txtMC3.Text);
                        MultipleChoiceChoice MCOption4 = new MultipleChoiceChoice(questionCounter, 'A', txtMC4.Text);

                        questionList.Add(newQuestion);
                    }

            // True False Question checked and saved
            if(rblChooseQuestion.SelectedValue == "True False")
                if(txtTFQuestion.Text != String.Empty)
                {
                    Question newQuestion = new Question(questionCounter,Int32.Parse(ddlPointValue.SelectedValue), "True/False");
                    TrueFalse newTFQuestion = new TrueFalse(questionCounter, txtTFQuestion.Text, rblTrueFalse.SelectedValue.ToString());
                    questionList.Add(newQuestion);
                }

            // Fill in the Blank question checked and saved
            if (rblChooseQuestion.SelectedValue == "Short Answer")
                if (txtFBAnswer.Text != String.Empty)
                {
                    Question newQuestion = new Question(questionCounter, Int32.Parse(ddlPointValue.SelectedValue), "Short Answer");
                    if (txtFBStatementBegin.Text != String.Empty && txtFBStatementEnd.Text != String.Empty)
                    {
                        ShortAnswer newSAQuestion = new ShortAnswer(questionCounter, txtFBStatementBegin.Text, txtFBAnswer.Text, txtFBStatementEnd.Text);
                    }
                    else if(txtFBStatementBegin.Text != String.Empty)
                    {
                        ShortAnswer newSAQuestion = new ShortAnswer(questionCounter, String.Empty, txtFBAnswer.Text, txtFBStatementEnd.Text);
                    }
                    else
                    {
                        ShortAnswer newSAQuestion = new ShortAnswer(questionCounter, txtFBStatementBegin.Text, txtFBAnswer.Text, String.Empty);
                    }
                    questionList.Add(newQuestion);
                }

            // Matching question checked and saved
            if(rblChooseQuestion.SelectedValue == "Matching")
            {
                if (txtSectionName.Text != String.Empty)
                {
                    Question newQuestion = new Question(questionCounter, Int32.Parse(ddlPointValue.SelectedValue), "Matching");
                    Matching newMatching = new Matching(questionCounter, txtSectionName.Text);
                    if (txtMQuestion1.Text != String.Empty && txtMAnswer1.Text != String.Empty)
                    {
                        MatchingQuestions newChoice1 = new MatchingQuestions(4, txtMQuestion1.Text, txtMAnswer1.Text);
                    }
                    if (txtMQuestion2.Text != String.Empty && txtMAnswer2.Text != String.Empty)
                    {
                        MatchingQuestions newChoice2 = new MatchingQuestions(4, txtMQuestion2.Text, txtMAnswer2.Text);
                    }
                    if (txtMQuestion3.Text != String.Empty && txtMAnswer3.Text != String.Empty)
                    {
                        MatchingQuestions newChoice3 = new MatchingQuestions(4, txtMQuestion3.Text, txtMAnswer3.Text);
                    }
                    if (txtMQuestion4.Text != String.Empty && txtMAnswer4.Text != String.Empty)
                    {
                        MatchingQuestions newChoice4 = new MatchingQuestions(4, txtMQuestion4.Text, txtMAnswer4.Text);
                    }
                    questionList.Add(newQuestion);
                }
            }

            // Essay question checked and saved
            if (rblChooseQuestion.SelectedValue == "Essay")
                if (txtEQuestion.Text != String.Empty)
                {
                    Question newQuestion = new Question(questionCounter, Int32.Parse(ddlPointValue.SelectedValue), "Essay");
                    Essay newEssayQuestion = new Essay(questionCounter, txtEQuestion.Text);
                    questionList.Add(newQuestion);
                }

            // tentative way to have unique questionIds
            questionCounter++;
        }