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++; }
private string Encode(string[] items) { StringBuilder builder = new StringBuilder(); string sep = ""; foreach (string item in items) { builder.Append(sep + item); sep = SEP.ToString(); } return(builder.ToString()); }
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); }
/// <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); }
public override XmlElement Export(XmlDocument doc, XmlElement parent) { XmlElement current = base.Export(doc, parent); if (ActiveFrom != null) { current.SetAttribute("ACTIVE_FROM", ActiveFrom.ToString()); } if (ActiveTill != null) { current.SetAttribute("ACTIVE_TILL", ActiveTill.ToString()); } if (Confcal != null) { current.SetAttribute("CONFCAL", Confcal.ToString()); } if (Date != null) { current.SetAttribute("DATE", Date.ToString()); } if (Days != null) { current.SetAttribute("DAYS", Days.ToString()); } if (DaysAndOr != null) { current.SetAttribute("DAYS_AND_OR", DaysAndOr.ToString()); } if (DaysCal != null) { current.SetAttribute("DAYSCAL", DaysCal.ToString()); } if (Level != null) { current.SetAttribute("LEVEL", Level.ToString()); } if (MaxWait != null) { current.SetAttribute("MAXWAIT", MaxWait.ToString()); } if (Retro != null) { current.SetAttribute("RETRO", Retro.ToString()); } if (Shift != null) { current.SetAttribute("SHIFT", Shift.ToString()); } if (ShiftNum != null) { current.SetAttribute("SHIFTNUM", ShiftNum.ToString()); } if (TagsActiveFrom != null) { current.SetAttribute("TAGS_ACTIVE_FROM", TagsActiveFrom.ToString()); } if (TagsActiveTill != null) { current.SetAttribute("TAGS_ACTIVE_TILL", TagsActiveTill.ToString()); } if (WeekDays != null) { current.SetAttribute("WEEKDAYS", WeekDays.ToString()); } if (Weekscal != null) { current.SetAttribute("WEEKSCAL", Weekscal.ToString()); } if (JAN != null) { current.SetAttribute("JAN", JAN.ToString()); } if (FEB != null) { current.SetAttribute("FEB", FEB.ToString()); } if (MAR != null) { current.SetAttribute("MAR", MAR.ToString()); } if (APR != null) { current.SetAttribute("APR", APR.ToString()); } if (MAY != null) { current.SetAttribute("MAY", MAY.ToString()); } if (JUN != null) { current.SetAttribute("JUN", JUN.ToString()); } if (JUL != null) { current.SetAttribute("JUL", JUL.ToString()); } if (AUG != null) { current.SetAttribute("AUG", AUG.ToString()); } if (SEP != null) { current.SetAttribute("SEP", SEP.ToString()); } if (OCT != null) { current.SetAttribute("OCT", OCT.ToString()); } if (NOV != null) { current.SetAttribute("NOV", NOV.ToString()); } if (DEC != null) { current.SetAttribute("DEC", DEC.ToString()); } return(current); }