예제 #1
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);
        }
예제 #2
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++;
        }
예제 #3
0
        private void ReportUnansweredQuestion(QuestionsRow question)
        {
            var tr = new HtmlTableRow().AddTo(_HtmlTable, "trPoliticianIssueQuestion");

            new HtmlTableCell {
                InnerHtml = question.Question, ColSpan = 2
            }.AddTo(tr,
                    "tdPoliticianIssueQuestion");
        }
예제 #4
0
        private void ReportAnswer(QuestionsRow question, DataRow answer)
        {
            var tr = new HtmlTableRow().AddTo(_HtmlTable, "trPoliticianIssueQuestion");

            new HtmlTableCell {
                InnerHtml = question.Question
            }.AddTo(tr,
                    "tdPoliticianIssueQuestion");

            var td = new HtmlTableCell().AddTo(tr, "tdPoliticianIssueAnswer");

            FormatAnswer(answer, td, false);
        }
            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
            public QuestionsRow AddQuestionsRow(int TypeId, int SubtypeId, int DifficultyLevelId, string Text, byte[] Picture)
            {
                QuestionsRow rowQuestionsRow = ((QuestionsRow)(this.NewRow()));

                rowQuestionsRow.ItemArray = new object[] {
                    null,
                    TypeId,
                    SubtypeId,
                    DifficultyLevelId,
                    Text,
                    Picture
                };
                this.Rows.Add(rowQuestionsRow);
                return(rowQuestionsRow);
            }
예제 #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
        private static string ExtractQuestionAndWeight(ref string questionWeight, ref string qidString, ref int pregunta, bool showPoints, double pointFactor, ref ExamsRow r)
        {
            string       examen;
            QuestionsRow q = r.QuestionsRow;

            qidString += r.QID.ToString() + SEP.ToString();
            Decimal askValue = Convert.ToDecimal(q.Weight * pointFactor);
            string  weight   = Decimal.Round(askValue, 3).ToString();

            examen = pregunta.ToString() + "- " + q.Question; //pregunta

            if (showPoints)
            {
                examen += "\t( " + PUNTOS + ": " + weight + " )";
            }
            examen += "\n";
            pregunta++;                                             //contador

            questionWeight += q.Weight.ToString() + SEP.ToString(); // save a string of questionsWeights
            return(examen);
        }
예제 #9
0
 public QuestionsRowChangeEvent(QuestionsRow row, System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
예제 #10
0
 public void RemoveQuestionsRow(QuestionsRow row)
 {
     this.Rows.Remove(row);
 }
예제 #11
0
 public void AddQuestionsRow(QuestionsRow row)
 {
     this.Rows.Add(row);
 }
예제 #12
0
        private static void MakeTableBytes <T>(ref T l, string examPath)
        {
            Type tipo = l.GetType();

            byte[] arr2 = null;
            // string afile = string.Empty;

            if (tipo.Equals(typeof(ExamsListRow)))
            {
                ExamsListRow ls = l as ExamsListRow;

                IEnumerable <ExamsRow> rows = ls.GetExamsRows();

                ExamsDataTable exdt = new ExamsDataTable();
                foreach (var item in rows)
                {
                    exdt.ImportRow(item);
                }

                // afile = ExasmPath + ls.EID.ToString();

                arr2     = Tables.MakeDTBytes(ref exdt, examPath);
                ls.EData = arr2;
            }
            else if (tipo.Equals(typeof(ExamsRow)))
            {
                //SAVE COPY OF TABLE

                ExamsRow     ex = l as ExamsRow;
                QuestionsRow q  = ex.QuestionsRow;
                // afile = ExasmPath + ex.QID.ToString(); IEnumerable<DB.QuestionsRow> shortQlist =
                // new List<DB.QuestionsRow>(); ((IList<DB.QuestionsRow>)shortQlist).Add(ex.QuestionsRow);
                QuestionsDataTable qdt = new QuestionsDataTable();
                qdt.ImportRow(q);
                byte[] qarray = Tables.MakeDTBytes(ref qdt, examPath);
                ex.QData = qarray;
                Dumb.FD(ref qdt);

                AnswersDataTable         adt  = new AnswersDataTable();
                IEnumerable <AnswersRow> answ = q.GetAnswersRows();
                foreach (var item in answ)
                {
                    adt.ImportRow(item);
                }
                // afile = ExasmPath + ex.QueToString() + ".xml";
                arr2     = Tables.MakeDTBytes(ref adt, examPath);
                ex.AData = arr2;
                Dumb.FD(ref adt);
            }
            else if (tipo.Equals(typeof(PreferencesRow)))
            {
                PreferencesRow p = l as PreferencesRow;              //SAVE A COPY OF EXAMS LISTS
                IEnumerable <DB.ExamsListRow> rows = p.GetExamsListRows();

                ExamsListDataTable dt = new ExamsListDataTable();
                foreach (var item in rows)
                {
                    dt.ImportRow(item);
                }

                // afile = ExasmPath + p.PID.ToString() + ".xml";
                arr2     = Tables.MakeDTBytes(ref dt, examPath);
                p.ELData = arr2;

                Dumb.FD(ref dt);
            }
        }