public void ViewSetQuizzes()
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "ViewSetQuizzes";
            this.eventAggregator.Publish(changePage);
        }
        public void MarkQuizList()
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "MarkQuizList";
            this.eventAggregator.Publish(changePage);
        }
        public void DraftList()
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "DraftList";
            this.eventAggregator.Publish(changePage);
        }
Example #4
0
        public void Back()
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "TeacherMainMenu";
            this.eventAggregator.Publish(changePage);
        }
        public void CreateQuiz()
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "CreateQuiz";
            this.eventAggregator.Publish(changePage);
        }
        public void ManageClasses()
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "ManageClasses";
            this.eventAggregator.Publish(changePage);
        }
Example #7
0
        private void Browse(object obj)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "QM test (*.qm)|*.qm",
                Title  = "Select Qucik Mark test ..."
            };

            if (openFileDialog.ShowDialog() == true)
            {
                TestManager test = new TestManager(ServiceProvider.GetApplicationSettings);
                if (test.LoadTestData(openFileDialog.FileName))
                {
                    string destinationPath = Path.Combine(ServiceProvider.GetApplicationSettings.TestStorageFolderPath, Path.GetFileName(openFileDialog.FileName));

                    if (!File.Exists(destinationPath))//do backup copy of selected file
                    {
                        File.Copy(openFileDialog.FileName, destinationPath);
                    }
                    else if (openFileDialog.FileName == destinationPath)//the selected file is the backupfile stored in TestStorageFolderPath
                    {
                        File.SetLastAccessTime(destinationPath, DateTime.Now);
                    }
                    else//replace
                    {
                        File.Delete(destinationPath);
                        File.Copy(openFileDialog.FileName, destinationPath);
                        File.SetLastAccessTime(destinationPath, DateTime.Now);
                    }
                    ChangePageEvent.Invoke(this, new TestMakerViewModel(ChangePageEvent, test));
                }
            }
        }
        public void ViewHomework()
        {
            ChangePageEvent pageEvent = new ChangePageEvent();

            pageEvent.pageName = "HomeworkList";
            this.eventAggregator.Publish(pageEvent);
        }
        public void ViewQuizzes()
        {
            ChangePageEvent pageEvent = new ChangePageEvent();

            pageEvent.pageName = "ViewQuizzes";
            this.eventAggregator.Publish(pageEvent);
        }
        public void JoinClass()
        {
            ChangePageEvent pageEvent = new ChangePageEvent();

            pageEvent.pageName = "JoinClass";
            this.eventAggregator.Publish(pageEvent);
        }
Example #11
0
        public void SubmitClass()
        {
            // submits joining class request, with whether it was a success being returned as a string into joinClassAttempt
            ServerConnection server           = new ServerConnection();
            string           joinClassAttempt = server.ServerRequest("JOINCLASS", new string[2] {
                model.Username, model.ClassID.ToString()
            });

            //Prevents null characters from being at the end of the string, making it easier to handle
            joinClassAttempt = joinClassAttempt.Replace("\0", string.Empty);

            //if it was a success, go back to the student main menu and display a success message box
            if (joinClassAttempt == "success")
            {
                MessageBox.Show($"Successfully requested to join the class {model.ClassID}");

                ChangePageEvent changePage = new ChangePageEvent();
                changePage.pageName = "StudentMainMenu";
                this.eventAggregator.Publish(changePage);
            }
            else
            {
                MessageBox.Show($"Joining of {model.ClassID} unsuccessful. You may have entered the wrong ID or may already be in this class");
            }
        }
Example #12
0
        // makes it so the student plays the quiz, with the ID of the quiz being passed to QuizScreenViewModel
        void TakeQuiz(int quizID)
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "TakeQuiz";
            changePage.quizID   = quizID;
            this.eventAggregator.Publish(changePage);
        }
Example #13
0
        void SubmitPage(QuizResults results)
        {
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "QuizSubmit";
            changePage.results  = results;
            this.eventAggregator.Publish(changePage);
        }
Example #14
0
        private void LoadTest(object obj)
        {
            TestManager test = new TestManager(ServiceProvider.GetApplicationSettings);

            if (test.LoadTestData(SelectedTestDataPreview.FullPath))
            {
                ChangePageEvent.Invoke(this, new TestMakerViewModel(ChangePageEvent, test));
            }
        }
Example #15
0
        public void Edit()
        {
            //puts the quiz ID into the quiz edit page so that the teacher can edit the quiz as if it's their own
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "EditQuiz";
            changePage.quizID   = Int32.Parse(quizID);
            this.eventAggregator.Publish(changePage);
            this.RequestClose(true);
        }
Example #16
0
        public void TakeQuiz()
        {
            //if the teacher wants to take a quiz, then pass the quiz ID to the QuizScreenViewModel
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "TakeQuiz";
            changePage.quizID   = Int32.Parse(quizID);
            this.eventAggregator.Publish(changePage);
            this.RequestClose(true);
        }
