Beispiel #1
0
        private void NewTimingRun()
        {
            CurrentTiming = new SurveyTiming();

            ChangeSurvey("JP4");

            RefreshCurrentRecord();
        }
Beispiel #2
0
        // TODO finishthis
        public frmSurveyTiming(SurveyTiming timing)
        {
            InitializeComponent();

            loading = true;
            bs      = new BindingSource();
            bsRun   = new BindingSource();
            bindingNavigator1.BindingSource = bs;

            CustomList = new List <string>();
            DoCustomList();

            CurrentTiming = timing;


            //ChangeSurvey(timing.SurveyCode);

            RefreshCurrentRecord();

            // bindings
            bsRun.DataSource = CurrentTiming;

            cboSurvey.DataSource   = DBAction.GetSurveyList();
            cboSurvey.SelectedItem = null;
            cboSurvey.DataBindings.Add(new Binding("SelectedItem", bsRun, "SurveyCode"));

            txtTimingTitle.DataBindings.Add("Text", bsRun, "Title", true, DataSourceUpdateMode.OnPropertyChanged);
            txtKnownWPM.DataBindings.Add(new Binding("Text", bsRun, "WPM"));
            txtStartAt.DataBindings.Add(new Binding("Text", bsRun, "StartQ"));
            txtNotes.DataBindings.Add(new Binding("Text", bsRun, "Notes"));

            rbKnownWPM.Checked = true;

            txtVarName.DataBindings.Clear();
            txtVarName.DataBindings.Add("Text", bs, "VarName.FullVarName");

            txtQnum.DataBindings.Clear();
            txtQnum.DataBindings.Add("Text", bs, "Qnum");

            txtWeight.DataBindings.Clear();
            txtWeight.DataBindings.Add("Text", bs, "Weight.Value");

            txtWeightSource.DataBindings.Clear();
            txtWeightSource.DataBindings.Add("Text", bs, "Weight.Source");

            cboSurvey.SelectedIndexChanged += cboSurvey_SelectedIndexChanged;
            bs.CurrentChanged += Bs_CurrentChanged;
            loading            = false;
        }
Beispiel #3
0
        private void GetSavedRuns(string savedRunFolder)
        {
            string[] files;

            if (Directory.Exists(savedRunFolder))
            {
                files = Directory.GetFiles(savedRunFolder, "*.xml");
            }
            else
            {
                MessageBox.Show("Directory " + savedRunFolder + " not found.");
                return;
            }

            foreach (string f in files)
            {
                Timing      run     = new Timing();
                XmlDocument runData = new XmlDocument();

                ListViewItem lvi = new ListViewItem();
                listView1.View = View.Details;
                runData.LoadXml(File.ReadAllText(f));
                string scheme = runData.SelectSingleNode("/SurveyTiming").Attributes["TimingScheme"].InnerText;

                if (scheme.Equals("WholeSurvey"))
                {
                    SurveyTiming timing = new SurveyTiming(File.ReadAllText(f));
                    SavedRuns.Add(timing);
                    lvi = new ListViewItem(new string[] { timing.Title, "Method 3" });
                }
                else if (scheme.Equals("TimingUser"))
                {
                    UserTiming timing = new UserTiming(File.ReadAllText(f));
                    SavedRuns.Add(timing);
                    lvi = new ListViewItem(new string[] { timing.Title, "Method 2" });
                }
                else
                {
                    continue;
                }

                listView1.Items.Add(lvi);
            }
        }
Beispiel #4
0
        // TODO
        private void method3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // get path
            var filePath = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = TimingFolder;
                openFileDialog.Filter           = "XML Documents (*.xml)|*.xml";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;
                }
            }

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }


            try
            {
                SurveyTiming    run = new SurveyTiming(File.ReadAllText(filePath));
                frmSurveyTiming frm = new frmSurveyTiming(run);
                frm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid saved run.");
                return;
            }
        }
Beispiel #5
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // get path
            var filePath = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = GetFilePath();
                openFileDialog.Filter           = "XML Documents (*.xml)|*.xml";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;
                }
            }

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            loading = true;

            CurrentTiming = new SurveyTiming(File.ReadAllText(filePath));

            bsRun.DataSource = CurrentTiming;
            bs.DataSource    = CurrentTiming.Questions;

            // bsRun.ResetBindings(true);
            RefreshLists();
            UpdateTiming();

            loading = false;
        }
