MOBILE-3636 assign: Minor fixes

main
Pau Ferrer Ocaña 2021-02-24 09:30:00 +01:00
parent 4cf2a40ca7
commit cf7f4b4951
14 changed files with 16 additions and 49 deletions

View File

@ -13,10 +13,6 @@
// limitations under the License.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreSharedModule } from '@/core/shared.module';
import { CoreCourseComponentsModule } from '@features/course/components/components.module';
@ -35,10 +31,6 @@ import { AddonModAssignEditFeedbackModalComponent } from './edit-feedback-modal/
AddonModAssignEditFeedbackModalComponent,
],
imports: [
CommonModule,
IonicModule,
TranslateModule.forChild(),
FormsModule,
CoreSharedModule,
CoreCourseComponentsModule,
],

View File

@ -104,20 +104,11 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
*
* @return Promise resolved with the input data, rejected if cancelled.
*/
editFeedback(): Promise<AddonModAssignFeedbackCommentsTextData> {
async editFeedback(): Promise<AddonModAssignFeedbackCommentsTextData> {
if (!this.canEdit) {
throw new CoreError('Cannot edit feedback');
}
return new Promise((resolve, reject): void => {
this.showEditFeedbackModal(resolve, reject);
});
}
protected async showEditFeedbackModal(
resolve: (value: AddonModAssignFeedbackCommentsTextData | PromiseLike<AddonModAssignFeedbackCommentsTextData>) => void,
reject: () => void,
): Promise < void> {
// Create the navigation modal.
const modal = await ModalController.instance.create({
component: AddonModAssignEditFeedbackModalComponent,
@ -134,9 +125,9 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
const result = await modal.onDidDismiss();
if (typeof result.data == 'undefined') {
reject();
throw null; // User cancelled.
} else {
resolve(result.data);
return result.data;
}
}

View File

@ -1,7 +1,8 @@
<core-loading [hideUntil]="loaded" class="core-loading-center">
<!-- User and status of the submission. -->
<ion-item class="ion-text-wrap" *ngIf="!blindMarking && user" core-user-link [userId]="submitId" [courseId]="courseId" [title]="user!.fullname">
<ion-item class="ion-text-wrap" *ngIf="!blindMarking && user" core-user-link [userId]="submitId" [courseId]="courseId"
[title]="user!.fullname">
<core-user-avatar [user]="user" slot="start"></core-user-avatar>
<ion-label>
<h2>{{ user!.fullname }}</h2>

View File

@ -28,7 +28,6 @@ import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate
CoreEditorComponentsModule,
],
providers: [
AddonModAssignFeedbackCommentsHandler,
{
provide: APP_INITIALIZER,
multi: true,

View File

@ -26,7 +26,6 @@ import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate
CoreSharedModule,
],
providers: [
AddonModAssignFeedbackEditPdfHandler,
{
provide: APP_INITIALIZER,
multi: true,

View File

@ -26,7 +26,6 @@ import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate
CoreSharedModule,
],
providers: [
AddonModAssignFeedbackFileHandler,
{
provide: APP_INITIALIZER,
multi: true,

View File

@ -15,7 +15,6 @@
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { CoreError } from '@classes/errors/error';
import { CoreIonLoadingElement } from '@classes/ion-loading';
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
import { CoreNavigator } from '@services/navigator';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
@ -208,26 +207,15 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy {
*
* @return Promise resolved with boolean: whether data has changed.
*/
protected hasDataChanged(): Promise<boolean> {
protected async hasDataChanged(): Promise<boolean> {
// Usually the hasSubmissionDataChanged call will be resolved inmediately, causing the modal to be shown just an instant.
// We'll wait a bit before showing it to prevent this "blink".
let modal: CoreIonLoadingElement;
let showModal = true;
setTimeout(async () => {
if (showModal) {
modal = await CoreDomUtils.instance.showModalLoading();
}
}, 100);
const modal = await CoreDomUtils.instance.showModalLoading();
const data = this.getInputData();
return AddonModAssignHelper.instance.hasSubmissionDataChanged(this.assign!, this.userSubmission, data).finally(() => {
if (modal) {
modal.dismiss();
} else {
showModal = false;
}
});
}

View File

@ -245,7 +245,6 @@ export class AddonModAssignHelperProvider {
// If no participants returned and all groups specified, get participants by groups.
const groupsInfo = await CoreGroups.instance.getActivityGroupInfo(assign.cmid, false, undefined, modOptions.siteId);
[];
const participantsIndexed: {[id: number]: AddonModAssignParticipant} = {};
@ -582,7 +581,7 @@ export class AddonModAssignHelperProvider {
siteId?: string,
): Promise<AddonModAssignSavePluginData> {
const pluginData = {};
const pluginData: Record<string, unknown> = {};
const promises = feedback.plugins
? feedback.plugins.map((plugin) =>
AddonModAssignFeedbackDelegate.instance.preparePluginFeedbackData(assignId, userId, plugin, pluginData, siteId))

View File

@ -31,6 +31,7 @@ import { AddonModAssignOffline } from './assign-offline';
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
import { CoreComments } from '@features/comments/services/comments';
import { AddonModAssignSubmissionFormatted } from './assign-helper';
import { CoreWSError } from '@classes/errors/wserror';
const ROOT_CACHE_KEY = 'mmaModAssign:';
@ -1119,7 +1120,7 @@ export class AddonModAssignProvider {
if (warnings.length) {
// The WebService returned warnings, reject.
throw warnings[0];
throw new CoreWSError(warnings[0]);
}
}
@ -1202,7 +1203,7 @@ export class AddonModAssignProvider {
if (warnings.length) {
// The WebService returned warnings, reject.
throw warnings[0];
throw new CoreWSError(warnings[0]);
}
}
@ -1371,7 +1372,7 @@ export class AddonModAssignProvider {
if (warnings.length) {
// The WebService returned warnings, reject.
throw warnings[0];
throw new CoreWSError(warnings[0]);
}
}

View File

@ -16,7 +16,8 @@ import { CoreSiteSchema } from '@services/sites';
/**
* Database variables for AddonModAssignOfflineProvider.
*/export const SUBMISSIONS_TABLE = 'addon_mod_assign_submissions';
*/
export const SUBMISSIONS_TABLE = 'addon_mod_assign_submissions';
export const SUBMISSIONS_GRADES_TABLE = 'addon_mod_assign_submissions_grading';
export const OFFLINE_SITE_SCHEMA: CoreSiteSchema = {
name: 'AddonModAssignOfflineProvider',

View File

@ -28,7 +28,6 @@ import { CoreCommentsComponentsModule } from '@features/comments/components/comp
CoreCommentsComponentsModule,
],
providers: [
AddonModAssignSubmissionCommentsHandler,
{
provide: APP_INITIALIZER,
multi: true,

View File

@ -26,7 +26,6 @@ import { AddonModAssignSubmissionDelegate } from '../../services/submission-dele
CoreSharedModule,
],
providers: [
AddonModAssignSubmissionFileHandler,
{
provide: APP_INITIALIZER,
multi: true,

View File

@ -28,7 +28,6 @@ import { AddonModAssignSubmissionDelegate } from '../../services/submission-dele
CoreEditorComponentsModule,
],
providers: [
AddonModAssignSubmissionOnlineTextHandler,
{
provide: APP_INITIALIZER,
multi: true,

View File

@ -42,7 +42,7 @@ export class CoreIonLoadingElement {
* Present the loading.
*/
async present(): Promise<void> {
// Wait a bit before presenting the modal, to prevent it being displayed if dissmiss is called fast.
// Wait a bit before presenting the modal, to prevent it being displayed if dismiss is called fast.
await CoreUtils.instance.wait(40);
if (!this.isDismissed) {