Example #17
0
        public void MarkQuiz(int pointer)
        {
            //publishes the markQuiz event containing the quiz ID and the username of the quiz attempt
            MarkQuizEvent markQuiz = new MarkQuizEvent();

            markQuiz.quizID   = Int32.Parse(this.Model.List[pointer].quizID);
            markQuiz.username = this.Model.List[pointer].username;
            this.eventAggregator.Publish(markQuiz);

            //changes page to the quiz marking
            ChangePageEvent changePage = new ChangePageEvent();

            changePage.pageName = "MarkQuizView";
            this.eventAggregator.Publish(changePage);
        }
Example #18
0
        void FinishMarking()
        {
            string correctTotal = GetCorrectTotal();

            //updates the amount of correct questions in the QuizAttempts table
            ServerConnection server  = new ServerConnection();
            string           success = server.ServerRequest("FINISHMARKING", new string[] { this.Model.Username, this.Model.QuizID.ToString(), correctTotal });

            success = success.Replace("\0", string.Empty);

            if (success == "success")
            {
                MessageBox.Show("Updated the correct total");

                ChangePageEvent changePage = new ChangePageEvent();
                changePage.pageName = "TeacherMainMenu";
                this.eventAggregator.Publish(changePage);
            }
            else
            {
                MessageBox.Show("Failed to update the correct total");
            }
        }
Example #19
0
        public void Quit()
        {
            //asks the user if they want to quit with Yes/No buttons
            MessageBoxResult result = MessageBox.Show("Are you sure you want to quit?", "Quit quiz", MessageBoxButton.YesNo);

            //if the user wants to quit, then go back to the respective main menu
            if (result.ToString() == "Yes")
            {
                Debug.WriteLine(this.userType);
                if (this.userType == "TEACHER")
                {
                    ChangePageEvent changePage = new ChangePageEvent();
                    changePage.pageName = "TeacherMainMenu";
                    this.eventAggregator.Publish(changePage);
                }
                else
                {
                    ChangePageEvent changePage = new ChangePageEvent();
                    changePage.pageName = "StudentMainMenu";
                    this.eventAggregator.Publish(changePage);
                }
            }
        }
Example #20
0
        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();
            }
        }
Example #21
0
 private void ShowTestLoaderPage(object obj)
 {
     ChangePageEvent.Invoke(this, new TestMaker.TestLoaderViewModel(ChangePageEvent));
 }
Example #22
0
 private void ShowBasicSettingsPage(object obj)
 {
     ChangePageEvent.Invoke(this, new Settings.BasicSettingsViewModel(ChangePageEvent));
 }
Example #23
0
 private void ShowTypeSelectorPage(object obj)
 {
     ChangePageEvent.Invoke(this, new TestCreator.TypeSelectorViewModel(ChangePageEvent));
 }
Example #24
0
 private void ShowMainMenuPage(object obj)
 {
     ChangePageEvent.Invoke(this, new MainMenu.MainMenuViewModel(ChangePageEvent));
 }
Example #25
0
        //Handles when a page publishes a ChangePageEvent event
        public void Handle(ChangePageEvent eventRaised)
        {
            //activates the appropriate view model
            switch (eventRaised.pageName)
            {
            case "LogIn":
                ActivateItem(new LogInViewModel(this.eventAggregator));
                break;

            case "TeacherMainMenu":
                ActivateItem(new TeacherMainMenuViewModel(this.eventAggregator));
                break;

            case "StudentMainMenu":
                ActivateItem(new StudentMainMenuViewModel(this.eventAggregator));
                break;

            case "TakeQuiz":
                ActivateItem(new QuizScreenViewModel(this.eventAggregator, eventRaised.quizID, this.userType, this.username));
                break;

            case "QuizSubmit":
                ActivateItem(new QuizSubmitViewModel(this.eventAggregator, eventRaised.results));
                break;

            case "JoinClass":
                ActivateItem(new JoinClassViewModel(this.eventAggregator, this.username));
                break;

            case "ManageClasses":
                ActivateItem(new ManageClassesViewModel(this.eventAggregator, this.windowManager, this.username));
                break;

            case "CreateQuiz":
                ActivateItem(new CreateQuizViewModel(this.eventAggregator, this.username, this.windowManager, -1));
                break;

            case "ViewQuizzes":
                ActivateItem(new QuizListViewModel(this.eventAggregator, this.windowManager, this.userType, this.username));
                break;

            case "DraftList":
                ActivateItem(new DraftListViewModel(this.eventAggregator, this.windowManager, this.username));
                break;

            case "HomeworkList":
                ActivateItem(new HomeworkViewModel(this.eventAggregator, this.windowManager, this.username));
                break;

            case "ViewSetQuizzes":
                ActivateItem(new TeacherQuizHistoryViewModel(this.eventAggregator, this.username));
                break;

            case "EditQuiz":
                ActivateItem(new CreateQuizViewModel(this.eventAggregator, this.username, this.windowManager, eventRaised.quizID));
                break;

            case "MarkQuizList":
                ActivateItem(new MarkListViewModel(this.eventAggregator, this.username));
                break;

            case "MarkQuizView":
                ActivateItem(new ViewQuizViewModel(this.eventAggregator, this.markQuiz.username, this.markQuiz.quizID));
                break;
            }
        }