public int AddQuestion(QuestionInfo question) { int level_ = AddLevel(question.Level); int topic_ = AddTopic(question.Topic); int question_ = AddQuestion(topic_, question.Question, level_, question.Info); return(question_); }
public int AddNewQuestion(QuestionInfo Question, IEnumerable <AnswerInfo> answer) { int level_ = AddLevel(Question.Level); int topic_ = AddTopic(Question.Topic); int question_ = AddQuestion(topic_, Question.Question, level_, Question.Info); foreach (var item in answer) { if (!string.IsNullOrWhiteSpace(item.Text)) { AddQuestionAnswer(question_, AddAnswer(item.Text), item.IsTrue); } } return(question_); }
public UserControlQuestion(QuestionInfo question, IEnumerable <AnswerInfo> answers, bool isCheck = false) { InitializeComponent(); id_question = question.ID; labelTopic.Text = question.Topic; labelQuestion.Text = question.Question; labeInfo.Text = question.Info; IsCheck = isCheck; foreach (AnswerInfo answer in answers) { if (!IsCheck) { CheckBox ch = new CheckBox(); ch.Margin = new Thickness(10); ch.Content = answer.Text; ch.FontSize = 16; ch.FontFamily = new FontFamily("Times New Roman"); StackAnswer.Children.Add(ch); Answers.Add(answer.ID, answer.Text);///???????????????????????? } else { Label ch = new Label(); ch.Margin = new Thickness(10); ch.Content = answer.Text; ch.FontSize = 16; ch.FontFamily = new FontFamily("Times New Roman"); if (answer.IsTrue) { ch.Background = Brushes.GreenYellow; } else { ch.Background = Brushes.Red; } StackAnswer.Children.Add(ch); } } }
public QuestionInfo GetQuestion(int id_question) { string command = "SELECT * FROM [QuestionView] WHERE id=" + id_question; SqlCommand cmd = new SqlCommand(command, connection); QuestionInfo question = null; using (var reader = cmd.ExecuteReader()) while (reader.Read()) { question = new QuestionInfo() { ID = id_question, Level = reader.GetString(1), Question = reader.GetString(2), Info = reader.IsDBNull(reader.GetOrdinal("info")) ? "": reader.GetString(3), Topic = reader.GetString(4) } } ; return(question); }
public UserControlNewQuestion(string Connection, int current, int all, QuestionInfo question, IEnumerable <AnswerInfo> answers) { InitializeComponent(); listView.ItemsSource = ans; Connect = Connection; if (question == null) { return; } ID = question.ID; textBoxLevel.Text = question.Level; textBoxTopic.Text = question.Topic; textBoxInfo.Text = question.Info; textBoxQuestion.Text = question.Question; labelID.Content = "№ " + question.ID; labelCurrent.Content = string.Format(@"{0}/{1}", (current + 1), all); foreach (var item in answers) { ans.Add(item); } }
public int UpdateQuestion(QuestionInfo info) { UpdateValue(TablesExam.Answer, info.ID, new FieldValue("IsNotUse", "true")); return(AddQuestion(info)); }