Skip to content

Commit

Permalink
Merge pull request #3728 from NoelDeMartin/MOBILE-4362
Browse files Browse the repository at this point in the history
MOBILE-4362: Tweaks
  • Loading branch information
crazyserver authored Jul 11, 2023
2 parents 9d44d91 + 93783d2 commit 2c88179
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .vscode/moodle.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,13 @@
],
"description": "[Moodle] Create a Pure Singleton"
},
"Innherit doc": {
"prefix": "inheritdoc",
"body": [
"/**",
" * @inheritdoc",
" */"
],
"description": "Add @inheritdoc documentation block"
}
}
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
}
},
"cli": {
"analytics": false,
"defaultCollection": "@ionic/angular-toolkit"
},
"schematics": {
Expand Down
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<hook src="scripts/cordova-hooks/before_plugin_add.sh" type="before_plugin_add" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ionic:serve:before": "gulp",
"ionic:serve": "cross-env-shell ./scripts/serve.sh",
"ionic:build:before": "gulp",
"postinstall": "patch-package",
"postinstall": "patch-package && cd cordova-plugin-moodleapp && npm install",
"lang:update-langpacks": "./scripts/update_langpacks.sh",
"lang:detect-langpacks": "./scripts/update_langpacks.sh detect",
"lang:create-langindex": "./scripts/create_langindex.sh"
Expand Down
8 changes: 8 additions & 0 deletions scripts/cordova-hooks/before_plugin_add.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [[ $CORDOVA_PLUGINS == *cordova-plugin-moodleapp* ]]; then
echo "Building cordova-plugin-moodleapp"

cd cordova-plugin-moodleapp
npm run prod
fi
2 changes: 1 addition & 1 deletion scripts/update_lang_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function copy_lang {
lang=$1

index_keys=$(jq -r 'to_entries[] | "\"\(.key)\","' langindex.json)
index_keys=$(echo "$index_keys" | sed 's/,*$//')
index_keys=${index_keys:0:-1}

hyphenlang=${lang/_/-}
langfilepath=$LANG_PATH/$hyphenlang.json
Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/quiz/services/handlers/prefetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
if (attempt.state == AddonModQuizProvider.ATTEMPT_IN_PROGRESS) {
// Get data for each page.
promises = promises.concat(pages.map(async (page) => {
if (isSequential && attempt.currentpage && page < attempt.currentpage) {
if (isSequential && typeof attempt.currentpage === 'number' && page < attempt.currentpage) {
// Sequential quiz, cannot get pages before the current one.
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/classes/errors/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { CoreCaptureError } from './captureerror';
import { CoreNetworkError } from './network-error';
import { CoreSiteError } from './siteerror';
import { CoreLoginError } from './loginerror';
import { CoreErrorWithOptions } from './errorwithtitle';
import { CoreErrorWithOptions } from './errorwithoptions';
import { CoreHttpError } from './httperror';

export const CORE_ERRORS_CLASSES: Type<unknown>[] = [
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/core/components/iframe/core-iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<core-navbar-buttons slot="end" prepend *ngIf="initialized && showFullscreenOnToolbar && !loading">
<ion-button fill="clear" (click)="toggleFullscreen()"
[attr.aria-label]="(fullscreen ? 'core.disablefullscreen' : 'core.fullscreen') | translate">
<ion-icon *ngIf="!fullscreen" name="fas-expand" slot="icon-only" aria-hidden="true"></ion-icon>
<ion-icon *ngIf="fullscreen" name="fas-compress" slot="icon-only" aria-hidden="true"></ion-icon>
<ion-icon [name]="fullscreen ? 'fas-compress' : 'fas-expand'" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</core-navbar-buttons>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy {
// Don't allow guest access if it requires a password if not supported.
this.guestAccessPasswordRequired = info.passwordrequired;

return info.status === true && (!info.passwordrequired || CoreCourses.isValidateGuestAccessPasswordAvailable());
return info.status && (!info.passwordrequired || CoreCourses.isValidateGuestAccessPasswordAvailable());
}

/**
Expand Down Expand Up @@ -193,7 +193,7 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy {
const enrolmentMethods = await CoreCourses.getCourseEnrolmentMethods(this.courseId);

enrolmentMethods.forEach((method) => {
if (!method.status) {
if (!CoreUtils.isTrueOrOne(method.status)) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/features/course/services/course-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,7 @@ export class CoreCourseHelperProvider {

// Don't allow guest access if it requires a password and it's available.
return {
guestAccess: info.status === true &&
(!info.passwordrequired || CoreCourses.isValidateGuestAccessPasswordAvailable()),
guestAccess: info.status && (!info.passwordrequired || CoreCourses.isValidateGuestAccessPasswordAvailable()),
passwordRequired: info.passwordrequired,
};
} catch {
Expand Down
4 changes: 2 additions & 2 deletions src/core/features/course/tests/behat/basic_usage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ Feature: Test basic usage of one course in app
And I should find "Test scorm name" in the app
And I should find "Test workshop name" in the app

When I set "page-core-course-index .core-course-thumb" styles to "--course-color" "lightblue"
And I set "page-core-course-index .core-course-thumb" styles to "--course-color-tint" "white"
When I set "page-core-course-index .core-course-thumb" styles to "background" "lightblue"
And I set "page-core-course-index .core-course-thumb img" styles to "display" "none"
Then the UI should match the snapshot

When I press "Choice course 1" in the app
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/core/features/courses/services/courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1827,14 +1827,14 @@ export type CoreCourseEnrolmentInfo = {
courseid: number; // Id of course.
type: string; // Type of enrolment plugin.
name: string; // Name of enrolment plugin.
status: boolean | string; // Available status of enrolment plugin. True if successful, else error message or false.
};

/**
* Course enrolment method.
*/
export type CoreCourseEnrolmentMethod = CoreCourseEnrolmentInfo & {
wsfunction?: string; // Webservice function to get more information.
status: string; // Status of enrolment plugin. True if successful, else error message or false.
};

/**
Expand Down Expand Up @@ -1877,6 +1877,7 @@ export type CoreCourseGetRecentCoursesOptions = CoreSitesCommonWSOptions & {
*/
export type CoreCourseEnrolmentGuestMethod = CoreCourseEnrolmentInfo & {
passwordrequired: boolean; // Is a password required?
status: boolean; // Is the enrolment enabled?
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/courses/services/handlers/course-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler
let isSelfEnrolEnabled = false;
let instances = 0;
methods.forEach((method) => {
if (method.type == 'self' && method.status) {
if (method.type == 'self' && CoreUtils.isTrueOrOne(method.status)) {
isSelfEnrolEnabled = true;
instances++;
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/features/login/pages/sites/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export class CoreLoginSitesPage implements OnInit {
async ngOnInit(): Promise<void> {
if (CoreNavigator.getRouteBooleanParam('openAddSite')) {
this.add();

return;
}

this.accountsList = await CoreLoginHelper.getAccountsList();
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { CoreRedirectPayload } from './navigator';
import { CoreSitesFactory } from './sites-factory';
import { CoreText } from '@singletons/text';
import { CoreLoginHelper } from '@features/login/services/login-helper';
import { CoreErrorWithOptions } from '@classes/errors/errorwithtitle';
import { CoreErrorWithOptions } from '@classes/errors/errorwithoptions';
import { CoreAjaxError } from '@classes/errors/ajaxerror';
import { CoreAjaxWSError } from '@classes/errors/ajaxwserror';
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { CoreWindow } from '@singletons/window';
import { CoreColors } from '@singletons/colors';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
import { CoreErrorWithOptions } from '@classes/errors/errorwithtitle';
import { CoreErrorWithOptions } from '@classes/errors/errorwithoptions';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreCancellablePromise } from '@classes/cancellable-promise';
Expand Down

0 comments on commit 2c88179

Please sign in to comment.