private void RenderQuestion(Question question) { AddControlToCurrentPage(QLWidgetFactory.GetWidget( question.Label, _executor.GetAnswer(question.Id), _executor.IsReadOnly(question.Id), value => SetAnswer(question.Id, value) ).Render()); }
private void ExportAnswers(object sender, EventArgs e) { if (_executor == null || _executor.VisibleQuestions.Any(question => _executor.GetAnswer(question.Id).IsUndefined())) { MessageBox.Show(Resources.MainPresenter_ExportAnswers_Please_answer_all_questions_first_); return; } var saveDialog = new SaveFileDialog { InitialDirectory = Directory.GetCurrentDirectory(), Filter = Resources.MainPresenter_ExportAnswers_CSV_files____csv____csv }; if (saveDialog.ShowDialog() == DialogResult.OK) { FormExporter.ExportToCSV(_executor, saveDialog.FileName); } }
public static void ExportToCSV(QLExecutor executor, string path) { var lines = executor.VisibleQuestions.Select(question => EscapeCSV(question.Id) + ";" + EscapeCSV(executor.GetAnswer(question.Id).ToString())); var contents = string.Join("\n", lines); File.WriteAllText(path, contents); }