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); }
///<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); }
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; }
protected Quiz() { IQuizRepository quizRepository = new QuizRepository(); IQuestionsService questionsService = new QuestionsService(quizRepository); _gameService = new GameService(questionsService); }
public FlagQuizController() { var quizRepository = new QuizRepository(); _flagRepository = new FlagRepository(); _game = quizRepository.Get(1); }
public ActionResult AddQuestion(int id) { FillDropdownValues(); var model = QuizRepository.Find(id); return(View(model)); }
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
///<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); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IQuizRepository quizRepo = new QuizRepository(); Application.Run(new MainForm(quizRepo)); }
public WelcomeViewModel() { //Przypisanie wywoływacza przycisku "Start" StartQuizCommand = new RelayCommand(SendQuiz, () => isSelected); //Ładuje testy Tests = QuizRepository.GetTests(); }
private static void ListQuizzes(QuizRepository quizRepository) { var i = 0; quizRepository.ForEach(q => { Console.WriteLine("{0} {1}", (++i).ToString().PadRight(3), q.Name); }); }
public void ResetRepositories() { _quizRepository = null; _ruleRepository = null; _stageRepository = null; _questionRepository = null; _endingRepository = null; _fileRepository = null; }
public IRepository <Common.Quiz, Guid> GetQuizRepository() { if (quizRepository == null) { quizRepository = new QuizRepository(context); } return(quizRepository); }
public JsonResult Delete(int id) { QuizRepository.Delete(id); QuizRepository.Save(); return(new JsonResult() { Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
// 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()); }
public ActionResult Create(Quiz model) { if (ModelState.IsValid) { QuizRepository.Insert(model); QuizRepository.Save(); return(RedirectToAction("Index")); } FillDropdownValues(); return(View(model)); }
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; } }
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 }); }
// 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); }
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); }
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); }
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>(); }
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)); }
public QuizsController(IDataRepository <Quiz> QuizData, UserManager <IdentityUser> userManager) { _quizData = (QuizRepository)QuizData; _userManager = userManager; }
public QuizService(QuizRepository quizRepository) { this.quizRepository = quizRepository; listOfAllExercise = quizRepository.AllExercise(); }
public QuizController(IConnectionManager signalRConnectionManager) : base(signalRConnectionManager) { quizRepository = new QuizRepository(); // _context = connectionManager.GetHubContext<QuizHub>(); }
public QuizController(QuizRepository quizRepository) { this.quizRepository = quizRepository; }
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; }
public QuizController(QuizRepository quizReporitory, UserRepository userRepository) { this.quizReporitory = quizReporitory; this.userRepository = userRepository; }