Exemplo n.º 1
0
        private static IQuiz GetQuizChoice(QuizRepository quizRepository)
        {
            IQuiz result = null;

            do
            {
                Console.Write("Which quiz would you like to take? ");

                int quizNum;
                if (!int.TryParse(Console.ReadLine(), out quizNum))
                {
                    Console.WriteLine("That is not a quiz number!!");
                    continue;
                }

                try
                {
                    result = quizRepository[--quizNum];
                }
                catch (ArgumentOutOfRangeException)
                {
                    Console.WriteLine("Cannot find that quiz...");
                }
            } while (null == result);

            return(result);
        }
Exemplo n.º 2
0
        ///<summary>
        ///Busca os questionários de questionários de uma firma
        /// </summary>
        public List <QuizDTO> GetAllFromFirmDTO(int firmId, string search, int pageIndex, int pageSize)
        {
            QuizRepository repository = new QuizRepository();

            List <QuizEntity> list = this.GetAllFromFirm(firmId, search, pageIndex, pageSize);

            List <QuizDTO> listTO = new List <QuizDTO>();

            foreach (var item in list)
            {
                QuizDTO to = new QuizDTO()
                {
                    CreatedBy      = item.CreatedBy,
                    Description    = item.Description,
                    FirmId         = item.FirmId,
                    Id             = item.Id,
                    IdQuizQuestion = item.IdQuizQuestion,
                    InitialDate    = item.InitialDate,
                    IsMultiple     = item.IsMultiple,
                    LastUpdate     = item.LastUpdate,
                    Name           = item.Name,
                    Required       = item.Required,
                    Score          = item.Score,
                    UpdatedBy      = item.UpdatedBy,
                    DateLimit      = item.DateLimit,
                    status         = item.status,
                };
                QuizQuestionRepository questionRepository = new QuizQuestionRepository();

                to.QtdPerguntas = questionRepository.Get(x => x.IdQuiz == item.Id).Count();
                listTO.Add(to);
            }

            return(listTO);
        }
Exemplo n.º 3
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))
     );
 }
        /// <summary>
        /// Funkcja wykonująca się gdy otrzyma się wiadomość
        /// </summary>
        private void ReceiveChoosenTest(Test obj)
        {
            //pobierz pytania
            _questions        = QuizRepository.GetQuestionsByTestID(obj.ID);
            NumberOfQuestions = _questions.Length;
            //ustaw aktualne pytanie na pierwsze pytanie
            CurrentQuestion = _questions[0];

            //Rezerwujemy dla każdej tablicy 4 elementy (odpowiedzi ABCD)
            _userAnswersABCDCheckBoxes = new bool[NumberOfQuestions][];
            for (int i = 0; i < NumberOfQuestions; i++)
            {
                _userAnswersABCDCheckBoxes[i] = new bool[4];
            }

            _userAnswers = new string[NumberOfQuestions][];
            //ustaw przycisk na "Zakończ" lub "Następne" w zależności od ilości pytań
            if (NumberOfQuestions > 1)
            {
                _nextQuestionOrEndQuiz = NextQuestionContentValue.Następne.ToString();
            }
            else
            {
                _nextQuestionOrEndQuiz = NextQuestionContentValue.Zakończ.ToString();
            }

            //ustaw temat na ten który otrzymałeś
            Test     = obj;
            TimeLeft = Test.Time;
        }
Exemplo n.º 5
0
        protected Quiz()
        {
            IQuizRepository   quizRepository   = new QuizRepository();
            IQuestionsService questionsService = new QuestionsService(quizRepository);

            _gameService = new GameService(questionsService);
        }
Exemplo n.º 6
0
        public FlagQuizController()
        {
            var quizRepository = new QuizRepository();

            _flagRepository = new FlagRepository();
            _game           = quizRepository.Get(1);
        }
Exemplo n.º 7
0
        public ActionResult AddQuestion(int id)
        {
            FillDropdownValues();
            var model = QuizRepository.Find(id);

            return(View(model));
        }
