Beispiel #1
0
 public Test(int testerNumber, int traineeNumber)
 {
     Criterions  = new CriterionsOfTest();
     _TestNumber = TestIdTotal++;
     TesterId    = testerNumber;
     TraineeId   = traineeNumber;
 }
        public void FinishTest(int id, CriterionsOfTest criterions, bool pass, string note)
        {
            Test test = GetTestByNumber(id);

            if (test == null)
            {
                throw new Exception("Attempted to finish an unexistent test");
            }
            test.Criterions = criterions ?? throw new Exception("You have to insert criterions to finish test");
            test.Pass       = pass;
            test.TesterNote = note;
            DS.DataSource.tests.RemoveAll(t => t.TestNumber == id);
            DS.DataSource.tests.Add(test);
        }
        public finishTest()
        {
            InitializeComponent();
            CriterionsOfTest criterionsOfTest = new CriterionsOfTest();

            foreach (var item in criterionsOfTest.Criterions)
            {
                var label = new Label();
                label.Content = item.Name;
                CheckBox checkBox = new CheckBox();
                checkBox.Content = item.Name;
                critrions.Children.Add(checkBox);
            }
            tests.ItemsSource = bl.GetAllTests(test => !bl.isTestFinished(test));
        }
        public void FinishTest(int id, CriterionsOfTest criterions, bool pass, string note)
        {
            if (criterions.Criterions.Any(criterion => criterion.Mode == CriterionMode.NotDetermined))
            {
                throw new Exception("It is impossible that one of the criteria will not enter a value");
            }
            if (dal.GetTestByNumber(id) == null)
            {
                throw new Exception(string.Format("The test with number {0} is not found", id));
            }
            //TODO: work with criterions to think when is impotisble that trainee pass and when not.
            var distribution = new List <IGrouping <BE.CriterionMode, string> >(from criterion in criterions.Criterions group criterion.Name by criterion.Mode);

            List <string> passed       = new List <string>(0);
            List <string> failed       = new List <string>(0);
            List <string> NotDetermind = new List <string>(0);

            foreach (var mode in distribution)
            {
                if (mode.Key == BE.CriterionMode.passed)
                {
                    passed = mode.ToList <string>();
                }
                if (mode.Key == BE.CriterionMode.Fails)
                {
                    failed = mode.ToList <string>();
                }
                if (mode.Key == BE.CriterionMode.NotDetermined)
                {
                    NotDetermind = mode.ToList <string>();
                }
            }
            float grade = 100;

            if (failed.Count + NotDetermind.Count != 0)
            {
                grade = passed.Count / (failed.Count + NotDetermind.Count);
            }
            if (pass && grade < (((float)BE.Configuration.PERCETAGE_REQUIRED_FOR_PASSING) / 100))
            {
                throw new Exception(string.Format("Test number {0} couldn't have been passed, since not enough criteria have been met", id));
            }
            if (!pass && grade > BE.Configuration.PERCETAGE_REQUIRED_FOR_PASSING)
            {
                throw new Exception(string.Format("Test number {0} couldn't have been failed, since enough criteria have been met for the trainee to pass", id));
            }
            dal.FinishTest(id, criterions, pass, note);
        }
        private static void finishTest()
        {
            string id   = input("id");
            Test   test = bl.GetTestByNumber(int.Parse(id));

            if (test == null)
            {
                throw new Exception("test not found");
            }
            List <Criterion> list    = new List <Criterion>(test.Criterions.Criterions);
            List <Criterion> Newlist = new List <Criterion>();

            for (int i = 0; i < list.Count; i++)
            {
                string mode = input(string.Format("mode for {0} (0 or else)", list[i].Name));
                if (mode != "0")
                {
                    Newlist.Add(new Criterion(list[i].Name, CriterionMode.passed));
                }
                else
                {
                    Newlist.Add(new Criterion(list[i].Name, CriterionMode.Fails));
                }
            }
            string passed = input("wheater he passed");
            bool   _passed;

            if (passed == "0")
            {
                _passed = false;
            }
            else
            {
                _passed = true;
            }
            string           note       = input("note of tester");
            CriterionsOfTest criterions = new CriterionsOfTest(Newlist);

            bl.FinishTest(int.Parse(id), criterions, _passed, note);
        }