Exemple #1
0
        public void LazyExtraloadTest()
        {
            Question3 question;
            using (var repo = RepositoryContext.GetRepository())
            {
                question = new Question3() { Name = "question1123", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now };

                var addAnswer1 = new Answer3() { Name = "answer1", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, Question = question };
                var addAnswer2 = new Answer3() { Name = "answer2", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, Question = question };
                question.Answers.Add(addAnswer1);
                question.Answers.Add(addAnswer2);

                repo.Add(question);

                repo.SaveChanges();
            }

            using (var repo = RepositoryContext.GetRepository())
            {
                //SELECT * FROM [Question]
                var question1 = repo.GetAll<Question3>().FirstOrDefault();
                //SELECT count(ID) FROM [Answer] WHERE Question_ID='C421EA5F-89E3-4168-BF7D-60B8DB775C92'
                var count = question1.Answers.Count;
                //Assert.AreEqual(question.Answers.Count, 0);
                var afterLoad = question1.Answers;
            }
        }
Exemple #2
0
        private void NextQuestion()
        {
            if (answered >= 10 - 1)
            {
                Question.Text = "Вы справились с темой!";

                /*Answer1.Text = "Ответ 1";
                *  Answer2.Text = "Ответ 2";
                *  Answer3.Text = "Ответ 3";
                *  Answer4.Text = "Ответ 4";*/

                Answer1.Hide();
                Answer2.Hide();
                Answer3.Hide();
                Answer4.Hide();

                button2.Hide();

                ClearRecord();

                return;
            }

            answered++;

            GetQuestion(cur_theme - 1);
            if (cur_theme != 0 && (cur_question != null && cur_isAnswered == true))
            {
                Question.Text  = cur_question;
                cur_isAnswered = false;
            }
        }
Exemple #3
0
 private void New_question_withanswer_click(object sender, RoutedEventArgs e)
 {
     Question.Clear();
     Answer1.Clear();
     Answer2.Clear();
     Answer3.Clear();
     Answer4.Clear();
 }
Exemple #4
0
        private bool IsValid()
        {
            if (For == Guid.Empty || Statement.IsNullOrWhiteSpace() || Answer1.IsNullOrWhiteSpace() ||
                Answer2.IsNullOrWhiteSpace() || Answer3.IsNullOrWhiteSpace() ||
                CorrectAnswer.IsNullOrWhiteSpace())
            {
                return(false);
            }

            return(true);
        }
Exemple #5
0
 private void Test_diff_color_Load(object sender, EventArgs e)
 {
     label2.Hide();
     Answer1.Hide();
     Answer2.Hide();
     Answer3.Hide();
     Answer4.Hide();
     button1.Hide();
     richTextBox1.Hide();
     timer1.Tick += timer1_Tick;
     timer1.Start();
 }
Exemple #6
0
        public Training()
        {
            InitializeComponent();

            Answer1.Hide();
            Answer2.Hide();
            Answer3.Hide();
            Answer4.Hide();

            button2.Hide();

            Question.Text = "";
        }
Exemple #7
0
 public void hide()
 {
     label1.Hide();
     Red_test.Hide();
     Blue_test.Hide();
     Green_test.Hide();
     label2.Show();
     Answer1.Show();
     Answer2.Show();
     Answer3.Show();
     Answer4.Show();
     button1.Show();
     richTextBox1.Show();
 }
Exemple #8
0
    // Update is called once per frame
    void Update()
    {
        Button btn1 = Answer1.GetComponent <Button>();
        Button btn2 = Answer2.GetComponent <Button>();
        Button btn3 = Answer3.GetComponent <Button>();

        btn1.onClick.AddListener(AnswerA);
        btn2.onClick.AddListener(AnswerB);
        btn3.onClick.AddListener(AnswerC);

        //print(Late.GetComponent<Rigidbody2D>().IsSleeping());

        if (Status == 1 && sleeping)
        {
            Answer2.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            Answer3.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            An1.GetComponent <Image>().color = Color.red;
            Late.GetComponent <Rigidbody2D>().WakeUp();
            Late.SetActive(true);
            van.SetActive(true);
            van.transform.Translate(Vector3.left * 200 * Time.deltaTime);
            van.GetComponent <Rigidbody2D>().AddForce(force);
            van.GetComponent <Rigidbody2D>().WakeUp();
            GameObject.Find("Target").SetActive(false);
            GameObject.Find("Player").SetActive(false);
        }
        if (Status == 2 && sleeping)
        {
            Answer1.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            Answer3.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            An2.GetComponent <Image>().color = Color.green;
            Late2.GetComponent <Rigidbody2D>().WakeUp();
            Late2.SetActive(true);
            //Late.GetComponent<Rigidbody2D>().WakeUp();
            //Late.SetActive(true);
            van.SetActive(true);
            //van.transform.Translate(Vector3.left * 200 * Time.deltaTime);
        }
        if (Status == 3 && sleeping)
        {
            Answer2.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            Answer1.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            An1.GetComponent <Image>().color = Color.green;
            Late2.GetComponent <Rigidbody2D>().WakeUp();
            Late2.SetActive(true);
            van.SetActive(true);
            //van.transform.Translate(Vector3.left * 200 * Time.deltaTime);
        }
    }