Exemplo n.º 8
0
        public QuizContollerTest()
        {
            int loggedInCustomerId = new LoginInfo().GetAuthenticatedId();


            quiz1 = new Quiz {
                Name = "Quiz Test", CourseID = 2, CreatedDate = DateTime.Now, IsActive = true, UserID = loggedInCustomerId
            };
            quiz2 = new Quiz {
                Name = "Quiz Test 2", CourseID = 3, CreatedDate = DateTime.Now, IsActive = true, UserID = loggedInCustomerId
            };


            quizList = new List <Quiz> {
                quiz1, quiz2
            };


            // Lets create our dummy repository
            quizRepo = new UserRepository(quizList);

            // Let us now create the Unit of work with our dummy repository
            uow = new OperationResult(quizRepo);

            // Now lets create the BooksController object to test and pass our unit of work
            controller = new QuizController(uow);
        }//end UserControllerTest
Exemplo n.º 9
0
        ///<summary>
        ///Ativa questionário
        /// </summary>
        public void Activating(int id)
        {
            QuizRepository repository = new QuizRepository();
            QuizEntity     quiz       = repository.GetById(id);

            quiz.status = true;
            repository.update(quiz);
        }
Exemplo n.º 10
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            IQuizRepository quizRepo = new QuizRepository();

            Application.Run(new MainForm(quizRepo));
        }
Exemplo n.º 11
0
        public WelcomeViewModel()
        {
            //Przypisanie wywoływacza przycisku "Start"
            StartQuizCommand = new RelayCommand(SendQuiz, () => isSelected);

            //Ładuje testy
            Tests = QuizRepository.GetTests();
        }
Exemplo n.º 12
0
        private static void ListQuizzes(QuizRepository quizRepository)
        {
            var i = 0;

            quizRepository.ForEach(q =>
            {
                Console.WriteLine("{0} {1}", (++i).ToString().PadRight(3), q.Name);
            });
        }
Exemplo n.º 13
0
 public void ResetRepositories()
 {
     _quizRepository     = null;
     _ruleRepository     = null;
     _stageRepository    = null;
     _questionRepository = null;
     _endingRepository   = null;
     _fileRepository     = null;
 }
Exemplo n.º 14
0
        public IRepository <Common.Quiz, Guid> GetQuizRepository()
        {
            if (quizRepository == null)
            {
                quizRepository = new QuizRepository(context);
            }

            return(quizRepository);
        }
