Merge pull request #4006 from crazyserver/MOBILE-4483

Mobile 4483
main
Noel De Martin 2024-04-11 09:28:05 +02:00 committed by GitHub
commit 92ceb61740
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 36 additions and 11 deletions

View File

@ -2105,6 +2105,7 @@ export type AddonModQuizGetAttemptSummaryWSParams = {
*/
export type AddonModQuizGetAttemptSummaryWSResponse = {
questions: CoreQuestionQuestionWSData[];
totalunanswered?: number; // @since 4.4. Total unanswered questions.
warnings?: CoreWSExternalWarning[];
};

View File

@ -16,7 +16,6 @@ import { Component, ElementRef, Input, OnInit } from '@angular/core';
import {
CoreCourse,
CoreCourseModuleCompletionStatus,
CoreCourseModuleCompletionTracking,
CoreCourseProvider,
} from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper';
@ -88,10 +87,9 @@ export class CoreCourseCourseIndexComponent implements OnInit {
const modules = section.modules
.filter((module) => this.renderModule(section, module))
.map((module) => {
const completionStatus = !completionEnabled || module.completiondata === undefined ||
module.completiondata.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE
? undefined
: module.completiondata.state;
const completionStatus = completionEnabled
? CoreCourseHelper.getCompletionStatus(module.completiondata)
: undefined;
return {
id: module.id,

View File

@ -17,7 +17,6 @@ import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChange } from '@a
import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion';
import {
CoreCourseModuleCompletionStatus,
CoreCourseModuleCompletionTracking,
} from '@features/course/services/course';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreCourseModuleCompletionDetailsComponent } from '../module-completion-details/module-completion-details';
@ -87,9 +86,7 @@ export class CoreCourseModuleCompletionComponent
return;
}
const completionStatus = this.completion.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE
? undefined
: this.completion.state;
const completionStatus = CoreCourseHelper.getCompletionStatus(this.completion);
this.completed = completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE &&
completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE_FAIL;

View File

@ -2082,6 +2082,29 @@ export class CoreCourseHelperProvider {
return !!adminOptions[courseId]?.['reports'];
}
/**
* Get the completion status of a module.
*
* @param completion Completion data.
* @returns Completion status or undefined if not available.
*/
getCompletionStatus(completion?: CoreCourseModuleCompletionData): CoreCourseModuleCompletionStatus | undefined {
if (completion === undefined) {
return undefined;
}
if (completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE) {
return undefined;
}
if (completion.isoverallcomplete === true) {
// If the module is marked as overall complete, we'll show it as complete.
return CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE;
}
return completion.state;
}
}
export const CoreCourseHelper = makeSingleton(CoreCourseHelperProvider);

View File

@ -1659,6 +1659,8 @@ export type CoreCourseCompletionActivityStatus = {
description: string; // Completion description.
};
}[];
isoverallcomplete?: boolean; // @since 4.4.
// Whether the overall completion state of this course module should be marked as complete or not.
offline?: boolean; // Whether the completions is offline and not yet synced.
};
@ -1840,6 +1842,8 @@ export type CoreCourseModuleWSCompletionData = {
istrackeduser?: boolean; // @since 3.11. Whether completion is being tracked for this user.
uservisible?: boolean; // @since 3.11. Whether this activity is visible to the user.
details?: CoreCourseModuleWSRuleDetails[]; // @since 3.11. An array of completion details.
isoverallcomplete?: boolean; // @since 4.4.
// Whether the overall completion state of this course module should be marked as complete or not.
};
/**

View File

@ -627,8 +627,9 @@ export type CoreQuestionQuestionWSData = {
hasautosavedstep?: boolean; // Whether this question attempt has autosaved data.
flagged: boolean; // Whether the question is flagged or not.
questionnumber?: string; // @since 4.2. Question ordering number in the quiz.
state?: string; // The state where the question is in. It won't be returned if the user cannot see it.
status?: string; // Current formatted state of the question.
state?: string; // The state where the question is in terms of correctness.
// It will not be returned if the user cannot see it due to the quiz display correctness settings.
status?: string; // Human readable state of the question.
stateclass?: // @since 4.4. A machine-readable class name for the state that this question attempt is in.
typeof QUESTION_TODO_STATE_CLASSES[number] |
typeof QUESTION_INVALID_STATE_CLASSES[number] |

View File

@ -1162,6 +1162,7 @@ type CoreEnrolSearchUsersWSParams = {
searchanywhere: boolean; // Find a match anywhere, or only at the beginning.
page: number; // Page number.
perpage: number; // Number per page.
contextid?: number; // @since 4.4. Context ID.
};
/**