/// <summary> /// Handle when user clicks edit button /// </summary> private async void ButtonEdit_Clicked(string DBId) { QuizInfo info = QuizRosterDatabase.GetQuizInfo(DBId); if (!CredentialManager.IsLoggedIn) { await this.DisplayAlert("Hold on!", "Before you can edit any quizzes, you have to login.", "Ok"); } else if (info.SyncStatus == (int)SyncStatusEnum.NotDownloadedAndNeedDownload) { await this.DisplayAlert("Hold on!", "This quiz isn't on your device, download it before you try to edit it", "Ok"); } else { CreateNewQuizPage quizPage = new CreateNewQuizPage(info); //Create the quizPage quizPage.SetQuizName(info.QuizName); Quiz quizDB = new Quiz(info.DBId); foreach (Question question in quizDB.GetQuestions()) { quizPage.AddNewQuestion(question); } await this.Navigation.PushAsync(quizPage); } }
/// <summary> /// When the user wants to create a brand new quiz /// </summary> /// <param name="sender"> </param> /// <param name="e"> </param> private async void ButtonCreateQuiz_Activated(object sender, EventArgs e) { if (CredentialManager.IsLoggedIn) { CreateNewQuizPage quiz = new CreateNewQuizPage(); await this.Navigation.PushAsync(quiz); } else { if (await this.DisplayAlert("Hold on!", "Before you can create your own custom quizzes, you have to create your own account.", "Login/Create Account", "Go Back")) { ProfilePage profilePage = new ProfilePage(); if (!profilePage.IsLoading && !profilePage.IsOnLoginPage) { await profilePage.UpdateProfilePageAsync(); } profilePage.SetTemporary(); await this.Navigation.PushAsync(profilePage); } } }