示例#1
0
        //adds a question to the question list box
        private void addButton_Click(object sender, EventArgs e)
        {
            if (questionTextBox.Text == string.Empty || choice1TextBox.Text == string.Empty ||
                choice2TextBox.Text == string.Empty || choice3TextBox.Text == string.Empty ||
                choice4TextBox.Text == string.Empty)
            {
                MessageBox.Show("Please make sure all fields are entered");
                return;
            }

            //new data in a Question object
            // put question data in a DataEntryEventArgs object
            Question tmpQuestion = new Question(questionTextBox.Text, choice1TextBox.Text, choice2TextBox.Text,
                                                choice3TextBox.Text, choice4TextBox.Text, feedbackTextBox.Text, correctChoiceComboBox.SelectedIndex.ToString());
            DataEntryEventArgs tmpArgs = new DataEntryEventArgs(tmpQuestion);

            //clears the data in the text box so a new question can be added
            if (NewQuestionCreated != null)
            {
                NewQuestionCreated(this, tmpArgs);
                questionTextBox.Clear();
                choice1TextBox.Clear();
                choice2TextBox.Clear();
                choice3TextBox.Clear();
                choice4TextBox.Clear();
                correctChoiceComboBox.SelectedItem = 1;
                feedbackTextBox.Clear();
                questionTextBox.Focus();
            }
        }
示例#2
0
        private void DataForm_NewQuestionCreated(object sender, EventArgs e)
        {
            DataEntryEventArgs tmpArgs = new DataEntryEventArgs(null);

            //downcast to add the new question to the listbox
            if (e is DataEntryEventArgs)
            {
                tmpArgs = (DataEntryEventArgs)e;
                Question tmpQuestion = tmpArgs.Question;
                questonlist.Add(tmpQuestion);
            }
        }
示例#3
0
        //updates the question and displays the question updated in the status label
        private void UpdateForm_QuestionUpdated(object sennder, EventArgs e)
        {
            if (e is DataEntryEventArgs)
            {
                DataEntryEventArgs tmpArgs     = (DataEntryEventArgs)e;
                Question           tmpQuestion = tmpArgs.Question;
                statusLabel.Text = $"Question Updated - {tmpQuestion.MyQuestion}";
                timer1.Enabled   = true;

                questonlist.ResetBindings();
            }
        }
示例#4
0
        //edits the question
        private void editButton_Click(object sender, EventArgs e)
        {
            Question tmpQuestion = new Question(questionTextBox.Text, choice1TextBox.Text, choice2TextBox.Text,
                                                choice3TextBox.Text, choice4TextBox.Text, feedbackTextBox.Text, correctChoiceComboBox.SelectedIndex.ToString());

            Question.MyQuestion    = questionTextBox.Text;
            Question.Choice[0]     = choice1TextBox.Text;
            Question.Choice[1]     = choice2TextBox.Text;
            Question.Choice[2]     = choice3TextBox.Text;
            Question.Choice[3]     = choice4TextBox.Text;
            Question.Feedback      = feedbackTextBox.Text;
            Question.CorrectChoice = correctChoiceComboBox.SelectedIndex.ToString();

            DataEntryEventArgs tmpArgs = new DataEntryEventArgs(tmpQuestion);

            if (QuestionUpdated != null)
            {
                QuestionUpdated(this, tmpArgs);
            }
            this.Close();
        }