Exemplo n.º 15
0
        public JsonResult Delete(int id)
        {
            QuizRepository.Delete(id);
            QuizRepository.Save();

            return(new JsonResult()
            {
                Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 16
0
        // GET: Home
        public ActionResult Index()
        {
            var courses = new CourseRepository();

            ViewBag.courses = courses.GetCourses(3);

            var quizzes = new QuizRepository();

            ViewBag.quizzes = quizzes.GetQuizzes(3);

            return(View());
        }
Exemplo n.º 17
0
        public ActionResult Create(Quiz model)
        {
            if (ModelState.IsValid)
            {
                QuizRepository.Insert(model);
                QuizRepository.Save();
                return(RedirectToAction("Index"));
            }

            FillDropdownValues();
            return(View(model));
        }
Exemplo n.º 18
0
        public void Dispose()
        {
            if (_transaction != null)
            {
                _transaction.Dispose();
                _transaction = null;
            }

            if (_quizRepository != null)
            {
                _quizRepository.Dispose();
                _quizRepository = null;
            }

            if (_ruleRepository != null)
            {
                _ruleRepository.Dispose();
                _ruleRepository = null;
            }

            if (_stageRepository != null)
            {
                _stageRepository.Dispose();
                _stageRepository = null;
            }

            if (_questionRepository != null)
            {
                _questionRepository.Dispose();
                _questionRepository = null;
            }

            if (_endingRepository != null)
            {
                _endingRepository.Dispose();
                _endingRepository = null;
            }

            if (_fileRepository != null)
            {
                _fileRepository.Dispose();
                _fileRepository = null;
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }
        }
Exemplo n.º 19
0
        public JsonResult DeleteQuestion(int id, int quizId)
        {
            var modelQuestion = QuestionRepository.Find(id);
            var modelQuiz     = QuizRepository.Find(quizId);

            modelQuiz.Questions.Remove(modelQuestion);
            QuizRepository.Update(modelQuiz);
            QuizRepository.Save();

            return(new JsonResult()
            {
                Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 20
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            var dbConfig = Configuration.GetSection("dbconfig").Get <CustomConfig>();

            services.AddSingleton(dbConfig);

            var mongoClient = new MongoClient(dbConfig.Connectionstring);

            var quizRepository = new QuizRepository(mongoClient, dbConfig.DBName, "quizes");

            services.AddSingleton <IQuizRepository>(quizRepository);
        }
Exemplo n.º 21
0
        public string GetAllQuizByGameId(string gameId)
        {
            QuizRepository    repository = new QuizRepository();
            List <QuizEntity> quiz       = repository.GetAllFromGame(gameId);

            string json;

            json = JsonConvert.SerializeObject(
                quiz,
                Formatting.Indented,
                new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            return(json);
        }
Exemplo n.º 22
0
        public string GetQuiz(int id)
        {
            QuizRepository  repository = new QuizRepository();
            QuizCompleteDTO quiz       = repository.GetQuizCompleteDTOById(id);

            string json;

            json = JsonConvert.SerializeObject(
                quiz,
                Formatting.Indented,
                new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            return(json);
        }
Exemplo n.º 23
0
        public ActionResult EditPost(Quiz formModel)
        {
            if (ModelState.IsValid)
            {
                var modelDb = QuizRepository.Find(formModel.ID);
                if (this.TryUpdateModel(modelDb))
                {
                    QuizRepository.Update(modelDb);
                    QuizRepository.Save();

                    return(RedirectToAction("Index"));
                }
            }

            FillDropdownValues();
            return(View(formModel));
        }
 public UnitOfWork()
 {
     LoginService = new LoginService(this);
     LoginService.UserLoggedIn += AddAuthTokens;
     User              = new UserRepository();
     Answer            = new AnswerRepository();
     Question          = new Repository <Question>();
     Quiz              = new QuizRepository();
     Study             = new Repository <Study>();
     UserType          = new Repository <UserType>();
     Course            = new Repository <Course>();
     Faculty           = new Repository <Faculty>();
     Rating            = new RatingRepository();
     Semester          = new Repository <Semester>();
     SelectedAnswer    = new Repository <SelectedAnswer>();
     QuizUserStatistic = new Repository <QuizUserStatistic>();
 }
Exemplo n.º 25
0
        public ActionResult AddQuestionPost(Quiz formModel, int Question)
        {
            if (ModelState.IsValid)
            {
                var modelDb       = QuizRepository.Find(formModel.ID);
                var modelQuestion = QuestionRepository.Find(Question);
                modelDb.Questions.Add(modelQuestion);
                if (this.TryUpdateModel(modelDb))
                {
                    QuizRepository.Update(modelDb);
                    QuizRepository.Save();

                    //return RedirectToAction("Index");
                }
            }
            FillDropdownValues();
            return(View(formModel));
        }
Exemplo n.º 26
0
 public QuizsController(IDataRepository <Quiz> QuizData, UserManager <IdentityUser> userManager)
 {
     _quizData    = (QuizRepository)QuizData;
     _userManager = userManager;
 }
Exemplo n.º 27
0
 public QuizService(QuizRepository quizRepository)
 {
     this.quizRepository = quizRepository;
     listOfAllExercise   = quizRepository.AllExercise();
 }
Exemplo n.º 28
0
 public QuizController(IConnectionManager signalRConnectionManager) : base(signalRConnectionManager)
 {
     quizRepository = new QuizRepository();
     // _context = connectionManager.GetHubContext<QuizHub>();
 }
Exemplo n.º 29
0
 public QuizController(QuizRepository quizRepository)
 {
     this.quizRepository = quizRepository;
 }
Exemplo n.º 30
0
 private static void ListQuizzes(QuizRepository quizRepository)
 {
     var i = 0;
     quizRepository.ForEach(q =>
     {
         Console.WriteLine("{0} {1}", (++i).ToString().PadRight(3), q.Name);
     });
 }
Exemplo n.º 31
0
        private static IQuiz GetQuizChoice(QuizRepository quizRepository)
        {
            IQuiz result = null;

            do
            {
                Console.Write("Which quiz would you like to take? ");

                int quizNum;
                if (!int.TryParse(Console.ReadLine(), out quizNum))
                {
                    Console.WriteLine("That is not a quiz number!!");
                    continue;
                }

                try
                {
                    result = quizRepository[--quizNum];
                }
                catch (ArgumentOutOfRangeException)
                {
                    Console.WriteLine("Cannot find that quiz...");
                }
            } while (null == result);

            return result;
        }
Exemplo n.º 32
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))
     );
 }
Exemplo n.º 33
0
 public QuizController(QuizRepository quizReporitory, UserRepository userRepository)
 {
     this.quizReporitory = quizReporitory;
     this.userRepository = userRepository;
 }