public QuizScreenViewModel(IEventAggregator eventAggregator, int quizID, string userType, string username) { this.eventAggregator = eventAggregator; this.quizID = quizID; this.userType = userType; this.username = username; this.Model = new QuizScreenModel(); //gets the quiz JSON and then fills the model with the quiz's content string JSON = QuizHandling.GetQuizJSON(this.quizID); (Model.Questions, Model.QuestionTypes, Model.Answers, Model.TimeLeft, Model.QuizType) = QuizHandling.OpenQuiz(JSON); //creates a string array that the user's inputs will go into Model.UserInputs = new string[Model.Questions.Length]; this.Model.NextButtonText = "Next Question"; SetFirstQuestion(); SetTimerSettings(); }
public CreateQuizViewModel(IEventAggregator eventAggregator, string username, IWindowManager windowManager, int quizID) { this.eventAggregator = eventAggregator; //subscribe to the event aggregator for sending the quiz to a class at the end eventAggregator.Subscribe(this); //sets everything up as it should be and assigns the default values for editing a quiz from the first question this.windowManager = windowManager; this.Model = new CreateQuizModel(); this.Model.Username = username; this.Model.CurrentQuestionNumber = 0; this.Model.NextButtonText = "Add question"; this.Model.Public = true; // quiz ID being -1 means that it's a new quiz, if the quiz ID put into the ViewModel as a parameter isn't -1 then load the quiz contents from the server if (quizID != -1) { string JSON = QuizHandling.GetQuizJSON(quizID); //temporary to return values into string[] questions; int[] questionTypes; string[] answers; (questions, questionTypes, answers, Model.TimeAllocated, Model.QuizType) = QuizHandling.OpenQuiz(JSON); FillModel(questions, questionTypes, answers); SetUpQuestion(); } else { //Sets the default values for quiz entry this.Model.QuestionNumberDisplay = "Question 1/1"; this.Model.Instant = true; this.Model.QuizType = "Instant"; //start on settings this.Model.CurrentQuestionType = 3; } }
public ViewQuizViewModel(IEventAggregator eventAggregator, string username, int quizID) { this.eventAggregator = eventAggregator; this.Model = new ViewQuizModel(); bool success; //gets the quiz attempt information from the server (Model.QuizID, Model.Username, Model.QuizType, Model.Questions, Model.Answers, Model.CorrectQuestions, success) = QuizHandling.GetQuizInformation(username, quizID); if (success == false) { MessageBox.Show("Something went wrong loading the quiz. Returning to the main menu"); ChangePageEvent changePage = new ChangePageEvent(); changePage.pageName = "TeacherMainMenu"; this.eventAggregator.Publish(changePage); } else { this.Model.CurrentQuestionNumber = 0; SetUpQuestion(); } }