@openstax/ts-utils 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/services/lrsGateway/xapiUtils.d.ts +3 -1
- package/dist/cjs/services/lrsGateway/xapiUtils.js +11 -2
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/lrsGateway/xapiUtils.d.ts +3 -1
- package/dist/esm/services/lrsGateway/xapiUtils.js +8 -2
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AccountsGateway } from '../accountsGateway';
|
|
2
2
|
import { AuthProvider } from '../authProvider';
|
|
3
3
|
import { Logger } from '../logger';
|
|
4
|
+
import { ActivityState } from './attempt-utils';
|
|
4
5
|
import { LrsGateway } from '.';
|
|
5
6
|
export interface Grade {
|
|
6
7
|
scoreGiven: number;
|
|
@@ -13,7 +14,7 @@ export interface Grade {
|
|
|
13
14
|
export declare const getRegistrationAttemptInfo: (lrs: LrsGateway, registration: string, options?: {
|
|
14
15
|
anyUser?: boolean | undefined;
|
|
15
16
|
} | undefined) => Promise<{
|
|
16
|
-
[key: string]:
|
|
17
|
+
[key: string]: ActivityState;
|
|
17
18
|
}>;
|
|
18
19
|
export declare const getCurrentGrade: (services: {
|
|
19
20
|
lrs: LrsGateway;
|
|
@@ -27,6 +28,7 @@ export declare const getAllGradesForAssignment: (services: {
|
|
|
27
28
|
lrs: LrsGateway;
|
|
28
29
|
logger: Logger;
|
|
29
30
|
}, registration: string, options?: {
|
|
31
|
+
incompleteAttemptsCallback?: ((mappedInfo: [string, ActivityState][]) => Promise<Grade[]>) | undefined;
|
|
30
32
|
platformId?: string | undefined;
|
|
31
33
|
scoreMaximum?: number | undefined;
|
|
32
34
|
} | undefined) => Promise<Grade[]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import partition from 'lodash/fp/partition';
|
|
1
2
|
import { roundToPrecision } from '../..';
|
|
2
3
|
import { resolveAttemptInfo } from './attempt-utils';
|
|
3
4
|
export const getRegistrationAttemptInfo = async (lrs, registration, options) => {
|
|
@@ -50,6 +51,11 @@ export const getCurrentGrade = async (services, registration, options) => {
|
|
|
50
51
|
};
|
|
51
52
|
export const getAllGradesForAssignment = async (services, registration, options) => {
|
|
52
53
|
const infoPerUserUuid = await getRegistrationAttemptInfo(services.lrs, registration, { anyUser: true });
|
|
53
|
-
const
|
|
54
|
-
|
|
54
|
+
const mappedInfo = await services.accountsGateway.mapUserUuids(infoPerUserUuid, services.logger, options === null || options === void 0 ? void 0 : options.platformId);
|
|
55
|
+
const gradeCompletedAttemptsOnly = (results) => results.map(([userId, userInfo]) => getInfoGrade(userInfo, userId, options === null || options === void 0 ? void 0 : options.scoreMaximum));
|
|
56
|
+
if (!(options === null || options === void 0 ? void 0 : options.incompleteAttemptsCallback)) {
|
|
57
|
+
return gradeCompletedAttemptsOnly(mappedInfo);
|
|
58
|
+
}
|
|
59
|
+
const [incompleteInfo, completedInfo] = partition((info) => info[1].currentAttemptCompleted === undefined)(mappedInfo);
|
|
60
|
+
return gradeCompletedAttemptsOnly(completedInfo).concat(await options.incompleteAttemptsCallback(incompleteInfo));
|
|
55
61
|
};
|