public QuestionnaireWindow(EyetrackerEntities db, Test test, Questionnaire questionnaire)
 {
     InitializeComponent();
     Db = db;
     QuestionnaireAnswer = new QuestionnaireAnswer(test, questionnaire);
     if (test.start_time == null)
     {
         test.start_time = DateTime.Now;
     }
     DataContext = QuestionnaireAnswer;
 }
Пример #2
0
 public QuestionnaireAnswerViewModel(QuestionnaireAnswer answer)
 {
     QuestionText    = Culture.IsSpanish ? answer.Question.QuestionEs : answer.Question.QuestionEn;
     AnswerType      = answer.Question.AnswerType;
     SliderValue     = answer.SliderValue;
     OptionText      = Culture.IsSpanish ? answer.OptionsValue?.Es : answer.OptionsValue?.En;
     ForOrganisation = answer.Question.ForOrganisation;
     if (AnswerType == AnswerType.Slider)
     {
         FaceType = answer.Question.SliderInfo !.FaceType;
         Options  = answer.Question.SliderInfo !.EffectiveTextStops.Select(x => Culture.IsSpanish ? x.Es : x.En).ToList();
     }
     else if (AnswerType == AnswerType.Options)
     {
         Options = answer.Question.Options !.Select(x => Culture.IsSpanish ? x.Es : x.En).ToList();
     }
 }
 public ActionResult Create(QuestionnaireAnswerModel model)
 {
     if (ModelState.IsValid)
     {
         QuestionnaireAnswer info = new QuestionnaireAnswer();
         info.Id             = Guid.NewGuid();
         info.Title          = model.Title;
         info.QuestionType   = model.QuestionType;
         info.QuestionInfoId = model.QuestionInfoId;
         QuestionnaireAnswerService.Add(info);
         return(Json(new AjaxResult()
         {
             Result = Result.Success
         }));
     }
     return(View(PluginHelper.GetViewPath(this.GetType(), "Create"), model));
 }
Пример #4
0
        //public int BatchDelete(Expression<Func<QuestionnaireAnswer, bool>> filterExpression)
        //{
        //    using (var repository = new Repository<QuestionnaireAnswer>())
        //    {
        //        return repository.BatchDelete(filterExpression);
        //    }
        //}

        public void Delete(QuestionnaireAnswer info)
        {
            repository.Delete(info);
        }
Пример #5
0
        public void Update(QuestionnaireAnswer info)
        {
            var query = repository.Table;

            repository.Update(info);
        }
Пример #6
0
        public void Add(QuestionnaireAnswer info)
        {
            var query = repository.Table;

            repository.Insert(info);
        }
        public IActionResult Index(Questionnaire questionnaire, IFormCollection collection)
        {
            if (string.IsNullOrEmpty(questionnaire.FirstName) && string.IsNullOrEmpty(questionnaire.LastName))
            {
                ModelState.AddModelError("FirstName", "The field FirstName must be input");
                ModelState.AddModelError("LastName", "The field LastName must be input");
            }
            else if (string.IsNullOrEmpty(questionnaire.FirstName))
            {
                ModelState.AddModelError("FirstName", "The field First Name must be input");
            }
            else if (string.IsNullOrEmpty(questionnaire.LastName))
            {
                ModelState.AddModelError("LastName", "The field Last Name must be input");
            }
            else if (questionnaire.FirstName == questionnaire.LastName)
            {
                ModelState.AddModelError("FirstName", "First and last name can't match!");
            }
            else if (questionnaire.FirstName.Contains("Admin") || questionnaire.LastName.Contains("Admin"))
            {
                ModelState.AddModelError("FirstName", "Admin name is not available!");
            }

            if (ModelState.IsValid)
            {
                QuestionnaireAnswer qaDto = new QuestionnaireAnswer()
                {
                    Answer = collection["genre"],
                };
                QuestionnaireAnswer qa2Dto = new QuestionnaireAnswer
                {
                    Answer = collection["language"],
                };
                QuestionnaireAnswer qa3Dto = new QuestionnaireAnswer
                {
                    Answer = collection["age"] == "true,false" ? "Yes" : "No",
                };

                var questionnaireDto = new Questionnaire()
                {
                    Id                   = questionnaire.Id,
                    FirstName            = questionnaire.FirstName,
                    LastName             = questionnaire.LastName,
                    QuestionnaireAnswers = new List <QuestionnaireAnswer>
                    {
                        qaDto, qa2Dto, qa3Dto
                    }
                };

                List <string> answerList = new List <string> {
                    collection["genre"], collection["language"], collection["age"] == "true,false" ? "Yes" : "No"
                };

                ViewBag.answerList = answerList;

                db.Questionnaires.Add(questionnaireDto);

                db.SaveChanges();

                return(View("Result", questionnaire));
            }

            return(View("Index", new Questionnaire()));
        }
