void ReadList() { if (createQuestionCounter == questionBlock.Count) { QuestionBlock questionBloc = new QuestionBlock(); questionBloc.id = questionBlock.Count; questionBloc.Text = WriteTextBox("Test"); questionBloc.Answers = new List <Answer>(); // MessageBox.Show("as"+AsciCounter.ToString()); for (int i = 0; i < AsciCounter; i++) { Answer answer = new Answer(); answer.id = i; answer.Text = WriteTextBoxAnswer($"{i}"); questionBloc.Answers.Add(answer); } questionBlock.Add(questionBloc); } else { questionBlock[createQuestionCounter].id = createQuestionCounter; questionBlock[createQuestionCounter].Text = WriteTextBox("Test"); for (int i = 0; i < questionBlock[createQuestionCounter].Answers.Count; i++) { questionBlock[createQuestionCounter].Answers[i].id = i; questionBlock[createQuestionCounter].Answers[i].Text = WriteTextBoxAnswer($"{i}"); // MessageBox.Show(questionBlock[createQuestionCounter].Answers[i].Text); } //if(questionBlock[createQuestionCounter].Answers.Count<AsciCounter) //{ // QuestionBlock questionBloc = new QuestionBlock(); // questionBloc.id = questionBlock.Count; // questionBloc.Text = WriteTextBox("Test"); // questionBloc.Answers = new List<Answer>(); // for (int i = 0; i < questionBlock[createQuestionCounter].Answers.Count-AsciCounter; i++) // { // Answer answer = new Answer(); // answer.id = i; // answer.Text = WriteTextBoxAnswer($"{i}"); // questionBloc.Answers.Add(answer); // } // questionBlock.Add(questionBloc); //} //if (questionBlock[createQuestionCounter].Answers.Count > AsciCounter) //{ // for (int i = AsciCounter-1; i < questionBlock[createQuestionCounter].Answers.Count - AsciCounter; i++) // { // questionBlock[createQuestionCounter - 1].Answers.Remove(questionBlock[createQuestionCounter].Answers[i]); // } //} } foreach (var item in questionBlock[0].Answers) { // MessageBox.Show(item.Text); } }
private void submitBtn_Click(object sender, EventArgs e) { submitBtn.Visible = false; acceptBtn.Visible = false; CircleProgressBar.Visible = false; pageLbl.Visible = false; CorrectLbl.Visible = true; inCorrectLbl.Visible = true; notAnsweredLbl.Visible = true; CorrectLbl.Text = $"Correct Answers {result.correct.ToString()}"; inCorrectLbl.Text = $"Incorrect Answers {result.incorrect.ToString()}"; notAnsweredLbl.Text = $"Not Answered {result.notAnswered.ToString()}"; //report report += $"{CorrectLbl.Text} - {inCorrectLbl.Text} - {notAnsweredLbl.Text}\n\n"; submited = true; nextPage.Location = new Point(nextPage.Location.X, nextPage.Location.Y + nextPage.Height); previousPage.Location = new Point(previousPage.Location.X, previousPage.Location.Y + previousPage.Height); if (result.notAnswered == questionsBlock.Count) { questionRctxtbx.Text = ""; QuestionPanel.Controls.Clear(); return; } //report foreach (var item in result.QuestionsAndAnswers) { QuestionBlock tmp = questionsBlock.Find(x => x.id == item.Key); report += "\n========================================\n"; report += $"Question ID:{tmp.id}) {tmp.Text.Replace("\n", "")}\n\n"; foreach (var answer in tmp.Answers) { report += $"Answer ID:{answer.id}. {answer.Text.Replace("\n", "")} "; if (answer.id == item.Value) { report += "<--Your answer"; } if (answer.IsCorrect == "Yes") { report += "<--Right answer "; } report += "\n"; } report += "\n========================================\n"; } // currentQuestion = 0; nextPage.PerformClick(); LoadQuestions(); }
private void AddBtn_Click(object sender, EventArgs e) { if (CheckFields()) { ID++; QuestionBlock question = new QuestionBlock { Text = QuestionTxtBx.Text, id = ID }; Answer a = new Answer { id = 0, IsCorrect = CheckTrueAnswer(vARbtn), Text = vATxtBx.Text }; Answer b = new Answer { id = 1, IsCorrect = CheckTrueAnswer(vBRbtn), Text = vBTxtBx.Text }; Answer c = new Answer { id = 2, IsCorrect = CheckTrueAnswer(vCRbtn), Text = vCTxtBx.Text }; Answer d = new Answer { id = 3, IsCorrect = CheckTrueAnswer(vDRbtn), Text = vDTxtBx.Text }; question.Answers.Add(a); question.Answers.Add(b); question.Answers.Add(c); question.Answers.Add(d); questions.Add(question); MessageBox.Show("Question Sucsessfully added to list"); ClearAllFields(); SaveBtn.Enabled = true; } else { MessageBox.Show("Fill Fields"); } }
public addQuestionUC(QuestionBlock question) { InitializeComponent(); text = question.Text; this.id = question.id; foreach (var item in question.Answers) { createAnswerUC uc1 = new createAnswerUC(item.IsCorrect, item.Text, item.id); uc1.delete += refreshId; uc1.delete += deleteAnswer; uc1.changed += RightAnswerSelected; answersPanel.Controls.Add(uc1); answerID++; } staticID++; setQuestionBlock(); }
void ReadList() { string CorrectName = ControlRadioButton(); if (createQuestionCounter == questionBlock.Count) { QuestionBlock questionBloc = new QuestionBlock(); questionBloc.id = questionBlock.Count; questionBloc.Text = WriteTextBox("Test"); questionBloc.Answers = new List <Answer>(); for (int i = 0; i < AsciCounter; i++) { Answer answer = new Answer(); answer.id = i; answer.Text = WriteTextBoxAnswer($"{i}"); questionBloc.Answers.Add(answer); if (CorrectName == i.ToString()) { answer.IsCorrect = "Yes"; } else { answer.IsCorrect = "No"; } } questionBlock.Add(questionBloc); } else { // if (questionBlock[createQuestionCounter].Answers.Count < AsciCounter) // { QuestionBlock questionBloc = new QuestionBlock(); questionBloc.id = questionBlock.Count; questionBloc.Text = WriteTextBox("Test"); questionBloc.Answers = new List <Answer>(); for (int i = 0; i < AsciCounter; i++) { Answer answer = new Answer(); answer.id = i; answer.Text = WriteTextBoxAnswer($"{i}"); questionBloc.Answers.Add(answer); if (CorrectName == i.ToString()) { answer.IsCorrect = "Yes"; } else { answer.IsCorrect = "No"; } } questionBlock[createQuestionCounter] = questionBloc; // } //if (questionBlock[createQuestionCounter].Answers.Count > AsciCounter) //{ // QuestionBlock questionBloc = new QuestionBlock(); // questionBloc.id = questionBlock.Count; // questionBloc.Text = WriteTextBox("Test"); // questionBloc.Answers = new List<Answer>(); // for (int i = 0; i < AsciCounter; i++) // { // Answer answer = new Answer(); // answer.id = i; // answer.Text = WriteTextBoxAnswer($"{i}"); // questionBloc.Answers.Add(answer); // if (CorrectName == i.ToString()) // { // answer.IsCorrect = "Yes"; // } // else // { // answer.IsCorrect = "No"; // } // } // questionBlock[createQuestionCounter] = questionBloc; //} } //foreach (var item in questionBlock[createQuestionCounter].Answers) //{ // MessageBox.Show(item.Text); //} }