Exemple #9
0
        public override bool Equals(object obj)
        {
            var response = obj as Response;

            if (response != null)
            {
                return(ResponseID.ToString().Equals(response.ResponseID.ToString(), StringComparison.Ordinal) &&
                       RespondentID.Equals(response.RespondentID) &&
                       SurveyDate.Equals(response.SurveyDate) &&
                       Answer1.Equals(response.Answer1) &&
                       Answer2.Equals(response.Answer2) &&
                       Answer3.Equals(response.Answer3) &&
                       Answer4.Equals(response.Answer4) &&
                       Answer5.Equals(response.Answer5) &&
                       Answer6.Equals(response.Answer6));
            }

            return(false);
        }
Exemple #10
0
    // Use this for initialization
    void Start()
    {
        ans  = gameObject.AddComponent <Answer3>();
        time = timer.GetComponent <Timer>();
        for (a = 0; a < 4; a++)
        {
            for (b = 0; b < 4; b++)
            {
                var aaa = Instantiate(panel);

                aaa.transform.position = new Vector3(a * 10 - 55, b * 10 - 40, 82);
                panels [a, b]          = aaa;
                pk [a, b]     = aaa.GetComponent <panel_kaiten2> ();
                pk [a, b].x   = a;
                pk [a, b].y   = b;
                States [a, b] = false;
                //Debug.Log (States [0, 0]);
            }
        }
    }
Exemple #11
0
    // Update is called once per frame
    void Update()
    {
        Button btn1 = Answer1.GetComponent <Button>();
        Button btn2 = Answer2.GetComponent <Button>();
        Button btn3 = Answer3.GetComponent <Button>();

        btn1.onClick.AddListener(AnswerA);
        btn2.onClick.AddListener(AnswerB);
        btn3.onClick.AddListener(AnswerC);

        //print(Late.GetComponent<Rigidbody2D>().IsSleeping());

        if (Status == 1)
        {
            Answer2.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            Answer3.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            An1.GetComponent <Image>().color = Color.red;
            Late.GetComponent <Rigidbody2D>().WakeUp();
            Late.SetActive(true);
        }
        if (Status == 2)
        {
            Answer1.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            Answer3.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            An2.GetComponent <Image>().color = Color.green;
            Late.GetComponent <Rigidbody2D>().WakeUp();
            Late.SetActive(true);

            //van.transform.Translate(Vector3.left * 200 * Time.deltaTime);
        }
        if (Status == 3)
        {
            Answer2.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            Answer1.transform.Translate(Vector3.left * 1000 * Time.deltaTime);
            An1.GetComponent <Image>().color = Color.green;
            Late.GetComponent <Rigidbody2D>().WakeUp();
            Late.SetActive(true);
            //van.transform.Translate(Vector3.left * 200 * Time.deltaTime);
        }
    }
Exemple #12
0
 public async Task <bool> HandleAsync(Answer3 e, CancellationToken ct)
 {
     return(true);
 }
