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 = { export type AddonModQuizGetAttemptSummaryWSResponse = {
questions: CoreQuestionQuestionWSData[]; questions: CoreQuestionQuestionWSData[];
totalunanswered?: number; // @since 4.4. Total unanswered questions.
warnings?: CoreWSExternalWarning[]; warnings?: CoreWSExternalWarning[];
}; };

View File

@ -16,7 +16,6 @@ import { Component, ElementRef, Input, OnInit } from '@angular/core';
import { import {
CoreCourse, CoreCourse,
CoreCourseModuleCompletionStatus, CoreCourseModuleCompletionStatus,
CoreCourseModuleCompletionTracking,
CoreCourseProvider, CoreCourseProvider,
} from '@features/course/services/course'; } from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper'; import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper';
@ -88,10 +87,9 @@ export class CoreCourseCourseIndexComponent implements OnInit {
const modules = section.modules const modules = section.modules
.filter((module) => this.renderModule(section, module)) .filter((module) => this.renderModule(section, module))
.map((module) => { .map((module) => {
const completionStatus = !completionEnabled || module.completiondata === undefined || const completionStatus = completionEnabled
module.completiondata.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE ? CoreCourseHelper.getCompletionStatus(module.completiondata)
? undefined : undefined;
: module.completiondata.state;
return { return {
id: module.id, 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 { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion';
import { import {
CoreCourseModuleCompletionStatus, CoreCourseModuleCompletionStatus,
CoreCourseModuleCompletionTracking,
} from '@features/course/services/course'; } from '@features/course/services/course';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { CoreCourseModuleCompletionDetailsComponent } from '../module-completion-details/module-completion-details'; import { CoreCourseModuleCompletionDetailsComponent } from '../module-completion-details/module-completion-details';
@ -87,9 +86,7 @@ export class CoreCourseModuleCompletionComponent
return; return;
} }
const completionStatus = this.completion.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE const completionStatus = CoreCourseHelper.getCompletionStatus(this.completion);
? undefined
: this.completion.state;
this.completed = completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE && this.completed = completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE &&
completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE_FAIL; completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE_FAIL;

View File

@ -2082,6 +2082,29 @@ export class CoreCourseHelperProvider {
return !!adminOptions[courseId]?.['reports']; 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); export const CoreCourseHelper = makeSingleton(CoreCourseHelperProvider);

View File

@ -1659,6 +1659,8 @@ export type CoreCourseCompletionActivityStatus = {
description: string; // Completion description. 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. 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. 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. uservisible?: boolean; // @since 3.11. Whether this activity is visible to the user.
details?: CoreCourseModuleWSRuleDetails[]; // @since 3.11. An array of completion details. 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. hasautosavedstep?: boolean; // Whether this question attempt has autosaved data.
flagged: boolean; // Whether the question is flagged or not. flagged: boolean; // Whether the question is flagged or not.
questionnumber?: string; // @since 4.2. Question ordering number in the quiz. 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. state?: string; // The state where the question is in terms of correctness.
status?: string; // Current formatted state of the question. // 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. 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_TODO_STATE_CLASSES[number] |
typeof QUESTION_INVALID_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. searchanywhere: boolean; // Find a match anywhere, or only at the beginning.
page: number; // Page number. page: number; // Page number.
perpage: number; // Number per page. perpage: number; // Number per page.
contextid?: number; // @since 4.4. Context ID.
}; };
/** /**