Ejemplo n.º 1
0
        /// <summary>
        /// Called when the user tries to upload a quiz
        /// </summary>
        /// <param name="sender">  </param>
        /// <param name="e">       </param>
        private async void SyncUpload_Clicked(object sender, EventArgs e)
        {
            this.serverConnected = true;
            ImageButton       button           = (sender as ImageButton);
            ActivityIndicator indicatorSyncing = (button.Parent as StackLayout).Children[(int)UISyncStatus.Syncing] as ActivityIndicator;
            string            quizPath         = "/" + button.StyleId + "/" + button.ClassId;

            button.IsVisible           = false;
            indicatorSyncing.IsVisible = true;
            indicatorSyncing.IsRunning = true;
            if (await Task.Run(async() => await ServerOperations.SendQuiz(quizPath)))
            {
                ImageButton buttonSyncNoChange = (button.Parent as StackLayout).Children[(int)UISyncStatus.NoChange] as ImageButton;
                indicatorSyncing.IsVisible   = false;
                buttonSyncNoChange.IsVisible = true;
            }
            else // if it failed to upload
            {
                indicatorSyncing.IsVisible = false;
                button.IsVisible           = true;
                await this.DisplayAlert("Quiz Upload Failed",
                                        "This quiz could not be uploaded to the server. Please try again.",
                                        "OK");
            }
            indicatorSyncing.IsRunning = false;
            this.serverConnected       = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the user tries to upload a quiz
        /// </summary>
        /// <param name="sender">  </param>
        /// <param name="e">       </param>
        private async void SyncUpload_Clicked(object sender, EventArgs e)
        {
            ImageButton       button           = (sender as ImageButton);
            ActivityIndicator indicatorSyncing = (button.Parent as StackLayout).Children[(int)UISyncStatus.Syncing] as ActivityIndicator;
            string            quizPath         = "/" + button.StyleId + "/" + button.ClassId;

            button.IsVisible           = false;
            indicatorSyncing.IsVisible = true;
            indicatorSyncing.IsRunning = true;
            if (await Task.Run(async() => await ServerOperations.SendQuiz(quizPath)))
            {
                ImageButton buttonSyncNoChange = (button.Parent as StackLayout).Children[(int)UISyncStatus.NoChange] as ImageButton;
                indicatorSyncing.IsVisible   = false;
                buttonSyncNoChange.IsVisible = true;
            }
            else // if it failed to upload
            {
                indicatorSyncing.IsVisible = false;
                button.IsVisible           = true;
                await this.DisplayAlert("Quiz Upload Failed",
                                        "This quiz could not be uploaded to the server. Please try again.",
                                        "OK");
            }
            indicatorSyncing.IsRunning = false;
            this.QuizNumber.Text       =
                "You have published a total of " +
                await Task.Run(() => ServerOperations.GetNumberOfQuizzesByAuthorName(CredentialManager.Username)) +
                " quizzes!";
        }