コード例 #1
0
        /// <summary>
        /// Returns a question list of the given page range that can be answered
        /// </summary>
        public QuestionData GetAnswerableQuestionListInPageRange(int surveyId, int startPageNumber, int endPageNumber)
        {
            QuestionData questions = QuestionFactory.Create().GetAnswerableQuestionListInPageRange(surveyId, startPageNumber, endPageNumber);

            this.ParseHTMLTagsFromQuestionText(questions, 80);
            return(questions);
        }
コード例 #2
0
        /// <summary>
        /// Returns a question list of the given page that can be answered
        /// </summary>
        /// <param name="surveyId">Survey id from which you want to retrieve the questions</param>
        /// <returns>A question object collection</returns>
        public QuestionData GetAnswerableQuestionList(int surveyId, int pageNumber)
        {
            QuestionData answerableQuestionList = QuestionFactory.Create().GetAnswerableQuestionList(surveyId, pageNumber);

            this.ParseHTMLTagsFromQuestionText(answerableQuestionList, 80);
            return(answerableQuestionList);
        }
コード例 #3
0
        /// <summary>
        /// Returns the question and its answers results
        /// </summary>
        public QuestionResultsData GetQuestionResults(int questionId, int filterId, string sortOrder, string languageCode, DateTime startDate, DateTime endDate)
        {
            QuestionResultsData data = QuestionFactory.Create().GetQuestionResults(questionId, filterId, sortOrder, languageCode, startDate, endDate);

            if (data.Questions.Rows.Count == 0)
            {
                throw new QuestionNotFoundException();
            }
            foreach (QuestionResultsData.QuestionsRow row in data.Questions)
            {
                if (row.QuestionText != null)
                {
                    row.QuestionText = Regex.Replace(row.QuestionText, "<[^>]*>", " ");
                    if (row.QuestionText.Length > 40)
                    {
                        row.QuestionText = row.QuestionText.Substring(0, 40) + "...";
                    }
                }
                if (row.ParentQuestionText != null)
                {
                    row.ParentQuestionText = Regex.Replace(row.ParentQuestionText, "<[^>]*>", " ");
                    if (row.ParentQuestionText.Length > 40)
                    {
                        row.ParentQuestionText = row.ParentQuestionText.Substring(0, 40) + "...";
                    }
                }
            }
            return(data);
        }
コード例 #4
0
        /// <summary>
        /// Returns a question list of the given page with only text, questionid and display order field
        /// from the given survey that have at leat one selectable answer type
        /// </summary>
        /// <param name="surveyId">Survey id from which you want to retrieve the questions</param>
        /// <returns>A question object collection</returns>
        public QuestionData GetQuestionListWithSelectableAnswers(int surveyId, int pageNumber)
        {
            QuestionData questionListWithSelectableAnswers = QuestionFactory.Create().GetQuestionListWithSelectableAnswers(surveyId, pageNumber);

            this.ParseHTMLTagsFromQuestionText(questionListWithSelectableAnswers, 80);
            return(questionListWithSelectableAnswers);
        }
コード例 #5
0
        /// <summary>
        /// Returns a question list that can be answered and that don't have any questions
        /// </summary>
        /// <param name="surveyId">Survey id from which you want to retrieve the questions</param>
        /// <returns>A question object collection</returns>
        public QuestionData GetAnswerableSingleQuestionListWithoutChilds(int surveyId)
        {
            QuestionData answerableSingleQuestionListWithoutChilds = QuestionFactory.Create().GetAnswerableSingleQuestionListWithoutChilds(surveyId);

            this.ParseHTMLTagsFromQuestionText(answerableSingleQuestionListWithoutChilds, 80);
            return(answerableSingleQuestionListWithoutChilds);
        }
コード例 #6
0
        /// <summary>
        /// Import the given questions into the DB
        /// </summary>
        public void ImportQuestions(NSurveyQuestion importQuestions, int userId)
        {
            IQuestion question = QuestionFactory.Create();

            this.TurnOverPrimaryKeys(importQuestions);
            question.ImportQuestions(importQuestions, userId);
        }
