예제 #1
0
        private bool hasRecents(ref IEnumerable <DB.StudentRow> different, int mLE)
        {
            DateTime ahora = DateTime.Now;

            Func <DB.StudentRow, bool> recents = o =>
            {
                if (o.IsDatePresentedNull())
                {
                    return(false);
                }

                double minutesSince = ahora.Subtract(o.DatePresented).TotalSeconds;
                if (minutesSince < mLE)
                {
                    return(true);
                }
                return(false);
            };
            IEnumerable <DB.StudentRow> recent = different.Where(recents).ToList(); //examenes  recientemente presentados

            if (recent.Count() != 0)
            {
                this.currentStudent = null; //quitar esto de aqui??? porque si el boton validar falla no me deja evaluar
                this.currentExam    = null;
                //el estudiante YA HA SIDO EVALUADO RECIENTEMENTE tal vez ponerlo de primero
                //   this.inter.StatusHandler?.Invoke(null, EventArgs.Empty);

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        private bool hasGUIDDuplicates(string guid)
        {
            //
            Func <DB.StudentRow, bool> samers = o =>
            {
                //evaluacion actual tiene mismo examen GUID de una evaluacion ya existente
                if (o.IsGUIDNull())
                {
                    return(false);
                }
                if (o.GUID.CompareTo(guid) == 0)
                {
                    return(true);
                }
                return(false);
            };

            IEnumerable <DB.StudentRow> same = this.inter.IdB.Student.Where(samers).ToList(); //lista de repetidos examenes no hay que hacerle la prueba del tiempo?

            //como acomodo esto???
            if (same.Count() != 0)
            {
                //AQUIIIIII
                this.currentExam    = null;
                this.currentStudent = null;
                //el estudiante YA HA SIDO ASOCIADO AL EXAMEN, tal vez ponerlo de primero
                //    this.inter.StatusHandler?.Invoke(null, EventArgs.Empty);

                // deberia guardar una lista de estos intentos!!!!
                return(true); //SALTE
            }
            return(false);
        }
예제 #3
0
        private int getStudentListID(int dAP)
        {
            // DB.TAM.StuListTableAdapter.FillByStudentIDClass(inter.IdB.StuList, Studentid, clase);

            DateTime ahora = DateTime.Now;

            Func <DB.StuListRow, bool> timecomparer = o =>
            {
                if (o.IsDateNull())
                {
                    return(false);
                }
                double days = ahora.Subtract(o.Date).TotalDays; //dias periodo academico StuList
                if (days < dAP)
                {
                    return(true); // menos de 90 dias
                }
                return(false);    // mas de 90
            };

            DB.StuListRow stu = inter.IdB.StuList.FirstOrDefault(timecomparer);

            if (stu == null)
            {
                this.currentStudent = null;
                this.currentExam    = null;

                return(0); // no le des SLID
            }
            else
            {
                return(stu.SLID); //HAY RECIENTE
            }
        }
예제 #4
0
        public bool AssignExamModel(string res)
        {
            currentExam = null;
            bool validated = false;

            Image = null;

            string decrypto = Rsx.Encryption.AESThenHMAC.SimpleDecryptWithPassword(res, inter.Password, 0); //decrypt the QR Code!!! importantisimo

            if (decrypto == null)
            {
                return(validated);
            }

            currentExam = inter.IdB.ExamsList.FirstOrDefault(o => o.GUID.CompareTo(decrypto) == 0);

            if (currentExam != null)
            {
                Image     = Tools.CreateQRCode(res, QRSIZE);
                validated = true;
            }
            else
            {
                this.inter.Status = Resources.QRNoEncontrado;
            }
            return(validated);
        }
예제 #5
0
        private bool hasExpired(int dEG, DateTime examGenerated)
        {
            DateTime ahora = DateTime.Now;
            //   DateTime examGenerated =examDateTime ;
            //horas elapsadas desde que se generó el examen hasta AHORA
            double diascreado = ahora.Subtract(examGenerated).TotalDays;

            if (diascreado > dEG)           //supera 15 dias
            {
                this.currentExam    = null; //desechalo
                this.currentStudent = null;
                // this.inter.StatusHandler?.Invoke(null, EventArgs.Empty);

                return(true); //SALTE EL EXAMEN EXPIRO!!!
            }
            return(false);
        }
예제 #6
0
        public void OpenFile()
        {
            try
            {
                DB.ExamsListRow erow = inter.IBS.CurrentExam;

                string destFile = model + erow.GUID + PDF_EXT; //ok

                if (erow.IsExamFileNull())
                {
                    return;
                }

                byte[] arr = erow.ExamFile;

                IO.OpenBytesFile(ref arr, destFile, examsPath);
            }
            catch (Exception ex)
            {
                inter.Status = "El Examen ya está abierto";
            }
        }
예제 #7
0
파일: BS.cs 프로젝트: hnjm/Exam
        /*
         * public bool Working
         * {
         *
         *  set
         *  {
         *      if (!value)
         *      {
         *          //    Exam.CurrentChanged += Exam_CurrentChanged;
         *          ExamsList.CurrentChanged += currentChanged;
         *          //     Student.CurrentChanged += Exam_CurrentChanged;
         *          StudentsList.CurrentChanged += currentChanged;
         *          Questions.CurrentChanged += currentChanged;
         *          //    Answers.CurrentChanged += Exam_CurrentChanged;
         *          //      Preferences.CurrentChanged += Exam_CurrentChanged;
         *          LogPref.CurrentChanged += currentChanged;
         *          //      Order.CurrentChanged += Exam_CurrentChanged;
         *          //     Class.CurrentChanged += Exam_CurrentChanged;
         *          //     AYear.CurrentChanged += Exam_CurrentChanged;
         *
         *          Topics.CurrentChanged += currentChanged;
         *      }
         *      else
         *      {
         *          //    Exam.CurrentChanged += Exam_CurrentChanged;
         *          ExamsList.CurrentChanged -= currentChanged;
         *          //     Student.CurrentChanged += Exam_CurrentChanged;
         *          StudentsList.CurrentChanged -= currentChanged;
         *          Questions.CurrentChanged -= currentChanged;
         *          //    Answers.CurrentChanged += Exam_CurrentChanged;
         *          //      Preferences.CurrentChanged += Exam_CurrentChanged;
         *          LogPref.CurrentChanged -= currentChanged;
         *          //      Order.CurrentChanged += Exam_CurrentChanged;
         *          //     Class.CurrentChanged += Exam_CurrentChanged;
         *          //     AYear.CurrentChanged += Exam_CurrentChanged;
         *
         *          Topics.CurrentChanged -= currentChanged;
         *      }
         *  }
         * }
         */
        private void currentChanged(object sender, EventArgs e)
        {
            if (Working)
            {
                return;
            }

            try
            {
                // DataGridView dgv = sender as DataGridView;
                BindingSource bs = sender as BindingSource;
                if (bs.Current == null)
                {
                    return;
                }
                DataRowView view = (bs.Current as DataRowView);
                DataRow     row  = view.Row;
                if (row == null)
                {
                    return;
                }

                //   byte[] auxiliar = null;

                if (sender.Equals(this.Topics))
                {
                    DB.TopicsRow          r  = row as DB.TopicsRow;
                    DB.QuestionsDataTable dt = set.Questions;
                    Questions.Filter = dt.TopicIDColumn.ColumnName + " = " + r.TopicID;
                }
                else if (sender.Equals(this.Questions))
                {
                    DB.QuestionsRow r  = row as DB.QuestionsRow;
                    string          dt = set.Answers.QIDColumn.ColumnName;
                    Answers.Filter = dt + " = " + r.QID;
                }
                else if (sender.Equals(this.RandomQuestions))
                {
                    DB.QuestionsRow r  = row as DB.QuestionsRow;
                    string          dt = auxiliar.Answers.QIDColumn.ColumnName;
                    RandomAnswers.Filter = dt + " = " + r.QID;
                }
                else if (sender.Equals(this.Exam))
                {
                    string      dt = auxiliar.Questions.QIDColumn.ColumnName;
                    DB.ExamsRow r  = row as DB.ExamsRow;
                    //        string[] aux  = r.AIDString.Split(',');
                    RandomQuestions.Position = RandomQuestions.Find(dt, r.QID);
                    Questions.Position       = Questions.Find(dt, r.QID);
                }
                else if (sender.Equals(this.StudentsList))
                {
                    DB.StuListRow       r  = row as DB.StuListRow;
                    DB.StudentDataTable dt = set.Student;
                    Student.Filter = dt.EIDColumn.ColumnName + " = " + r.SLID;

                    //     DB.TAM.ExamsTableAdapter.FillByEID(dt, r.EID);
                }
                else if (sender.Equals(this.ExamsList))
                {
                    DB.ExamsListRow r = row as DB.ExamsListRow;
                    //     DB.ExamsDataTable dt = set.Exams;
                    Exam.Filter = auxiliar.Exams.EIDColumn.ColumnName + " = " + r.EID;
                    Working     = true;
                    auxiliar.PopulateExamQuestions(ref r);
                    Working = false;
                    Exam.MoveFirst();
                }
                else if (sender.Equals(this.LogPref))
                {
                    DB.PreferencesRow     r  = row as DB.PreferencesRow;
                    DB.ExamsListDataTable dt = set.ExamsList;

                    ExamsList.Filter = dt.PIDColumn.ColumnName + " = " + r.PID;

                    DB.TAM.ExamsListTableAdapter.FillByPID(dt, r.PID);

                    /*
                     * if (!r.IsELDataNull())
                     * {
                     * // string pid = ExasmPath + r.PID.ToString() + ".xml";
                     *  auxiliar = r.ELData;
                     *  Tables.ReadDTBytes(ExasmPath,ref auxiliar, ref dt);
                     * }
                     * else
                     * {
                     *  DB.TAM.ExamsListTableAdapter.FillByPID(dt, r.PID);
                     *  // MakeTableBytes(ref r);
                     * }
                     */
                }
            }
            catch (SystemException ex)
            {
            }
        }
예제 #8
0
        private void evaluateStudent()
        {
            string provided = currentStudent.LProvided;

            string TrueAns = currentStudent.ExamsListRow.CLAnswer;                                      //take the encripted answer

            TrueAns = Rsx.Encryption.AESThenHMAC.SimpleDecryptWithPassword(TrueAns, inter.Password, 0); //decripta
            Tools.StripAnswer(ref TrueAns);

            string[] split  = currentStudent.ExamsListRow.LQuestion.Split(SEP2);
            double   factor = Convert.ToDouble(split[1]);

            string[] weights = split[0].Split(SEP);

            int[] ws = weights.Select(o => Convert.ToInt32(o)).ToArray();

            IList <int> errorArray = new List <int>();

            double puntos      = 0;
            int    correct     = 0;
            int    i           = 0;
            double puntosTotal = 0;

            for (i = 0; i < provided.Length; i++)
            {
                char   c = provided[i];
                char   a = TrueAns[i];
                double puntosQuestion = ws[i] * factor;
                puntosTotal += puntosQuestion;
                if (c == a)
                {
                    puntos += puntosQuestion;
                    correct++;
                }
                else if (c.Equals('0'))
                {
                    continue;
                }
                else
                {
                    errorArray.Add(i + 1);
                }
            }

            string error = string.Empty;

            currentStudent.Error = error;

            if (errorArray.Count != 0)
            {
                foreach (int x in errorArray)
                {
                    error += x.ToString() + SEP.ToString();
                }
                if (error[error.Length - 1].Equals(SEP))
                {
                    currentStudent.Error = error.Substring(0, error.Length - 1);
                }
            }

            currentStudent.Score   = (double)Decimal.Round(Convert.ToDecimal(puntos), 1);
            currentStudent.Obs     = string.Empty; //nada aun
            currentStudent.Correct = correct;

            currentStudent.DatePresented = DateTime.Now;

            //mejorar esto
            //   currentStudent.ExamsListRow.Questions = currentStudent.ExamsListRow.GetExamsRows().Count();
            // currentStudent.ExamsListRow.Points = Decimal.Round(Convert.ToDecimal(puntosTotal),3);
            // this.picBox.Image = null;

            DB.TAM.StudentTableAdapter.Update(this.inter.IdB.Student);

            this.currentStudent = null; // reset values
            this.currentExam    = null; //reset asignments
        }