@openstax/ts-utils 1.44.0 → 1.44.1
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/accountsGateway/index.d.ts +4 -0
- package/dist/cjs/services/accountsGateway/index.js +1 -1
- package/dist/cjs/services/lrsGateway/attempt-utils.d.ts +3 -0
- package/dist/cjs/services/lrsGateway/attempt-utils.js +17 -2
- package/dist/cjs/services/lrsGateway/xapiUtils.js +2 -3
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/accountsGateway/index.d.ts +4 -0
- package/dist/esm/services/accountsGateway/index.js +1 -1
- package/dist/esm/services/lrsGateway/attempt-utils.d.ts +3 -0
- package/dist/esm/services/lrsGateway/attempt-utils.js +14 -1
- package/dist/esm/services/lrsGateway/xapiUtils.js +3 -4
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/script/bin/.init-params-script.bash.swp +0 -0
|
@@ -66,6 +66,8 @@ export type SearchUsersResponse = {
|
|
|
66
66
|
export type UpdateUserPayload = Partial<ApiUser>;
|
|
67
67
|
export type MappedUserInfo<T> = {
|
|
68
68
|
data: T;
|
|
69
|
+
firstName: string;
|
|
70
|
+
lastName: string;
|
|
69
71
|
fullName: string;
|
|
70
72
|
platformUserId?: string;
|
|
71
73
|
uuid: string;
|
|
@@ -81,6 +83,8 @@ export declare const accountsGateway: <C extends string = "accounts">(initialize
|
|
|
81
83
|
[uuid: string]: T;
|
|
82
84
|
}, platformId?: string) => Promise<{
|
|
83
85
|
data: T;
|
|
86
|
+
firstName: string;
|
|
87
|
+
lastName: string;
|
|
84
88
|
fullName: string;
|
|
85
89
|
platformUserId: string | undefined;
|
|
86
90
|
uuid: string;
|
|
@@ -98,7 +98,7 @@ const accountsGateway = (initializer) => (configProvider) => {
|
|
|
98
98
|
accountsUuid: user.uuid,
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
return { data, fullName: user.full_name, platformUserId, uuid: user.uuid };
|
|
101
|
+
return { data, firstName: user.first_name, lastName: user.last_name, fullName: user.full_name, platformUserId, uuid: user.uuid };
|
|
102
102
|
});
|
|
103
103
|
return results.filter(guards_1.isDefined);
|
|
104
104
|
};
|
|
@@ -4,6 +4,7 @@ export type AttemptEntry = {
|
|
|
4
4
|
attempt: UXapiStatement;
|
|
5
5
|
completed?: UXapiStatement;
|
|
6
6
|
scored?: UXapiStatement;
|
|
7
|
+
needsScoring: boolean;
|
|
7
8
|
};
|
|
8
9
|
export type ActivityState = {
|
|
9
10
|
attempts: number;
|
|
@@ -84,3 +85,5 @@ export declare const createCompletedPendingScoringStatement: (attemptStatement:
|
|
|
84
85
|
export declare const putCompletedPendingScoringStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement, user?: string) => Promise<import(".").EagerXapiStatement>;
|
|
85
86
|
export declare const createScoredStatement: (attemptStatement: UXapiStatement, result: UXapiStatement["result"]) => Pick<UXapiStatement, "object" | "verb" | "context" | "result">;
|
|
86
87
|
export declare const putScoredStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement, result: UXapiStatement["result"], user?: string) => Promise<import(".").EagerXapiStatement>;
|
|
88
|
+
export declare const createScoredPendingScoringStatement: (attemptStatement: UXapiStatement, result: UXapiStatement["result"]) => Pick<UXapiStatement, "object" | "verb" | "context" | "result">;
|
|
89
|
+
export declare const putScoredPendingScoringStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement, result: UXapiStatement["result"], user?: string) => Promise<import(".").EagerXapiStatement>;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.putScoredStatement = exports.createScoredStatement = exports.putCompletedPendingScoringStatement = exports.createCompletedPendingScoringStatement = exports.putCompletedStatement = exports.createCompletedStatement = exports.putAttemptActivityStatement = exports.createAttemptActivityStatement = exports.putAttemptStatement = exports.createAttemptStatement = exports.createStatement = exports.loadActivityAttemptInfo = exports.loadStatementsForActivityAndFirstChildren = exports.resolveAttemptInfo = exports.bestEntry = exports.mostRecentEntry = exports.oldestEntry = exports.mostRecentStatement = exports.oldestStatement = exports.getStatementTime = exports.getStatementTimeString = exports.resolveScoredForAttempt = exports.resolveCompletedForAttempt = exports.resolveAttempts = exports.matchAttemptScored = exports.matchAttemptCompleted = exports.matchAttempt = exports.EXT_PENDING_SCORING = void 0;
|
|
6
|
+
exports.putScoredPendingScoringStatement = exports.createScoredPendingScoringStatement = exports.putScoredStatement = exports.createScoredStatement = exports.putCompletedPendingScoringStatement = exports.createCompletedPendingScoringStatement = exports.putCompletedStatement = exports.createCompletedStatement = exports.putAttemptActivityStatement = exports.createAttemptActivityStatement = exports.putAttemptStatement = exports.createAttemptStatement = exports.createStatement = exports.loadActivityAttemptInfo = exports.loadStatementsForActivityAndFirstChildren = exports.resolveAttemptInfo = exports.bestEntry = exports.mostRecentEntry = exports.oldestEntry = exports.mostRecentStatement = exports.oldestStatement = exports.getStatementTime = exports.getStatementTimeString = exports.resolveScoredForAttempt = exports.resolveCompletedForAttempt = exports.resolveAttempts = exports.matchAttemptScored = exports.matchAttemptCompleted = exports.matchAttempt = exports.EXT_PENDING_SCORING = void 0;
|
|
7
7
|
/*
|
|
8
8
|
* the structure of xapi statements for handling multiple attempts of an activity
|
|
9
9
|
* including the option of a parent activity/attempt such that a new attempt
|
|
@@ -65,9 +65,12 @@ const resolveScoredForAttempt = (statements, attempt, activityIRI) => {
|
|
|
65
65
|
};
|
|
66
66
|
exports.resolveScoredForAttempt = resolveScoredForAttempt;
|
|
67
67
|
const resolveAttemptEntries = (statements, attempts, activityIRI) => attempts.reduce((acc, attempt) => {
|
|
68
|
+
var _a, _b, _c, _d;
|
|
68
69
|
const completed = (0, exports.resolveCompletedForAttempt)(statements, attempt, activityIRI);
|
|
69
70
|
const scored = (0, exports.resolveScoredForAttempt)(statements, attempt, activityIRI);
|
|
70
|
-
|
|
71
|
+
const needsScoring = (((_b = (_a = completed === null || completed === void 0 ? void 0 : completed.result) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b[exports.EXT_PENDING_SCORING]) === 'true' && scored === undefined) ||
|
|
72
|
+
((_d = (_c = scored === null || scored === void 0 ? void 0 : scored.result) === null || _c === void 0 ? void 0 : _c.extensions) === null || _d === void 0 ? void 0 : _d[exports.EXT_PENDING_SCORING]) === 'true';
|
|
73
|
+
acc.push({ attempt, completed, scored, needsScoring });
|
|
71
74
|
return acc;
|
|
72
75
|
}, []);
|
|
73
76
|
const getStatementTimeString = (statement) => 'stored' in statement && statement.stored ? statement.stored : statement.timestamp;
|
|
@@ -358,3 +361,15 @@ const putScoredStatement = async (gateway, attemptStatement, result, user) => {
|
|
|
358
361
|
return (await gateway.putXapiStatements([(0, exports.createScoredStatement)(attemptStatement, result)], user))[0];
|
|
359
362
|
};
|
|
360
363
|
exports.putScoredStatement = putScoredStatement;
|
|
364
|
+
// scored statement for retry assessments - records a score but marks the attempt as still pending scoring
|
|
365
|
+
const createScoredPendingScoringStatement = (attemptStatement, result) => (0, exports.createScoredStatement)(attemptStatement, {
|
|
366
|
+
...result,
|
|
367
|
+
extensions: { [exports.EXT_PENDING_SCORING]: 'true' },
|
|
368
|
+
});
|
|
369
|
+
exports.createScoredPendingScoringStatement = createScoredPendingScoringStatement;
|
|
370
|
+
const putScoredPendingScoringStatement = async (gateway, attemptStatement, result, user) => {
|
|
371
|
+
return (await gateway.putXapiStatements([
|
|
372
|
+
(0, exports.createScoredPendingScoringStatement)(attemptStatement, result),
|
|
373
|
+
], user))[0];
|
|
374
|
+
};
|
|
375
|
+
exports.putScoredPendingScoringStatement = putScoredPendingScoringStatement;
|
|
@@ -31,7 +31,7 @@ exports.getRegistrationAttemptInfo = getRegistrationAttemptInfo;
|
|
|
31
31
|
// ltijs: https://cvmcosta.me/ltijs/#/grading
|
|
32
32
|
// Note: "min" is currently completely ignored
|
|
33
33
|
const getScoreGrade = (entry, options) => {
|
|
34
|
-
var _a, _b
|
|
34
|
+
var _a, _b;
|
|
35
35
|
const { raw, scaled, max } = ((_b = (_a = entry.scored) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.score) || {};
|
|
36
36
|
const { maxScore, userId } = options;
|
|
37
37
|
const scoreMaximum = maxScore !== null && maxScore !== void 0 ? maxScore : 100;
|
|
@@ -44,8 +44,7 @@ const getScoreGrade = (entry, options) => {
|
|
|
44
44
|
startedAt: entry.attempt ? (0, attempt_utils_1.getStatementTimeString)(entry.attempt) : undefined,
|
|
45
45
|
submittedAt: entry.completed ? (0, attempt_utils_1.getStatementTimeString)(entry.completed) : undefined,
|
|
46
46
|
};
|
|
47
|
-
const pendingManual = entry.
|
|
48
|
-
&& ((_e = (_d = (_c = entry.completed) === null || _c === void 0 ? void 0 : _c.result) === null || _d === void 0 ? void 0 : _d.extensions) === null || _e === void 0 ? void 0 : _e[attempt_utils_1.EXT_PENDING_SCORING]) === 'true';
|
|
47
|
+
const pendingManual = entry.needsScoring;
|
|
49
48
|
return {
|
|
50
49
|
userId,
|
|
51
50
|
activityProgress: entry.completed ? 'Completed' : 'Started',
|