コード例 #7
0
ファイル: QuestionAPI.cs プロジェクト: Malipaard/Rockstar-S2
        public string Validate(int id, string answer, string userName)
        {
            IQuestionDAL questionDal = QuestionFactory.GetQuestionDAL();
            Question     question    = questionDal.GetQuestion(id);

            if (!questionDal.QuestionIsAlreadyAnswered(userName, id))
            {
                if (answer == question.CorrectAnswer)
                {
                    IAccountDAL accountDAL = AccountFactory.GetAccountDAL();
                    Account     account    = accountDAL.GetAccount(userName);
                    accountDAL.AddScore(account, 10);
                    questionDal.QuestionAnswered(userName, id);
                    return("Question answered correctly");
                }
                else
                {
                    questionDal.QuestionAnswered(userName, id);
                    return("Question answered incorrectly");
                }
            }
            else
            {
                return("Question already answered");
            }

            // id = 2
            // answer = 'correct'
        }
コード例 #8
0
        /// <summary>
        /// Returns all question listed in the library without their child questions
        /// </summary>
        public QuestionData GetLibraryQuestionListWithoutChilds(int libraryId)
        {
            QuestionData libraryQuestionListWithoutChilds = QuestionFactory.Create().GetLibraryQuestionListWithoutChilds(libraryId);

            this.ParseHTMLTagsFromQuestionText(libraryQuestionListWithoutChilds, 80);
            return(libraryQuestionListWithoutChilds);
        }
コード例 #9
0
        /// <summary>
        /// Returns all question listed in the library
        /// </summary>
        public QuestionData GetLibraryQuestionList(int libraryId)
        {
            QuestionData libraryQuestionList = QuestionFactory.Create().GetLibraryQuestionList(libraryId);

            this.ParseHTMLTagsFromQuestionText(libraryQuestionList, 80);
            return(libraryQuestionList);
        }
