Ejemplo n.º 1
0
        private void lb_results_SelectedIndexChanged(object sender, EventArgs e)
        {
            ResultFile r = resultFiles[lb_results.SelectedItem.ToString()];

            dgv_Answers.Rows.Clear();
            dgv_Answers.Refresh();
            int iter = 0;

            foreach (Question q in r.questions)
            {
                iter++;
                if (q.answered)
                {
                    dgv_Answers.Rows.Add(new object[] { iter, q.question, q.question_word, q.correct_answer, q.chosen_answer, q.answers[0], q.answers[1], q.answers[2], q.answers[3], q.similarities[0], q.similarities[1], q.similarities[2], q.similarities[3], q.correct });
                }
                else
                {
                    dgv_Answers.Rows.Add(new object[] { iter, q.question, q.question_word, q.correct_answer, "NA", q.answers[0], q.answers[1], q.answers[2], q.answers[3], 0.0, 0.0, 0.0, 0.0, true });
                }
            }
            label1.Text = r.correct().ToString();
        }
Ejemplo n.º 2
0
        public ResultFile merge(ResultFile r)
        {
            source = new List <string>();
            ResultFile ret = new ResultFile();

            foreach (Question q in questions)
            {
                foreach (Question q2 in r.questions)
                {
                    if (q.question == q2.question)
                    {
                        Question n = new Question();
                        n.question       = q2.question;
                        n.question_word  = q2.question_word;
                        n.correct_answer = q2.correct_answer;
                        n.answers        = q2.answers;
                        n.answered       = true;
                        n.similarities   = new List <double>();
                        string[] ss = new string[4];
                        if (q.answered && q2.answered)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                if (Math.Abs(q.similarities[i]) > Math.Abs(q2.similarities[i]))
                                {
                                    ss[i] = "1";
                                    n.similarities.Add(Math.Abs(q.similarities[i]));
                                }
                                else
                                {
                                    ss[i] = "2";
                                    n.similarities.Add(Math.Abs(q2.similarities[i]));
                                }
                            }
                            double max       = -100;
                            int    max_index = 0;
                            for (int i = 0; i < 4; i++)
                            {
                                if (n.similarities[i] > max)
                                {
                                    max_index = i;
                                    max       = n.similarities[i];
                                }
                            }
                            ret.source.Add(ss[max_index]);
                            n.chosen_answer = n.answers[max_index];
                            if (n.chosen_answer == n.correct_answer)
                            {
                                n.correct = true;
                            }
                            else
                            {
                                n.correct = false;
                            }
                        }
                        else
                        {
                            if (q.answered)
                            {
                                ret.source.Add("1");
                                n.similarities  = q.similarities;
                                n.chosen_answer = q.chosen_answer;
                                n.correct       = q.correct;
                            }
                            else
                            {
                                if (q2.answered)
                                {
                                    ret.source.Add("2");
                                    n.similarities  = q2.similarities;
                                    n.chosen_answer = q2.chosen_answer;
                                    n.correct       = q2.correct;
                                }
                                else
                                {
                                    ret.source.Add("NA");
                                    n.answered     = false;
                                    n.similarities = new List <double>()
                                    {
                                        0.0, 0.0, 0.0, 0.0
                                    };
                                    n.correct       = true;
                                    n.chosen_answer = "not answered";
                                }
                            }
                        }
                        ret.questions.Add(n);
                    }
                }
            }
            return(ret);
        }