Exemplo n.º 1
0
    public void ProcessBlock()
    {
        CutTrashHead();

        if (CheckBlock())
        {
            NoData = 0;
            Catch  = "";
            string   Block   = Buffer.Substring(FocusS + 1, FocusE - FocusS - 1);
            string[] spBlock = Block.Split(SEP1.ToCharArray());

            for (int i = 0; i < spBlock.Length; i++)
            {
                string[] spCommand = spBlock[i].Split(SEP2.ToCharArray());

                for (int j = 0; j < KeyDouble.Count; j++)
                {
                    if (spCommand[0] == KeyDouble[j])
                    {
                        DataDouble[j] = Convert.ToDouble(spCommand[1]);
                        Catch         = Catch + KeyDouble[j] + SEP1;
                        NoData++;
                        break;
                    }
                }

                for (int j = 0; j < KeyString.Count; j++)
                {
                    if (spCommand[0] == KeyString[j])
                    {
                        DataString[j] = spCommand[1];
                        Catch         = Catch + KeyString[j] + SEP1;
                        NoData++;
                        break;
                    }
                }

                for (int k = 0; k < KeyFunction.Count; k++)
                {
                    if (spCommand[0] == KeyFunction[k])
                    {
                        DataFunction[k]();
                        Catch = Catch + KeyFunction[k] + SEP1;
                        NoData++;
                        break;
                    }
                }
            }
            if (Catch != "")
            {
                Catch = Catch.Remove(Catch.Length - 1);
            }
            CutFirstBlock();
        }
        else
        {
            return;
        }
    }
Exemplo n.º 2
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,
        }
Exemplo n.º 3
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);
        }