public void Execute(IDataBase db)
        {
            var group = db.GetElements<Group>()[0];

            db.FillElement(group);

            var peoples = group.Peoples;

            var test = db.GetElements<Test>()[0];

            db.FillElement(test);

            var passedTest1 = new PassedTest();
            var passedTest2 = new PassedTest();

            passedTest1.SetPeople(peoples[0]);
            passedTest2.SetPeople(peoples[1]);
            passedTest1.SetTest(test);
            passedTest2.SetTest(test);

            passedTest1.Replies[test.Questions[0]] = "Я не знаю ответа.";
            passedTest1.Replies[test.Questions[1]] = "И тут я тоже не знаю ответа, увы.";

            passedTest2.Replies[test.Questions[0]] = "Бла-бла-бла";
            passedTest2.Replies[test.Questions[1]] = "Этой строки быть не должно";
            passedTest2.Replies[test.Questions[1]] = "Проверка на изменение ответа";

            db.ExecuteCommand(Parameters.Insert, passedTest1);
            db.ExecuteCommand(Parameters.Insert, passedTest2);
        }
Esempio n. 2
0
        public static bool WritePassedTest(AnsweredQuestions answeredQuestions, People people)
        {
            var test = Api.GetElements<Test>(Parameters.Filter, "[Id]", Parameters.Equal, answeredQuestions.TestId).FirstOrDefault();

            if (test == null)
            {
                return false;
            }

            Api.FillElement(test);

            var passedTest = new PassedTest();

            for (var i = 0; i < test.Questions.Length; i++)
            {
                try
                {
                    passedTest.Replies[test.Questions[i]] = answeredQuestions.Replies[i] ?? "";
                }
                catch
                {
                    passedTest.Replies[test.Questions[i]] = "";
                }
            }

            passedTest.SetPeople(people);
            passedTest.SetTest(test);

            Api.ExecuteCommand(Parameters.Insert, passedTest);

            return true;
        }
Esempio n. 3
0
        public MainForm(People people, IDataBase db)
        {
            _passedTest = new PassedTest();
            _passedTest.SetPeople(people);

            _db = db;

            InitializeComponent();
        }
Esempio n. 4
0
        private void btnWrite_Click(object sender, EventArgs e)
        {
            var passedTest = new PassedTest(SelectedDate);

            _db.FillElement(SelectedTest);

            passedTest.SetPeople(SelectedPeople);
            passedTest.SetTest(SelectedTest);

            foreach (var question in SelectedTest.Questions)
            {
                passedTest.Replies[question] = "Ответ был сформирован автоматически";
            }

            _db.ExecuteCommand(Parameters.Insert, passedTest);

            Close();
        }
Esempio n. 5
0
 public void SetPassedTest(PassedTest passedTest)
 {
     PassedTest = PassedTest ?? passedTest;
 }
Esempio n. 6
0
 public bool IsFinished(PassedTest passedTest)
 {
     return _test.Questions.Length == passedTest.Replies.Keys.Count && passedTest.Replies.All(reply => !string.IsNullOrEmpty(reply.Value));
 }