示例#1
0
        /// <summary>
        /// PERHAPS THE MOST IKPORTAN, WHERE QAS ARE GENERATED AND PASSWORDS TOO
        /// </summary>
        /// <param name="exams">         </param>
        /// <param name="pr">            </param>
        /// <param name="questionAnswer"></param>
        /// <returns></returns>
        private static string[] makeQAs(ref IEnumerable <ExamsRow> exams, ref PreferencesRow pr, out IList <string[]> questionAnswer)
        {
            bool   showPoints  = pr.showPoints;
            double pointFactor = pr.Factor;

            questionAnswer = new List <string[]>();

            int pregunta   = 1;
            int claveCount = 1;

            string Clave;
            string questionWeight;
            string qidString;

            Clave          = string.Empty;
            questionWeight = string.Empty;
            qidString      = string.Empty;

            foreach (DataRow row in exams)
            {
                string[] qAns   = new string[2];
                ExamsRow r      = (ExamsRow)row;
                string   examen = string.Empty;

                examen  = ExtractQuestionAndWeight(ref questionWeight, ref qidString, ref pregunta, showPoints, pointFactor, ref r);
                qAns[0] = examen;

                string[] answers = ExtractAnswersArray(ref r);

                examen  = ExtractAnswers(answers, ref r);
                qAns[1] = examen;

                ExtractKey(ref Clave, ref claveCount, answers, ref r);

                questionAnswer.Add(qAns);
            }

            if (qidString[qidString.Length - 1].Equals(SEP))
            {
                qidString = qidString.Substring(0, qidString.Length - 1); //erase last separator
            }

            if (questionWeight[questionWeight.Length - 1].Equals(SEP))
            {
                questionWeight = questionWeight.Substring(0, questionWeight.Length - 1); //erase last separator
            }

            questionWeight += SEP2.ToString() + pointFactor.ToString(); //KEEP THE FACTOR IN THE STRING!!!

            if (Clave[Clave.Length - 1].Equals(SEP))
            {
                Clave = Clave.Substring(0, Clave.Length - 1); //erase last separator
            }

            ///IMPORTANT CUMJULATIVE INFO
            return(new string[3] {
                Clave, questionWeight, qidString
            });                                                        // LAnswer , LQuestion,
        }
示例#2
0
        /// <summary>
        /// the code string for 1 exam question (already randonmized)
        /// </summary>
        /// <param name="qID"> </param>
        /// <param name="answ"></param>
        /// <returns></returns>
        public string CreateExamQuestionCode(ref IEnumerable <AnswersRow> answ)
        {
            string aid = string.Empty;
            ///MAKE ORDERS, which contain the string of answersID in the order of the exam, for each questionID selected
            string code = string.Empty;

            //the second separator sep2 gives the AnswrID (AID) of the right answer

            foreach (AnswersRow a in answ)
            {
                // OrderRow or = inter.IdB.Order.NewOrderRow(); inter.IdB.Order.AddOrderRow(or);
                // or.QID = qID; //questionID or.AID = a.AID; //answerID
                if (!a.IsCorrectNull() && a.Correct == true)
                {
                    aid = a.AID.ToString();
                }
                code += a.AID.ToString() + SEP.ToString();
            }
            code  = code.Substring(0, code.Length - 1); //without comma at the end
            code += SEP2.ToString() + aid;
            return(code);
        }