Merge pull request #4091 from dpalou/MOBILE-4470

Mobile 4470
main
Pau Ferrer Ocaña 2024-06-11 11:06:53 +02:00 committed by GitHub
commit 21e6b789f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 55 additions and 20 deletions

View File

@ -19,7 +19,6 @@ import { CoreCourseComponentsModule } from '@features/course/components/componen
import { AddonModQuizConnectionErrorComponent } from './connection-error/connection-error';
import { AddonModQuizIndexComponent } from './index/index';
import { AddonModQuizNavigationModalComponent } from './navigation-modal/navigation-modal';
import { AddonModQuizPreflightModalComponent } from './preflight-modal/preflight-modal';
import { AddonModQuizAttemptInfoComponent } from './attempt-info/attempt-info';
import { AddonModQuizAttemptStateComponent } from './attempt-state/attempt-state';
import { AddonModQuizQuestionCardComponent } from './question-card/question-card';
@ -31,7 +30,6 @@ import { AddonModQuizQuestionCardComponent } from './question-card/question-card
AddonModQuizIndexComponent,
AddonModQuizConnectionErrorComponent,
AddonModQuizNavigationModalComponent,
AddonModQuizPreflightModalComponent,
AddonModQuizQuestionCardComponent,
],
imports: [
@ -44,7 +42,6 @@ import { AddonModQuizQuestionCardComponent } from './question-card/question-card
AddonModQuizIndexComponent,
AddonModQuizConnectionErrorComponent,
AddonModQuizNavigationModalComponent,
AddonModQuizPreflightModalComponent,
AddonModQuizQuestionCardComponent,
],

View File

@ -0,0 +1,36 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { NgModule } from '@angular/core';
import { CoreSharedModule } from '@/core/shared.module';
import { CoreCourseComponentsModule } from '@features/course/components/components.module';
import { AddonModQuizPreflightModalComponent } from './preflight-modal.component';
export { AddonModQuizPreflightModalComponent };
@NgModule({
declarations: [
AddonModQuizPreflightModalComponent,
],
imports: [
CoreSharedModule,
CoreCourseComponentsModule,
],
exports: [
AddonModQuizPreflightModalComponent,
],
})
export class AddonModQuizPreflightModalComponentModule {}

View File

@ -22,7 +22,6 @@ import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton, Translate } from '@singletons';
import { AddonModQuizPreflightModalComponent } from '../components/preflight-modal/preflight-modal';
import { AddonModQuizAccessRuleDelegate } from './access-rules-delegate';
import { AddonModQuizModuleHandlerService } from './handlers/module';
import {
@ -269,6 +268,9 @@ export class AddonModQuizHelperProvider {
);
}
const { AddonModQuizPreflightModalComponent } =
await import('@addons/mod/quiz/components/preflight-modal/preflight-modal.module');
// Create and show the modal.
const modalData = await CoreDomUtils.openModal<Record<string, string>>({
component: AddonModQuizPreflightModalComponent,

View File

@ -19,6 +19,7 @@ import { CoreEventObserver } from '@singletons/events';
import { CoreLogger } from '@singletons/logger';
import { AddonQtypeDdMarkerQuestionData } from '../component/ddmarker';
import { AddonQtypeDdMarkerGraphicsApi } from './graphics_api';
import { CoreUtils } from '@services/utils/utils';
/**
* Class to make a question of ddmarker type work.
@ -692,17 +693,21 @@ export class AddonQtypeDdMarkerQuestion {
bgImg.src = this.imgSrc;
}
const imgLoaded = (): void => {
const imgLoaded = async (): Promise<void> => {
bgImg.removeEventListener('load', imgLoaded);
this.makeImageDropable();
setTimeout(() => {
this.redrawDragsAndDrops();
});
this.afterImageLoadDone = true;
this.question.loaded = true;
// Wait for image to be visible, otherwise the calculated positions are wrong.
const visiblePromise = CoreDom.waitToBeVisible(bgImg);
await CoreUtils.ignoreErrors(CoreUtils.timeoutPromise(visiblePromise, 500));
visiblePromise.cancel(); // In case of timeout, cancel the promise.
this.redrawDragsAndDrops();
};
if (!bgImg.src || (bgImg.complete && bgImg.naturalWidth)) {

View File

@ -1,3 +1,3 @@
<core-user-avatar *ngIf="(alwaysShow || isMainScreen) && siteInfo" [site]="siteInfo" class="core-bar-button-image clickable"
[linkProfile]="false" (ariaButtonClick)="openUserMenu($event)" [userTour]="userTour"
<core-user-avatar *ngIf="(alwaysShow || (isMainScreen && menuPage?.tabsPlacement === 'bottom')) && siteInfo" [site]="siteInfo"
class="core-bar-button-image clickable" [linkProfile]="false" (ariaButtonClick)="openUserMenu($event)" [userTour]="userTour"
[attr.aria-label]="'core.user.useraccount' | translate" />

View File

@ -1,7 +1,3 @@
:host-context(ion-tabs.placement-side ion-toolbar) {
display: none;
}
:host core-user-avatar {
--userpicture-padding: 6px !important;
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, Optional } from '@angular/core';
import { CoreSiteInfo } from '@classes/sites/unauthenticated-site';
import { CoreUserTourDirectiveOptions } from '@directives/user-tour';
import { CoreUserToursAlignment, CoreUserToursSide } from '@features/usertours/services/user-tours';
@ -22,6 +22,7 @@ import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreMainMenuUserMenuTourComponent } from '../user-menu-tour/user-menu-tour';
import { CoreMainMenuUserMenuComponent } from '../user-menu/user-menu';
import { CoreMainMenuPage } from '@features/mainmenu/pages/menu/menu';
/**
* Component to display an avatar on the header to open user menu.
@ -45,10 +46,8 @@ export class CoreMainMenuUserButtonComponent implements OnInit {
side: CoreScreen.isMobile ? CoreUserToursSide.Start : CoreUserToursSide.End,
};
constructor(protected routerOutlet: IonRouterOutlet) {
const currentSite = CoreSites.getRequiredCurrentSite();
this.siteInfo = currentSite.getInfo();
constructor(protected routerOutlet: IonRouterOutlet, @Optional() protected menuPage: CoreMainMenuPage | null) {
this.siteInfo = CoreSites.getCurrentSite()?.getInfo();
}
/**