コード例 #10
0
        public IEnumerable <IQuestion> Convert()
        {
            var sheet = _workbook.GetSheet(_reportSheetName);

            IRow lastRow   = null;
            var  lastRowId = "";

            // Loop through each row (skipping first row).
            for (var rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++)
            {
                var row = sheet.GetRow(rowNum);

                var currentRowId = row.GetCell(0)?.StringCellValue;

                if (currentRowId != null &&
                    !currentRowId.Equals(lastRowId, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (lastRow != null)
                    {
                        // Create question from last row.
                        yield return(QuestionFactory.Build(lastRow));
                    }

                    // Set new last row.
                    lastRow   = row;
                    lastRowId = currentRowId;
                }
            }

            // Handle last row
            yield return(QuestionFactory.Build(lastRow));
        }
コード例 #11
0
        public ActionResult Question()
        {
            QuestionFactory       TF           = new QuestionFactory();
            List <QuestionEntity> QuestionList = TF.GetQuestion().ToList();

            return(View(QuestionList));
        }
コード例 #12
0
ファイル: QuestionAPI.cs プロジェクト: Malipaard/Rockstar-S2
        public IActionResult Create(Question question)
        {
            IQuestionDAL dal = QuestionFactory.GetQuestionDAL();

            dal.Create(question);
            return(Accepted());
        }
コード例 #13
0
        public void CompareOutputAgainstGoldenSource([Range(0, 99)] int seed)
        {
            // Arrange
            var gameOutputStringBuilder = new StringBuilder();

            using (var gameOutput = new StringWriter(gameOutputStringBuilder))
            {
                Console.SetOut(gameOutput);
                var dice = new Dice();
                var consoleGameLogger = new ConsoleGameLogger();
                var categorySelector  = new CategorySelector();
                var questionFactory   = new QuestionFactory();
                var game   = new Game(consoleGameLogger, categorySelector, questionFactory);
                var random = new Random(seed);
                var randomAnsweringStrategy = new RandomAnsweringStrategy(random);

                var gameRunner = new GameRunner(dice, randomAnsweringStrategy, random, game);

                // Act
                gameRunner.Start();

                // Assert
                var actualGameOutput   = gameOutputStringBuilder.ToString();
                var expectedGameOutput = File.ReadAllText($@"c:\TestData\GoldenData_{seed}.txt");
                actualGameOutput.Should().BeEquivalentTo(expectedGameOutput);
            }
        }
コード例 #14
0
 private static void FillQuizzes(QuizRepository quizzes)
 {
     quizzes.CreateQuiz
     (
         "Test quiz",
         QuestionFactory.Create("Some question 1?",
                                ChoiceFactory.Create("Meh 1", 0),
                                ChoiceFactory.Create("Kinda 1", 5),
                                ChoiceFactory.Create("Yes 1!", 10)),
         QuestionFactory.Create("Some question 2?",
                                ChoiceFactory.Create("Meh 2", 0),
                                ChoiceFactory.Create("Kinda 2", 5),
                                ChoiceFactory.Create("Yes 2!", 10)),
         QuestionFactory.Create("Some question 3?",
                                ChoiceFactory.Create("Meh 3", 0),
                                ChoiceFactory.Create("Kinda 3", 5),
                                ChoiceFactory.Create("Yes 3!", 10))
     );
     quizzes.CreateQuiz
     (
         "Test quiz 2",
         QuestionFactory.Create("Some question 1?",
                                ChoiceFactory.Create("Meh 1", 0),
                                ChoiceFactory.Create("Kinda 1", 5),
                                ChoiceFactory.Create("Yes 1!", 10)),
         QuestionFactory.Create("Some question 2?",
                                ChoiceFactory.Create("Meh 2", 0),
                                ChoiceFactory.Create("Kinda 2", 5),
                                ChoiceFactory.Create("Yes 2!", 10)),
         QuestionFactory.Create("Some question 3?",
                                ChoiceFactory.Create("Meh 3", 0),
                                ChoiceFactory.Create("Kinda 3", 5),
                                ChoiceFactory.Create("Yes 3!", 10))
     );
 }
コード例 #15
0
        public ActionResult DeleteQuestion(long id, FormCollection collection)
        {
            try
            {
                QuestionFactory DeleteQuestion = new QuestionFactory();
                QuestionEntity  Question       = new QuestionEntity();
                Question = DeleteQuestion.GetQuestionById(id);

                DataLayer.tblQuestion NewQuestion = new DataLayer.tblQuestion();
                NewQuestion.QuestionId  = id;
                NewQuestion.QuizId      = Question.QuizId;
                NewQuestion.Question    = Question.Question;
                NewQuestion.CreatedDate = Question.CreatedDate;
                NewQuestion.CreatedBy   = Question.CreatedBy;
                NewQuestion.UpdatedDate = DateTime.Now;
                NewQuestion.UpdatedBy   = null;
                NewQuestion.IsActive    = false; // IsActive will be false in delete record

                DeleteQuestion.SaveQuestion(NewQuestion);

                return(RedirectToAction("Question"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #16
0
        public QuestionnaireViewModel(IQuestionnaireService questionnaireService, QuestionFactory questionFactory,
                                      IFrameNavigationService navigationService, IFestivalService festivalService, IOfflineService offlineService, IConfiguration config)
        {
            _config = config;
            _questionnaireService = questionnaireService;
            _navigationService    = navigationService;
            _questionFactory      = questionFactory;
            _festivalService      = festivalService;
            _offlineService       = offlineService;

            Initialize((int)_navigationService.Parameter);

            AddedQuestions         = new ObservableCollection <Question>();
            RemovedQuestions       = new ObservableCollection <Question>();
            OpenDeleteCheckCommand = new RelayCommand <Question>(DeleteCommandCheck, _ => offlineService.IsOnline, true);
            AddQuestionCommand     = new RelayCommand(AddQuestion, () => SelectedItem != null, true);
            // DeleteQuestionCommand = new RelayCommand<Question>(DeleteQuestion, _ => offlineService.IsOnline, true);
            DeleteCommand = new RelayCommand(DeleteQuestion, () => offlineService.IsOnline, true);
            DeleteQuestionnaireCommand     = new RelayCommand(DeleteQuestionnaire, () => offlineService.IsOnline, true);
            SaveQuestionnaireCommand       = new RelayCommand(SaveQuestionnaire, () => offlineService.IsOnline, true);
            OpenFileWindowCommand          = new RelayCommand <Question>(OpenFileWindow, HasAnswers);
            AddOptionToQuestion            = new RelayCommand <Question>(AddOption, _ => offlineService.IsOnline, true);
            SelectReferenceQuestionCommand =
                new RelayCommand <ReferenceQuestion>(SelectReferenceQuestion, _ => offlineService.IsOnline, true);
            SetReferenceQuestionCommand =
                new RelayCommand <Question>(SetReferenceQuestion, _ => offlineService.IsOnline, true);

            QuestionList        = (CollectionView)CollectionViewSource.GetDefaultView(_allQuestions());
            QuestionList.Filter = Filter;
        }
コード例 #17
0
        public StudentFormController(Student.QuestionForm mainform)
        {
            this.mainForm = mainform;
            view = mainForm.getView();

            //Connect (this) client to the session
            client = SignalRClient.GetInstance();
            client.ConnectionStatusChanged += Client_connectionStatusChanged;
            client.Connect();

            //Adds an event to the QuestionAdded function which is called when a new question is added by the teacher.
            QuestionFactory questionFactory = new QuestionFactory();
            questionFactory.QuestionAdded += Factory_questionAdded;

            //Adds an event to the QuestionListContinue function which is called when the teacher presses "Next" button for the next question.
            QuestionListFactory listFactory = new QuestionListFactory();
            listFactory.QuestionListContinue += LIFactory_continue;
            listFactory.QuestionListStarted += LIFactory_startList;
            listFactory.QuestionListStopped += LIFactory_stopped;

            //Adds an event to the PredefinedAnswerAdded function which is called for each PredefinedAnswer in the next question.
            PredefinedAnswerFactory PAFactory = new PredefinedAnswerFactory();
            PAFactory.PredefinedAnswerAdded += PAFactory_predefinedAnswerAdded;

            //Adds event, when an openquestion is added
            OpenQuestionFactory OpenQuestionFactory = new OpenQuestionFactory();
            OpenQuestionFactory.OpenQuestionAdded += openQuestionAdded;
        }
コード例 #18
0
        public void QuizRepository_CreateWithChoices_HasChoices()
        {
            const string quizName = "Quiz name";

            var question1 = QuestionFactory.Create("Some question",
                                                   ChoiceFactory.Create("Some choice", 10),
                                                   ChoiceFactory.Create("Some other choice", 0),
                                                   ChoiceFactory.Create("Some third choice", 20)
                                                   );
            var question2 = QuestionFactory.Create("Some other question",
                                                   ChoiceFactory.Create("Some choice", 10),
                                                   ChoiceFactory.Create("Some other choice", 0)
                                                   );

            var repo = QuizRepository.Instance;
            var quiz = repo.CreateQuiz(quizName, question1, question2);

            Assert.That(quiz.Questions.Count, Is.EqualTo(2));
            Assert.That(quiz.Questions[0].QuestionString, Is.EqualTo("Some question"));
            Assert.That(quiz.Questions[0].Choices.Count, Is.EqualTo(3));
            Assert.That(quiz.Questions[0].Choices[1].ChoiceText, Is.EqualTo("Some other choice"));
            Assert.That(quiz.Questions[0].Choices[2].Value, Is.EqualTo(20));
            Assert.That(quiz.Questions[1].QuestionString, Is.EqualTo("Some other question"));
            Assert.That(quiz.Questions[1].Choices.Count, Is.EqualTo(2));
            Assert.That(quiz.Questions[1].Choices[0].ChoiceText, Is.EqualTo("Some choice"));
            Assert.That(quiz.Questions[1].Choices[1].Value, Is.EqualTo(0));
        }
コード例 #19
0
        public void Create_WithFT_WillCreateAFreeTextQuestion()
        {
            var questionFactory = new QuestionFactory();

            var question = questionFactory.Create(new StringReader("Q1 FT Name"));

            Assert.IsInstanceOf(typeof(FreeTextQuestion), question);
        }
コード例 #20
0
        public void Create_WithSC_WillCreateASingleChoiceQuestion()
        {
            var questionFactory = new QuestionFactory();

            Base question = questionFactory.Create(new StringReader("SC Sex 2 Female Male"));

            Assert.IsInstanceOf(typeof(SingleChoiceQuestion), question);
        }
コード例 #21
0
        public void Create_WhenQuestionOfTypeFT_WillReturnFreeText()
        {
            var questionFactory = new QuestionFactory();

            var freeTextQuestion = questionFactory.Create(new StringReader("FT Numele"));

            Assert.That(freeTextQuestion.Name, Is.EqualTo("Numele"));
        }
コード例 #22
0
        public void CreateQuestion_Always_WillreturnAFreeTExtQuestion()
        {
            QuestionFactory questionFactory = new QuestionFactory();

            var question = questionFactory.CreateQuestion("Q1 FT Numele");

            Assert.IsInstanceOf(typeof(FreeTextQuestion), question);
        }
コード例 #23
0
        public void Create_WhenFT_WillReturnAFreeTextQuestion()
        {
            var questionFactory = new QuestionFactory();

            Base question = questionFactory.Create(new StringReader("FT Name"));

            Assert.IsInstanceOf(typeof(FreeTextQuestion), question);
        }
コード例 #24
0
        public void QuestionFactory()
        {
            IQuestionProvider qf = new QuestionFactory();
            var next             = qf.GetNextQuestion();
            var byId             = qf.GetQuestionById(next.Id);

            Assert.AreEqual(next.Question, byId.Question);
        }
コード例 #25
0
        public void CreateQuestion_WillCreateAQuestion()
        {
            IQuestionFactory questionFactory = new QuestionFactory();

            var question = questionFactory.CreateQuestion("Q1 FT Numele");

            Assert.IsInstanceOf(typeof(IQuestion), question);
        }
コード例 #26
0
        public void CreateQuestion_Always_WillCreateAFreeTextQuestion()
        {
            var questionFactory = new QuestionFactory();

            Base question = questionFactory.Create(new StringReader("Q1 Name"));

            Assert.IsInstanceOf(typeof(FreeTextQuestion), question);
        }
コード例 #27
0
        // GET: Question/Delete/5
        public ActionResult DeleteQuestion(long id)
        {
            QuestionFactory EditQuestion = new QuestionFactory();
            QuestionEntity  topic        = new QuestionEntity();

            topic = EditQuestion.GetQuestionById(id);
            return(View(topic));
        }
コード例 #28
0
        public void CreateQuestion_WillReturnAFreeTextQuestion()
        {
            QuestionFactory questionFactory = new QuestionFactory();

            var question = questionFactory.CreateQuestion(new StringReader("Q1 Name"));

            Assert.IsInstanceOf(typeof(FreeTextQuestion), question);
        }
コード例 #29
0
        public void Create_WithMC_WillCallCreateonAMultipleChoiceQuestion()
        {
            var mockMultipleChoiceQuestionFactory = new Mock <MultipleChoiceQuestionFactory>();
            var questionFactory = new QuestionFactory {
                MultipleChoiceQuestion = mockMultipleChoiceQuestionFactory.Object
            };

            Base question = questionFactory.Create(new StringReader("MC Optiuni 3 op1 op2 op3"));
        }
コード例 #30
0
        public void CreateQuestion_WWithFT_WillCreateAFreeTextQuestion()
        {
            QuestionFactory questionFactory = new QuestionFactory();

            var question = questionFactory.CreateQuestion("Q1 FT Numele");

            Assert.IsInstanceOf(typeof(FreeTextQuestion), question);
            Assert.That("Numele", Is.EqualTo(question.Text));
        }
コード例 #31
0
        public void CreateQuestion_WithFT_WillCreateAFreeTExtQuestion()
        {
            QuestionFactory questionFactory = new QuestionFactory();

            var question = questionFactory.CreateQuestion(new StringReader("Q1 Name"));

            Assert.IsInstanceOf(typeof(FreeTextQuestion), question);
            Assert.AreEqual("Name", question.Text);
        }
コード例 #32
0
        //This function will check if the list has been received correctly from the function underneath.
        private void listStartedCallbackHandler(Model.QuestionList list, HttpStatusCode status)
        {
            if (status != HttpStatusCode.OK)
            {
                MessageBox.Show("Er ging wat mis met het fetchen van de lijst, probeer het opnieuw.");
            }
            else
            {
                mainForm.getQuestionList().Id = list.Id;
                mainForm.getQuestionList().Name = list.Name;
                mainForm.getQuestionList().Ended = list.Ended;
                mainForm.getQuestionList().Position = list.Position;
                mainForm.getQuestionList().Ended = false;

                QuestionFactory questionFactory = new QuestionFactory();
                questionFactory.FindAll(mainForm.getView().GetHandler(),addQuestionsCallbackHandler);
            }
        }