public void info() { if (treeView1.SelectedNode == null) return; oprosnikElem x = new oprosnikElem(); string find = treeView1.SelectedNode.Text; int nAnsw=0; for (int i=0; i<res.selectedOprosnik.elements.Count; i++) { if (res.selectedOprosnik.elements[i].question == find) { x = res.selectedOprosnik.elements[i]; nAnsw=i; break; } } dataGridView1.Rows.Clear(); for (int i = 0; i < x.answers.Count; i++) { dataGridView1.Rows.Add(new DataGridViewRow()); dataGridView1.Rows[i].Cells[0].Value = x.answers[i]; float temp = 0; foreach (var it in res.testers) { if (it.answers[nAnsw].SelectedAnswers[i] == true) temp++; } dataGridView1.Rows[i].Cells[1].Value = temp.ToString(); if(res.testers.Count!=0) temp = temp * 100 / res.testers.Count; dataGridView1.Rows[i].Cells[2].Value = temp.ToString(); } }
public questionAdd(oprosnikElem elem) { InitializeComponent(); result = new oprosnikElem(); result.answers = elem.answers; result.IsOneVariant = elem.IsOneVariant; result.question = elem.question; textBox1.Text = result.question; foreach (string temp in result.answers) { richTextBox1.Text += temp + Environment.NewLine; } checkBox1.Checked = result.IsOneVariant; }
int infoAnsw(OOo.sheet.XSpreadsheet f, int stroka, string find) { oprosnikElem x = new oprosnikElem(); int nAnsw = 0; for (int i = 0; i < res.selectedOprosnik.elements.Count; i++) { if (res.selectedOprosnik.elements[i].question == find) { x = res.selectedOprosnik.elements[i]; nAnsw = i; break; } } for (int i = 0; i < x.answers.Count; i++) { SetText(f, 0, stroka, x.answers[i]); float temp = 0; foreach (var it in res.testers) { if (it.answers[nAnsw].SelectedAnswers[i] == true) temp++; } SetText(f, 1, stroka, temp.ToString()); if (res.testers.Count != 0) temp = temp * 100 / res.testers.Count; SetText(f, 2, stroka, temp.ToString()); stroka++; } return stroka; }
public bool load(string way) { try { FileStream fs = new FileStream(way, FileMode.Open); using (StreamReader sw = new StreamReader(fs)) { string temp=""; temp=sw.ReadLine(); if (temp != "!realOprosFile!") return false; maxTesters = Convert.ToInt32(sw.ReadLine()); temp = sw.ReadLine(); while (temp != "!endDescr!") { Description += temp+Environment.NewLine; temp = sw.ReadLine(); } IsAnonimus = Convert.ToBoolean(sw.ReadLine()); temp = sw.ReadLine(); while (temp != "!endGenAnketa!") { anketa.Add(temp); temp = sw.ReadLine(); } temp = sw.ReadLine(); while (temp != "!oprosnik!") { tester t = new tester(); while (temp != "!next!") { while (temp != "!endAnketa!") { t.anketa.Add(temp); temp = sw.ReadLine(); } temp = sw.ReadLine(); while (temp != "!next!") { if (temp != "!next!") { List<bool> variant = new List<bool>(); while (temp != "!newAnsw!") { if (temp == "+") variant.Add(true); else variant.Add(false); temp = sw.ReadLine(); } t.answers.Add(new answer(variant)); temp = sw.ReadLine(); } } } temp = sw.ReadLine(); testers.Add(t); } temp = sw.ReadLine(); while (temp != "!END!") { oprosnikElem x = new oprosnikElem(); x.IsOneVariant = Convert.ToBoolean(temp); x.question = sw.ReadLine(); temp = sw.ReadLine(); while (temp != "!next!") { x.answers.Add(temp); temp = sw.ReadLine(); } temp = sw.ReadLine(); selectedOprosnik.elements.Add(x); } } } catch (Exception ex) { MessageBox.Show("Ошибка при загрузке" + Environment.NewLine + ex.Message); } return true; }