コード例 #1
0
ファイル: MainForm.cs プロジェクト: cloughin/VoteProject.5
        //private readonly Dictionary<string, dynamic> _OldQuestionsDictionary =
        //  new Dictionary<string, dynamic>(StringComparer.OrdinalIgnoreCase);

        //private readonly Dictionary<string, dynamic> _NewQuestionsDictionary =
        //  new Dictionary<string, dynamic>(StringComparer.OrdinalIgnoreCase);

        private string PrependOldQuestionToAnswerIfNecessary(string questionKey, AnswersRow row)
        {
            var answer = row.Answer.Trim();

            if (!IsNullOrWhiteSpace(answer) &&
                answer.Length < AllOptions.LongAnswerMinimumLength
                //&& _NewQuestionsDictionary[questionKey].PrependOriginal
                )
            {
                _StatesDictionary.TryGetValue(row.StateCode, out var state);
                var question = Questions.GetQuestion(questionKey);
                if (!IsNullOrWhiteSpace(state))
                {
                    if (state == "District of Columbia")
                    {
                        state = "DC";
                    }
                    question = question.Replace("in " + state, Empty);
                    question = question.Replace(state + "'s", Empty);
                    question = question.Replace(state, Empty);
                }

                question = question.StripRedundantSpaces();
                answer   =
                    $"{question}: {answer}";
            }
            return(answer);
        }
コード例 #2
0
        private static string ExtractAnswers(string[] answers, ref ExamsRow r)
        {
            int AIDcorrecto = Convert.ToInt32(answers[1]); //toma la respuesta correcta

            answers = answers[0].Split(SEP);               //the array of answers ID

            QuestionsRow q = r.QuestionsRow;

            IEnumerable <AnswersRow> answ = q.GetAnswersRows();
            int    option = 0;
            string examen;

            examen = string.Empty;
            foreach (string s in answers)
            {
                char       letra = Tools.Alpha[option];
                int        aid   = Convert.ToInt32(s);
                AnswersRow a     = answ.FirstOrDefault(o => o.AID == aid); //selectivamente en el mismo orden en que fue generada

                string respuesta = a.Answer;
                examen += letra;
                examen += ") " + respuesta + "\n"; //respuesta
                option++;
            }

            return(examen);
        }
コード例 #3
0
        private static void ExtractKey(ref string Clave, ref int claveCount, string[] answers, ref ExamsRow r)
        {
            int AIDcorrecto = Convert.ToInt32(answers[1]); //toma la respuesta correcta

            answers = answers[0].Split(SEP);               //the array of answers ID

            QuestionsRow q = r.QuestionsRow;

            int option2 = 0;
            IEnumerable <AnswersRow> answ2 = q.GetAnswersRows();

            foreach (string s in answers)
            {
                char       letra = Tools.Alpha[option2];
                int        aid   = Convert.ToInt32(s);
                AnswersRow a     = answ2.FirstOrDefault(o => o.AID == aid); //selectivamente en el mismo orden en que fue generada
                a.Char = letra.ToString().ToUpper().Trim();
                if (a.AID == AIDcorrecto)
                {
                    Clave += letra;
                }
                option2++;
            }

            if (claveCount == answers.Count())
            {
                Clave     += SEP.ToString();
                claveCount = 0;
            }

            claveCount++;
        }
コード例 #4
0
            public AnswersRow AddAnswersRow(int QuestionId, string Text, bool IsCorrect, byte Order)
            {
                AnswersRow rowAnswersRow = ((AnswersRow)(this.NewRow()));

                rowAnswersRow.ItemArray = new object[] {
                    QuestionId,
                    Text,
                    IsCorrect,
                    Order
                };
                this.Rows.Add(rowAnswersRow);
                return(rowAnswersRow);
            }
コード例 #5
0
            public AnswersRow AddAnswersRow(QuestionsRow parentQuestionsRowByQuestionsAnswers, string Text, bool IsCorrect, byte Order)
            {
                AnswersRow rowAnswersRow = ((AnswersRow)(this.NewRow()));

                rowAnswersRow.ItemArray = new object[] {
                    null,
                    parentQuestionsRowByQuestionsAnswers[0],
                    Text,
                    IsCorrect,
                    Order
                };
                this.Rows.Add(rowAnswersRow);
                return(rowAnswersRow);
            }
コード例 #6
0
        private void fillQAOld()
        {
            DB   clone;
            bool cloned = false;

            if (inter.IdB.Topics.Count == 0)
            {
                clone = inter.IdB;
            }
            else
            {
                clone  = new DB();
                cloned = true;
            }
            DB.TAMQA.AnswersTableAdapter.Fill(clone.Answers);
            DB.TAMQA.QuestionsTableAdapter.Fill(clone.Questions);
            DB.TAMQA.TopicsTableAdapter.Fill(clone.Topics);

            if (cloned)
            {
                foreach (var item in clone.Topics)
                {
                    inter.IdB.Topics.ImportRow(item);
                }
                DB.TAMQA.TopicsTableAdapter.Update(inter.IdB.Topics);
                foreach (var item in clone.Questions)
                {
                    inter.IdB.Questions.ImportRow(item);

                    DB.TAMQA.QuestionsTableAdapter.Update(inter.IdB.Questions);
                    DB.QuestionsRow last    = inter.IdB.Questions.Last();
                    AnswersRow[]    answers = item.GetAnswersRows();
                    foreach (var a in answers)
                    {
                        inter.IdB.Answers.ImportRow(a);
                        AnswersRow la = inter.IdB.Answers.Last();
                        la.QID = last.QID;
                    }

                    DB.TAMQA.AnswersTableAdapter.Update(inter.IdB.Answers);
                }
            }
            // DB.TAMQA.AnswersTableAdapter.Fill(inter.IdB.Answers);
            // DB.TAMQA.QuestionsTableAdapter.Fill(inter.IdB.Questions); DB.TAMQA.TopicsTableAdapter.Fill(inter.IdB.Topics);
        }
コード例 #7
0
        /// <summary>
        /// GEnerates a virtual database
        /// </summary>
        public void GenerateQuestions(int questions)
        {
            int j = 1;

            int?topicID = inter.IBS.CurrentTopic?.TopicID;

            for (int i = 0; i < questions; i++)
            {
                if (j == 6)
                {
                    j = 1;
                }
                QuestionsRow q = inter.IdB.Questions.NewQuestionsRow();
                q.Weight = j;
                inter.IdB.Questions.AddQuestionsRow(q);
                if (topicID != null)
                {
                    q.TopicID = (int)topicID;
                }

                DB.TAMQA.QuestionsTableAdapter.Update(q);

                q.Question = "Pregunta número " + q.QID.ToString();

                int m = 1;
                while (m < 6)
                {
                    AnswersRow r = inter.IdB.Answers.NewAnswersRow();
                    r.Answer = "Respuesta " + q.QID.ToString() + "-" + m.ToString();
                    r.QID    = q.QID;
                    if (m == 5)
                    {
                        r.Correct = true;
                    }
                    inter.IdB.Answers.AddAnswersRow(r);
                    DB.TAMQA.AnswersTableAdapter.Update(r);
                    m++;
                }

                j++;
            }

            updateQA();
        }
コード例 #8
0
 public AnswersRowChangeEvent(AnswersRow row, System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
コード例 #9
0
 public void RemoveAnswersRow(AnswersRow row)
 {
     this.Rows.Remove(row);
 }
コード例 #10
0
 public void AddAnswersRow(AnswersRow row)
 {
     this.Rows.Add(row);
 }