Ejemplo n.º 1
0
        private void ProceedQuestions()
        {
            if (Answer != null)
            {
                for (int i = 0; i < Respondent.RadioButtonHelp.Length; i++)
                {
                    if (Respondent.RadioButtonHelp[i])
                    {
                        Answer.Answer = i + 1;
                    }
                }
                Answer.HeartBeatEnd = Respondent.RR.Count - 1;
                Respondent.DilemmaAnswers.Add(Answer);
            }

            if (Position >= Questions.Count)
            {
                Stage          = "e";
                Position       = 0;
                SlidesForStage = Directory.GetFiles(wfolder, "e-*.xml");
            }
            else
            {
                Respondent.DTitle          = Questions[Position].Title;
                Respondent.DDilemmaText    = Questions[Position].Text;
                Respondent.DDilemaQuestion = Questions[Position].Question;

                for (int i = 0; i < 7; i++)
                {
                    Respondent.RadioButtonHelp[i] = false;
                }
                LoadForm(SlidesForStage[0]);
                Answer = new DilemmaAnswer()
                {
                    TimeStart = DateTime.Now, HeartBeatStart = Respondent.RR.Count - 1, Dilemma = Questions[Position].ID
                };
                Position++;
            }
        }
Ejemplo n.º 2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (dataGrid1.SelectedValue != null)
            {
                StringBuilder csv = new StringBuilder();
                csv.AppendLine("N, RR, Dilemma");

                DilemmaRespondent resp = (DilemmaRespondent)dataGrid1.SelectedValue;
                for (int n = 0; n < resp.RR.Count; n++)
                {
                    DilemmaAnswer answ = resp.DilemmaAnswers.Find(z => z.HeartBeatStart <= n && z.HeartBeatEnd >= n);
                    if (answ != null)
                    {
                        csv.AppendFormat("{0}, {1}, {2}\r\n", n, resp.RR[n], answ.Dilemma);
                    }
                    else
                    {
                        csv.AppendFormat("{0}, {1}, {2}\r\n", n, resp.RR[n], "0");
                    }
                }

                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName   = resp.fileName;                         //resp.ID + "_" + resp.Education + "_" + resp.Age + "_" + resp.CountryLive;
                dlg.DefaultExt = ".csv";                                // Default file extension
                dlg.Filter     = "Comma-separated values (.csv)|*.csv"; // Filter files by extension

                // Show save file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process save file dialog box results
                if (result == true)
                {
                    // Save document
                    string filename = dlg.FileName;
                    File.WriteAllText(filename, csv.ToString());
                }
            }
        }