@openstax/ts-utils 1.5.0 → 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/config/envConfig.js +12 -3
- 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/config/envConfig.js +12 -3
- 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,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.envConfig = exports.ENV_BUILD_CONFIGS = void 0;
|
|
4
|
-
const
|
|
5
|
-
const guards_1 = require("../guards");
|
|
4
|
+
const _1 = require(".");
|
|
6
5
|
/**
|
|
7
6
|
* A list of environment variables that were requested at build time. Used by webpack to
|
|
8
7
|
* capture build-time environment variables values.
|
|
@@ -35,7 +34,17 @@ const envConfig = (name, type = 'build', defaultValue) => {
|
|
|
35
34
|
// - https://github.com/webpack/webpack/issues/14800
|
|
36
35
|
// - https://github.com/webpack/webpack/issues/5392
|
|
37
36
|
const envs = { ...process.env, ...(typeof __PROCESS_ENV !== 'undefined' ? __PROCESS_ENV : {}) };
|
|
38
|
-
|
|
37
|
+
if (envs[name] === undefined) {
|
|
38
|
+
if (defaultValue === undefined) {
|
|
39
|
+
throw new Error(`expected to find environment variable with name: ${name}`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return (0, _1.resolveConfigValue)(defaultValue);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return envs[name];
|
|
47
|
+
}
|
|
39
48
|
};
|
|
40
49
|
};
|
|
41
50
|
exports.envConfig = envConfig;
|
|
@@ -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,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getAllGradesForAssignment = exports.getCurrentGrade = exports.getRegistrationAttemptInfo = void 0;
|
|
7
|
+
const partition_1 = __importDefault(require("lodash/fp/partition"));
|
|
4
8
|
const __1 = require("../..");
|
|
5
9
|
const attempt_utils_1 = require("./attempt-utils");
|
|
6
10
|
const getRegistrationAttemptInfo = async (lrs, registration, options) => {
|
|
@@ -55,7 +59,12 @@ const getCurrentGrade = async (services, registration, options) => {
|
|
|
55
59
|
exports.getCurrentGrade = getCurrentGrade;
|
|
56
60
|
const getAllGradesForAssignment = async (services, registration, options) => {
|
|
57
61
|
const infoPerUserUuid = await (0, exports.getRegistrationAttemptInfo)(services.lrs, registration, { anyUser: true });
|
|
58
|
-
const
|
|
59
|
-
|
|
62
|
+
const mappedInfo = await services.accountsGateway.mapUserUuids(infoPerUserUuid, services.logger, options === null || options === void 0 ? void 0 : options.platformId);
|
|
63
|
+
const gradeCompletedAttemptsOnly = (results) => results.map(([userId, userInfo]) => getInfoGrade(userInfo, userId, options === null || options === void 0 ? void 0 : options.scoreMaximum));
|
|
64
|
+
if (!(options === null || options === void 0 ? void 0 : options.incompleteAttemptsCallback)) {
|
|
65
|
+
return gradeCompletedAttemptsOnly(mappedInfo);
|
|
66
|
+
}
|
|
67
|
+
const [incompleteInfo, completedInfo] = (0, partition_1.default)((info) => info[1].currentAttemptCompleted === undefined)(mappedInfo);
|
|
68
|
+
return gradeCompletedAttemptsOnly(completedInfo).concat(await options.incompleteAttemptsCallback(incompleteInfo));
|
|
60
69
|
};
|
|
61
70
|
exports.getAllGradesForAssignment = getAllGradesForAssignment;
|