/// <summary>
 /// Adds the exam.
 /// </summary>
 /// <param name="exam">The exam.</param>
 public void AddExam(Exam exam)
 {
     using (var context = new MyApplicationContext())
     {
         context.Exams.Add(exam);
         context.SaveChanges();
     }
 }
 public void SetUp()
 {
     // a valid exam
     exam = new Exam()
     {
         Date = DateTime.Now,
         Course = new Course()
     };
 }
 internal void ExamValidateDate(Exam exam, DateTime examinationDate, ValidationResults results)
 {
     if (examinationDate < DateTime.Today.Date)
     {
         results.AddResult(new ValidationResult
             (
                 "The start date cannot be in the past", exam, "ValidationMethod", "error", null)
             );
     }
 }
        public void TestExamUpdate()
        {
            Exam exam = new Exam() { Id = 14 };

            examDataService.Expect(dao => dao.UpdateExam(exam));

            examService.UpdateExam(exam);

            examDataService.VerifyAllExpectations();
        }
 /// <summary>
 /// Deletes the exam.
 /// </summary>
 /// <param name="exam">The exam.</param>
 public void DeleteExam(Exam exam)
 {
     using (var context = new MyApplicationContext())
     {
         var newProd = new Exam { Id = exam.Id };
         context.Exams.Attach(newProd);
         context.Exams.Remove(newProd);
         context.SaveChanges();
     }
 }
        public void TestExamAdd()
        {
            Exam exam = new Exam() { Id = 15 };

            examDataService.Expect(dao => dao.AddExam(exam));

            examService.AddExam(exam);

            examDataService.VerifyAllExpectations();
        }
        public void TestExamGetById()
        {
            int id = 15;
            Exam exam = new Exam() { Id = id };

            examDataService.Stub(dao => dao.GetExamById(id)).Return(exam);

            Exam result = examService.GetExamById(id);

            Assert.AreEqual(id, result.Id);
        }
 /// <summary>
 /// Updates the exam.
 /// </summary>
 /// <param name="exam">The exam.</param>
 /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception>
 public void UpdateExam(Exam exam)
 {
     using (var context = new MyApplicationContext())
     {
         Exam examRef = context.Exams.Where(c => c.Id == exam.Id).SingleOrDefault();
         if (examRef != null)
         {
             examRef = exam;
             context.SaveChanges();
         }
         else
             throw new KeyNotFoundException();
     }
 }
        public void ValidateAllowedPasses(Exam exam, ValidationResults results)
        {
            var numberOfExaminations = exam.Student.Exams.Count(e => e.StudentId == exam.StudentId && e.CourseId == exam.CourseId);

            // 1. La un examen un student se poate prezenta de maxim 3 ori.
            if (numberOfExaminations == 3)
            {
                results.AddResult(new ValidationResult
                   (
                       "The the number of allowed examinations for this course " + exam.Course + " is 3", exam, "ValidationMethod", "error", null)
                   );

                return;
            }

            // 2. Daca nota acordata este >= 5, atunci nu mai are voie sa se prezinte la reexaminari.
            // pai da, dar asta inseamna ca trebuie sa-l las sa treaca de validare...
            if (numberOfExaminations > 0 && exam.Grade >= 5)
            {
                results.AddResult(new ValidationResult
                    (
                        "The student has passed the exam for this course. No more examinations allowed!", exam, "ValidationMethod", "error", null)
                    );
            }

            // 3. Daca dupa 3 prezentari examenul nu este luat, atunci trebuie sa se aleaga alt curs disponibil in semestrul respectiv.
            // in cazul in care studentul s-a prezentat de 3 ori la curs si nu a luat nota de trecere, acest curs nu mai poate fi ales de catre student
            if (numberOfExaminations + 1 <= 3)
            {
                if (exam.Grade < 5)
                {
                    results.AddResult(new ValidationResult
                    (
                        "Please choose other course available in the current semester " + exam.Course + " is 3", exam, "ValidationMethod", "error", null)
                    );
                }

                // TODO: Determine if a course is prerequisite or corequisite for another course
                // 4. Daca cursul nepromovat dupa cele maxim 3 prezentari este prerequisite sau corequisite pentru alt curs,
                // acest al din urma curs nu mai poate fi absolvit.
            }
        }
Exemplo n.º 10
0
 public void DeleteExam(Exam exam)
 {
     examDataService.DeleteExam(exam);
 }
        public void TestExamGetListOfExams()
        {
            Exam exam1 = new Exam()
            {
                Id = 11
            };
            Exam exam2 = new Exam()
            {
                Id = 12
            };
            IList<Exam> exams = new List<Exam>() { exam1, exam2 };

            examDataService.Stub(dao => dao.GetAllExams()).Return(exams);

            var result = examService.GetListOfExams();

            Assert.AreEqual(result.Count, exams.Count);
        }
 /// <summary>
 /// Inainte de acordarea unei note pentru acest curs, materiile corequisite trebuie sa fie absolvite (luate cu cel putin 5).
 /// </summary>
 /// <param name="exam"></param>
 /// <param name="results"></param>
 internal void ValidateGradeCourse(Exam exam, ValidationResults results)
 {
     foreach (var courseCoRequisite in exam.Course.CourseCoRequisites.Where(courseCoRequisite => (courseCoRequisite.Exams.Any(e => e.Grade < 5))))
     {
         results.AddResult(new ValidationResult
             (
             "The co-requisite: " + courseCoRequisite + " was not graduated!", exam, "ValidationMethod", "error", null)
             );
     }
 }
Exemplo n.º 13
0
 public void AddExam(Exam exam)
 {
     examDataService.AddExam(exam);
 }
 // Update
 public void UpdateExam(int examId, Exam exam)
 {
     DataMapperFactory.GetMapperFactory().ExamMapper.UpdateExam(examId, exam);
 }
 public void DeleteExam(Exam exam)
 {
     DataMapperFactory.GetMapperFactory().ExamMapper.DeleteExam(exam);
 }
 // Create
 public void AddExam(Exam exam)
 {
     DataMapperFactory.GetMapperFactory().ExamMapper.AddExam(exam);
 }
Exemplo n.º 17
0
 public void UpdateExam(Exam exam)
 {
     examDataService.UpdateExam(exam);
 }