Пример #8
0
 /// <summary>
 /// 計算問卷填答得分
 /// </summary>
 /// <param name="answer">問卷填答資料</param>
 /// <returns></returns>
 public QuestionnaireResult Calculate(QuestionnaireAnswer answer)
 {
     return(null);
 }
Пример #9
0
        private static void SerializeQuestionnaireAnswers()
        {
            QuestionnaireAnswers answers = new QuestionnaireAnswers();

            QuestionnaireAnswer a1 = new QuestionnaireAnswer();
            a1.QuestionID = "1";
            a1.Value = "1";

            QuestionnaireAnswer a2 = new QuestionnaireAnswer();
            a2.QuestionID = "2";
            a2.Value = "0";

            answers.Answers.Add(a1);
            answers.Answers.Add(a2);

            SerializeMe(answers, "QuestionnaireAnswers.xml");
        }
Пример #10
0
        public static void Seed(LibraryContext context)
        {
            if (!context.Articles.Any())
            {
                Article a1 = new Article {
                    Title = "Winter colds and small amounts", Date = new DateTime(2021, 2, 10), Text = "Winter colds and small amounts of sunshine make feel us weak. The stores of vitamins in the body are significantly reduced during the winter. Weather shifts can affect immunity. As a result, a lot of people feel unwell with the start of spring. The sun is shining, flowers blossom, temperatures are rising and nature awakens from winter sleep. Spring is a beautiful time, isn’t it? Along with positive changes, it’s also the time when our body lacks vitamins, that is so-called avitaminosis."
                };
                Article a2 = new Article {
                    Title = "Self-discipline", Date = new DateTime(2021, 2, 11), Text = "Just understand that time is not your enemy but your friend. You can do so many things if you have goals and opportunities. The main thing is to organize yourself and your time correctly. It refers not only to work but also to other aspects of your life. Self-discipline is a key to success. A person who can’t control his life and be organized, so he can’t achieve the desired success. If you can’t achieve anything, it may cause stress, reduce productivity and disorganization. You get caught in a vicious circle!"
                };
                Article a3 = new Article {
                    Title = "Emotions", Date = new DateTime(2021, 2, 11), Text = "Psychologists refer fear as a basic “emotion” that we experience it daily at work, at school, in the street, at home, everywhere. Fear mainly arises from 2 sources:  your personality and uncertainty. Many people are afraid of different things: water, height, pain, failure, death. They may have the same fear, but their behavior is shown in absolutely different ways: some people start to panic, other can’t control their emotions, etc. In this article we will talk about a common phobia called “stage fright”."
                };

                Article a4 = new Article {
                    Title = "Winter colds and small amounts 2", Date = new DateTime(2021, 2, 12), Text = "Winter colds and small amounts of sunshine make feel us weak. The stores of vitamins in the body are significantly reduced during the winter. Weather shifts can affect immunity. As a result, a lot of people feel unwell with the start of spring. The sun is shining, flowers blossom, temperatures are rising and nature awakens from winter sleep. Spring is a beautiful time, isn’t it? Along with positive changes, it’s also the time when our body lacks vitamins, that is so-called avitaminosis."
                };
                Article a5 = new Article {
                    Title = "Self-discipline 2", Date = new DateTime(2021, 2, 12), Text = "Just understand that time is not your enemy but your friend. You can do so many things if you have goals and opportunities. The main thing is to organize yourself and your time correctly. It refers not only to work but also to other aspects of your life. Self-discipline is a key to success. A person who can’t control his life and be organized, so he can’t achieve the desired success. If you can’t achieve anything, it may cause stress, reduce productivity and disorganization. You get caught in a vicious circle!"
                };
                Article a6 = new Article {
                    Title = "Emotions 2", Date = new DateTime(2021, 2, 13), Text = "Psychologists refer fear as a basic “emotion” that we experience it daily at work, at school, in the street, at home, everywhere. Fear mainly arises from 2 sources:  your personality and uncertainty. Many people are afraid of different things: water, height, pain, failure, death. They may have the same fear, but their behavior is shown in absolutely different ways: some people start to panic, other can’t control their emotions, etc. In this article we will talk about a common phobia called “stage fright”."
                };

                Article a7 = new Article {
                    Title = "Winter colds and small amounts 3", Date = new DateTime(2021, 2, 14), Text = "Winter colds and small amounts of sunshine make feel us weak. The stores of vitamins in the body are significantly reduced during the winter. Weather shifts can affect immunity. As a result, a lot of people feel unwell with the start of spring. The sun is shining, flowers blossom, temperatures are rising and nature awakens from winter sleep. Spring is a beautiful time, isn’t it? Along with positive changes, it’s also the time when our body lacks vitamins, that is so-called avitaminosis."
                };
                Article a8 = new Article {
                    Title = "Self-discipline 3", Date = new DateTime(2021, 2, 14), Text = "Just understand that time is not your enemy but your friend. You can do so many things if you have goals and opportunities. The main thing is to organize yourself and your time correctly. It refers not only to work but also to other aspects of your life. Self-discipline is a key to success. A person who can’t control his life and be organized, so he can’t achieve the desired success. If you can’t achieve anything, it may cause stress, reduce productivity and disorganization. You get caught in a vicious circle!"
                };
                Article a9 = new Article {
                    Title = "Emotions 3", Date = new DateTime(2021, 2, 14), Text = "Psychologists refer fear as a basic “emotion” that we experience it daily at work, at school, in the street, at home, everywhere. Fear mainly arises from 2 sources:  your personality and uncertainty. Many people are afraid of different things: water, height, pain, failure, death. They may have the same fear, but their behavior is shown in absolutely different ways: some people start to panic, other can’t control their emotions, etc. In this article we will talk about a common phobia called “stage fright”."
                };

                Comment c1 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 10)
                };
                Comment c2 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 11)
                };
                Comment c3 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 12)
                };

                Comment c4 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 13)
                };
                Comment c5 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 14)
                };
                Comment c6 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 14)
                };

                Comment c7 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 15)
                };
                Comment c8 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 15)
                };
                Comment c9 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 15)
                };

                CommentText commentText = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c1
                };
                CommentText commentText1 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c2
                };
                CommentText commentText2 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c3
                };
                CommentText commentText3 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c4
                };
                CommentText commentText4 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c5
                };
                CommentText commentText5 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c6
                };
                CommentText commentText6 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c7
                };
                CommentText commentText7 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c8
                };
                CommentText commentText8 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c9
                };

                Questionnaire questionnaire = new Questionnaire();

                questionnaire.FirstName = "Pavlo";
                questionnaire.LastName  = "Kalenyk";

                QuestionnaireAnswer questionnaireAnswer = new QuestionnaireAnswer();

                questionnaireAnswer.Answer = "Fantastic";

                QuestionnaireAnswer questionnaireAnswer2 = new QuestionnaireAnswer();

                questionnaireAnswer2.Answer = "English";

                QuestionnaireAnswer questionnaireAnswer3 = new QuestionnaireAnswer();

                questionnaireAnswer3.Answer = "Yes";

                questionnaire.QuestionnaireAnswers.Add(questionnaireAnswer);
                questionnaire.QuestionnaireAnswers.Add(questionnaireAnswer2);
                questionnaire.QuestionnaireAnswers.Add(questionnaireAnswer3);

                Tag t1 = new Tag {
                    Name = "news"
                };
                Tag t2 = new Tag {
                    Name = "2020"
                };
                Tag t3 = new Tag {
                    Name = "cool"
                };

                t1.Articles = new List <Article> {
                    a1, a2, a7, a8, a9
                };
                t2.Articles = new List <Article> {
                    a2, a4, a5, a6
                };
                t3.Articles = new List <Article> {
                    a3, a4, a5, a6
                };

                context.Articles.AddRange(a1, a2, a3, a4, a5, a6, a7, a8, a9);

                context.Comments.AddRange(c1, c2, c3, c4, c5, c6, c7, c8, c9);

                context.CommentText.AddRange(commentText, commentText1, commentText2, commentText3, commentText4, commentText5, commentText6, commentText7, commentText8);

                context.Tags.Add(t1);
                context.Tags.Add(t2);
                context.Tags.Add(t3);

                context.Questionnaires.Add(questionnaire);

                context.SaveChanges();
            }
        }