Exemple #13
0
        // get (Number of theme - 1)
        // return Number of question
        // or -1 if question list is empty
        private void GetQuestion(int theme)
        {
            string questNodeName = "";

            switch (theme)
            {
            case 0:
                questNodeName = "cycles";
                break;

            case 1:
                questNodeName = "arrays";
                break;

            case 2:
                questNodeName = "lines";
                break;

            case 3:
                questNodeName = "recursion";
                break;

            case 4:
                questNodeName = "struct";
                break;

            case 5:
                questNodeName = "file";
                break;

            case 6:
                questNodeName = "addresses_and_pointers";
                break;

            case 7:
                questNodeName = "dynamic_memory";
                break;

            default:
                return;
            }

            if (amount == 0)
            {
                for (int i = 0; i < MAX_QUESTIONS_TRAIN; i++)
                {
                    isOpened[i] = -1;
                }
            }

            XmlDocument doc = new XmlDocument();

            doc.Load("testing.xml");
            XmlNode rootNode = doc.DocumentElement;             // <testing>


            foreach (XmlNode themeNode in rootNode)
            {
                if (themeNode.Name == questNodeName)
                {
                    Random rnd      = new Random();
                    int    question = rnd.Next() % themeNode.ChildNodes.Count;

                    bool exit = false;
                    while (!exit)
                    {
                        int i;
                        for (i = 0; i < amount; i++)
                        {
                            if (isOpened[i] == question)
                            {
                                question = rnd.Next() % themeNode.ChildNodes.Count;
                                break;
                            }
                        }

                        if (i == amount)
                        {
                            exit = true;
                        }
                    }

                    isOpened[amount] = question;
                    amount++;

                    foreach (XmlNode questionNode in themeNode.ChildNodes[question])
                    {
                        if (questionNode.Name == "quest")
                        {
                            cur_question = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "true")
                        {
                            cur_answer = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer1")
                        {
                            Answer1.Show();
                            Answer1.Text = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer2")
                        {
                            Answer2.Show();
                            Answer2.Text = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer3")
                        {
                            Answer3.Show();
                            Answer3.Text = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer4")
                        {
                            Answer4.Show();
                            Answer4.Text = questionNode.InnerText;
                        }
                    }

                    button2.Show();
                }
            }
        }
        public ActionResult AddQuestionnaire(QuestionnairesViewModel Model, string[] BlankOptions, string[] AnswerOptions)
        {
            try
            {
                VTSDBEntities objDB = new VTSDBEntities();

                if (Model.QuestionType == DAL.Model.QuestionType.SingleLine)
                {
                    Question1 question1 = new Question1();
                    question1.QuestionSentence = Model.QuestionText;
                    question1.OriginalSentence = "";
                    List <Option1> QuesOptions = new List <Option1>();
                    foreach (string OptionText in BlankOptions)
                    {
                        Option1 EachOption = new Option1();
                        EachOption.OptionText = OptionText;
                        EachOption.Question1  = question1;
                        QuesOptions.Add(EachOption);
                    }

                    List <Answer1> AllAnswers = new List <Answer1>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer1 EachAnswer = new Answer1();
                        EachAnswer.AnswerText = AnswerText;
                        EachAnswer.Question1  = question1;
                        AllAnswers.Add(EachAnswer);
                    }

                    question1.Answer1 = AllAnswers;
                    question1.Option1 = QuesOptions;
                    objDB.Question1.Add(question1);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.MultiLine)
                {
                    Question2 question2 = new Question2();
                    question2.QuestionText = Model.QuestionText;

                    List <Option2> QuesOptions = new List <Option2>();
                    foreach (string OptionText in BlankOptions)
                    {
                        Option2 EachOption = new Option2();
                        EachOption.OptionText = OptionText;
                        EachOption.Question2  = question2;
                        QuesOptions.Add(EachOption);
                    }

                    List <Answer2> AllAnswers = new List <Answer2>();
                    Answer2        EachAnswer = new Answer2();
                    EachAnswer.Answer    = Model.AnswerText;
                    EachAnswer.Question2 = question2;
                    AllAnswers.Add(EachAnswer);


                    question2.Answer2 = AllAnswers;
                    question2.Option2 = QuesOptions;
                    objDB.Question2.Add(question2);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.SingleOption)
                {
                    Question3 question3 = new Question3();
                    question3.QuestionText = Model.QuestionText;

                    List <Answer3> AllAnswers = new List <Answer3>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer3 EachAnswer = new Answer3();
                        EachAnswer.Answer    = AnswerText;
                        EachAnswer.Question3 = question3;
                        AllAnswers.Add(EachAnswer);
                    }


                    question3.Answer3 = AllAnswers;
                    objDB.Question3.Add(question3);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.MultiOption)
                {
                    Question4 question4 = new Question4();
                    question4.QuestionText = Model.QuestionText;

                    List <Answer4> AllAnswers = new List <Answer4>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer4 EachAnswer = new Answer4();
                        EachAnswer.Answer    = AnswerText;
                        EachAnswer.Question4 = question4;
                        AllAnswers.Add(EachAnswer);
                    }

                    question4.Answer4 = AllAnswers;
                    objDB.Question4.Add(question4);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
                else if (Model.QuestionType == DAL.Model.QuestionType.Date)
                {
                    Question5 question5 = new Question5();
                    question5.QuestionText = Model.QuestionText;

                    List <Answer5> AllAnswers = new List <Answer5>();
                    foreach (string AnswerText in AnswerOptions)
                    {
                        Answer5 EachAnswer = new Answer5();
                        EachAnswer.Answer    = AnswerText;
                        EachAnswer.Question5 = question5;
                        AllAnswers.Add(EachAnswer);
                    }

                    question5.Answer5 = AllAnswers;
                    objDB.Question5.Add(question5);
                    objDB.SaveChanges();
                    ViewBag.SuccessMsg = "Questionnaire added successfully.";
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                //throw raise;
                ViewBag.ErrorMsg = "An error occurred while saving the questionnaire.";
            }

            ModelState.Clear();
            return(View());
        }