Beispiel #6
0
        private void CompareTimingRuns(SurveyTiming time1, SurveyTiming time2)
        {
            DataTable dt = new DataTable();

            string description1 = time1.Title;
            string description2 = time2.Title;

            dt.Columns.Add(new DataColumn(description1 + " VarName"));
            dt.Columns.Add(new DataColumn(description1 + " Word Count"));
            dt.Columns.Add(new DataColumn(description1 + " Weight"));
            dt.Columns.Add(new DataColumn(description1 + " Weight Source"));

            dt.Columns.Add(new DataColumn(description2 + " VarName"));
            dt.Columns.Add(new DataColumn(description2 + " Word Count"));
            dt.Columns.Add(new DataColumn(description2 + " Weight"));
            dt.Columns.Add(new DataColumn(description2 + " Weight Source"));



            foreach (LinkedQuestion q in time1.Questions)
            {
                DataRow r      = dt.NewRow();
                int     words1 = q.WordCount(time1.IncludeNotes);
                r[description1 + " VarName"]       = q.VarName.RefVarName;
                r[description1 + " Word Count"]    = words1;
                r[description1 + " Weight"]        = q.Weight.Value;
                r[description1 + " Weight Source"] = q.Weight.Source;

                var match = time2.Questions.FirstOrDefault(x => x.VarName.RefVarName.Equals(q.VarName.RefVarName));
                if (match != null)
                {
                    r[description2 + " VarName"] = match.VarName.RefVarName;
                    int words2 = match.WordCount(time2.IncludeNotes);
                    if (words2 != words1)
                    {
                        r[description2 + " Word Count"] = "[brightgreen]" + words2 + "[/brightgreen]";
                    }
                    else
                    {
                        r[description2 + " Word Count"] = words2;
                    }

                    if (match.Weight.Value != q.Weight.Value)
                    {
                        r[description2 + " Weight"] = "[brightgreen]" + match.Weight.Value + "[/brightgreen]";
                    }
                    else
                    {
                        r[description2 + " Weight"] = match.Weight.Value;
                    }

                    if (match.Weight.Source != q.Weight.Source)
                    {
                        r[description2 + " Weight Source"] = "[brightgreen]" + match.Weight.Source + "[/brightgreen]";
                    }
                    else
                    {
                        r[description2 + " Weight Source"] = match.Weight.Source;
                    }
                }

                dt.Rows.Add(r);
            }

            List <LinkedQuestion> time2Only = time2.Questions.Except(time1.Questions, new LinkedQuestionComparer()).ToList();

            foreach (LinkedQuestion q in time2Only)
            {
                DataRow r = dt.NewRow();
                r[description2 + " VarName"]       = q.VarName.RefVarName;
                r[description2 + " Word Count"]    = q.WordCount(time2.IncludeNotes);
                r[description2 + " Weight"]        = q.Weight.Value;
                r[description2 + " Weight Source"] = q.Weight.Source;
                dt.Rows.Add(r);
            }


            OutputReport(dt, time1.Title + " vs. " + time2.Title);

            //// GET ADDED QS
            //List<LinkedQuestion> time1Only = time1.Questions.Except(time2.Questions).ToList();

            //double time1Time = time1Only.Sum(x => x.Weight.Value * x.GetTiming(time1.WPM, time1.IncludeNotes));

            //// GET REMOVED QS
            //List<LinkedQuestion> time2Only = time2.Questions.Except(time1.Questions).ToList();

            //double time2Time = time2Only.Sum(x => x.Weight.Value * x.GetTiming(time1.WPM, time1.IncludeNotes));

            //// for commons compare wording counts
            //List<LinkedQuestion> commonTime1 = time1.Questions.Intersect(time2.Questions).ToList();
            //List<LinkedQuestion> commonTime2 = time2.Questions.Intersect(time1.Questions).ToList();

            //foreach (LinkedQuestion q in commonTime1)
            //{

            //}

            //lblResults.Text = time1Only.Count() + " questions appear only in " + time1.Title + " totalling " + time1Time + " mins";
            //lblResults.Text += "\r\n" + time2Only.Count() + " questions appear only in " + time2.Title + " totalling " + time2Time + " mins";
        }