Skip to content

Commit

Permalink
Merge pull request #3868 from NoelDeMartin/MOBILE-3947
Browse files Browse the repository at this point in the history
MOBILE-3947: Fix build
  • Loading branch information
dpalou authored Nov 30, 2023
2 parents bb2e08d + 7325a1d commit 19ad6ee
Show file tree
Hide file tree
Showing 28 changed files with 301 additions and 158 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const appConfig = {
Object: {
message: 'Use {} instead.',
},
Function: false,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
},
"editor.formatOnSave": true,
"eslint.format.enable": true,
"html.format.endWithNewline": true,
"html.format.wrapLineLength": 140,
"files.eol": "\n",
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"typescript.tsdk": "./node_modules/typescript/lib",

/**
* Config files.
Expand Down
110 changes: 32 additions & 78 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"@awesome-cordova-plugins/sqlite": "^6.3.0",
"@awesome-cordova-plugins/status-bar": "^6.3.0",
"@awesome-cordova-plugins/web-intent": "^6.3.0",
"@awesome-cordova-plugins/zip": "^6.3.0",
"@ionic/angular": "^7.0.0",
"@ionic/cordova-builders": "^10.0.0",
"@moodlehq/cordova-plugin-advanced-http": "3.3.1-moodle.1",
Expand Down Expand Up @@ -177,7 +176,7 @@
"jest-preset-angular": "^13.1.4",
"jsonc-parser": "^2.3.1",
"keytar": "^7.2.0",
"minimatch": "^5.1.0",
"minimatch": "^9.0.3",
"native-run": "^2.0.0",
"patch-package": "^6.5.0",
"ts-jest": "^29.1.1",
Expand Down
18 changes: 11 additions & 7 deletions src/addons/mod/lesson/pages/user-retake/user-retake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
* @returns Formatted data.
*/
protected formatRetake(retakeData: AddonModLessonGetUserAttemptWSResponse): RetakeToDisplay {
const formattedData = <RetakeToDisplay> retakeData;
const formattedData = retakeData;

if (formattedData.userstats.gradeinfo) {
// Completed.
Expand All @@ -229,19 +229,23 @@ export class AddonModLessonUserRetakePage implements OnInit {
// Format pages data.
formattedData.answerpages.forEach((page) => {
if (AddonModLesson.answerPageIsContent(page)) {
page.isContent = true;
const contentPage = page as AnswerPage;

if (page.answerdata?.answers) {
page.answerdata.answers.forEach((answer) => {
contentPage.isContent = true;

if (contentPage.answerdata?.answers) {
contentPage.answerdata.answers.forEach((answer) => {
// Content pages only have 1 valid field in the answer array.
answer[0] = AddonModLessonHelper.getContentPageAnswerDataFromHtml(answer[0]);
});
}
} else if (AddonModLesson.answerPageIsQuestion(page)) {
page.isQuestion = true;
const questionPage = page as AnswerPage;

questionPage.isQuestion = true;

if (page.answerdata?.answers) {
page.answerdata.answers.forEach((answer) => {
if (questionPage.answerdata?.answers) {
questionPage.answerdata.answers.forEach((answer) => {
// Only the first field of the answer array requires to be parsed.
answer[0] = AddonModLessonHelper.getQuestionPageAnswerDataFromHtml(answer[0]);
});
Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/lesson/services/lesson-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class AddonModLessonHelperProvider {
if (option.checked || multiChoiceQuestion.multi) {
// Add the control.
const value = multiChoiceQuestion.multi ?
{ value: option.checked, disabled: option.disabled } : option.value;
{ value: option.checked, disabled: option.disabled } : option.checked;
questionForm.addControl(option.name, this.formBuilder.control(value));
controlAdded = true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/addons/mod/scorm/services/scorm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class AddonModScormProvider {

const re = /^(\d+)\*\{(.+)\}$/; // Sets like 3*{S34, S36, S37, S39}.
const reOther = /^(.+)(=|<>)(.+)$/; // Other symbols.
let matches = element.match(re);
const matches = element.match(re);

if (matches) {
const repeat = Number(matches[1]);
Expand All @@ -363,18 +363,18 @@ export class AddonModScormProvider {
element = '!';
} else if (reOther.test(element)) {
// Other symbols = | <> .
matches = element.match(reOther) ?? [];
element = matches[1]?.trim();
const otherMatches = element.match(reOther) ?? [];
element = otherMatches[1]?.trim();

if (trackData[element] !== undefined) {
let value = matches[3].trim().replace(/('|")/gi, '');
let value = otherMatches[3].trim().replace(/('|")/gi, '');
let oper: string;

if (STATUSES[value] !== undefined) {
value = STATUSES[value];
}

if (matches[2] == '<>') {
if (otherMatches[2] == '<>') {
oper = '!=';
} else {
oper = '==';
Expand Down
8 changes: 7 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
import { InjectionToken, Injector, ModuleWithProviders, NgModule, Type } from '@angular/core';
import {
PreloadAllModules,
RouterModule,
Expand Down Expand Up @@ -97,6 +97,12 @@ function buildConditionalUrlMatcher(pathOrMatcher: string | UrlMatcher, conditio
};
}

/**
* Type to declare lazy route modules.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type LazyRoutesModule = Type<any>;

/**
* Build url matcher using a regular expression.
*
Expand Down
4 changes: 2 additions & 2 deletions src/core/classes/application-init-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { ApplicationInitStatus, APP_INITIALIZER, Injectable, Injector } from '@angular/core';
import { ApplicationInitStatus, Injectable, Injector } from '@angular/core';
import { setSingletonsInjector } from '@singletons';

@Injectable()
Expand All @@ -21,7 +21,7 @@ export class CoreApplicationInitStatus extends ApplicationInitStatus {
constructor(injector: Injector) {
setSingletonsInjector(injector);

super(injector.get(APP_INITIALIZER, []));
super();
}

whenDone(callback: () => unknown): void {
Expand Down
4 changes: 2 additions & 2 deletions src/core/features/compile/pipes/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { Injectable, Pipe } from '@angular/core';
import { Injectable, Pipe, PipeTransform } from '@angular/core';
import { TranslatePipe } from '@ngx-translate/core';

/**
Expand All @@ -25,4 +25,4 @@ import { TranslatePipe } from '@ngx-translate/core';
pure: false, // required to update the value when the promise is resolved
standalone: true,
})
export class TranslatePipeForCompile extends TranslatePipe {}
export class TranslatePipeForCompile extends TranslatePipe implements PipeTransform {}
3 changes: 2 additions & 1 deletion src/core/features/course/services/course-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import { CoreRemindersPushNotificationData } from '@features/reminders/services/
import { CoreLocalNotifications } from '@services/local-notifications';
import { CoreEnrol } from '@features/enrol/services/enrol';
import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate';
import { LazyRoutesModule } from '@/app/app-routing.module';

/**
* Prefetch info of a module.
Expand Down Expand Up @@ -1990,7 +1991,7 @@ export class CoreCourseHelperProvider {
*
* @returns Course summary page module.
*/
async getCourseSummaryRouteModule(): Promise<unknown> {
async getCourseSummaryRouteModule(): Promise<LazyRoutesModule> {
return import('../course-summary-lazy.module').then(m => m.CoreCourseSummaryLazyModule);
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/features/courses/services/courses-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { of, firstValueFrom } from 'rxjs';
import { zipIncludingComplete } from '@/core/utils/rxjs';
import { catchError, map } from 'rxjs/operators';
import { chainRequests, WSObservable } from '@classes/sites/authenticated-site';
import { LazyRoutesModule } from '@/app/app-routing.module';

// Id for a course item representing all courses (for example, for course filters).
export const ALL_COURSES_ID = -1;
Expand Down Expand Up @@ -432,7 +433,7 @@ export class CoreCoursesHelperProvider {
*
* @returns My courses page module.
*/
async getMyRouteModule(): Promise<unknown> {
async getMyRouteModule(): Promise<LazyRoutesModule> {
return import('../courses-my-lazy.module').then(m => m.CoreCoursesMyLazyModule);
}

Expand Down
Loading

0 comments on commit 19ad6ee

Please sign in to comment.