@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.
@@ -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;
@@ -92,7 +92,7 @@ export const accountsGateway = (initializer) => (configProvider) => {
92
92
  accountsUuid: user.uuid,
93
93
  });
94
94
  }
95
- return { data, fullName: user.full_name, platformUserId, uuid: user.uuid };
95
+ return { data, firstName: user.first_name, lastName: user.last_name, fullName: user.full_name, platformUserId, uuid: user.uuid };
96
96
  });
97
97
  return results.filter(isDefined);
98
98
  };
@@ -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>;
@@ -53,9 +53,12 @@ export const resolveScoredForAttempt = (statements, attempt, activityIRI) => {
53
53
  return mostRecentStatement(scoringStatements);
54
54
  };
55
55
  const resolveAttemptEntries = (statements, attempts, activityIRI) => attempts.reduce((acc, attempt) => {
56
+ var _a, _b, _c, _d;
56
57
  const completed = resolveCompletedForAttempt(statements, attempt, activityIRI);
57
58
  const scored = resolveScoredForAttempt(statements, attempt, activityIRI);
58
- acc.push({ attempt, completed, scored });
59
+ 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[EXT_PENDING_SCORING]) === 'true' && scored === undefined) ||
60
+ ((_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[EXT_PENDING_SCORING]) === 'true';
61
+ acc.push({ attempt, completed, scored, needsScoring });
59
62
  return acc;
60
63
  }, []);
61
64
  export const getStatementTimeString = (statement) => 'stored' in statement && statement.stored ? statement.stored : statement.timestamp;
@@ -330,3 +333,13 @@ export const createScoredStatement = (attemptStatement, result) => {
330
333
  export const putScoredStatement = async (gateway, attemptStatement, result, user) => {
331
334
  return (await gateway.putXapiStatements([createScoredStatement(attemptStatement, result)], user))[0];
332
335
  };
336
+ // scored statement for retry assessments - records a score but marks the attempt as still pending scoring
337
+ export const createScoredPendingScoringStatement = (attemptStatement, result) => createScoredStatement(attemptStatement, {
338
+ ...result,
339
+ extensions: { [EXT_PENDING_SCORING]: 'true' },
340
+ });
341
+ export const putScoredPendingScoringStatement = async (gateway, attemptStatement, result, user) => {
342
+ return (await gateway.putXapiStatements([
343
+ createScoredPendingScoringStatement(attemptStatement, result),
344
+ ], user))[0];
345
+ };
@@ -1,6 +1,6 @@
1
1
  import partition from 'lodash/fp/partition';
2
2
  import { roundToPrecision } from '../..';
3
- import { EXT_PENDING_SCORING, getStatementTimeString, resolveAttemptInfo } from './attempt-utils';
3
+ import { getStatementTimeString, resolveAttemptInfo } from './attempt-utils';
4
4
  export const getRegistrationAttemptInfo = async (lrs, registration, options) => {
5
5
  const { currentPreference, ...xapiOptions } = options !== null && options !== void 0 ? options : {};
6
6
  const allStatements = await lrs.getAllXapiStatements({ ...xapiOptions, registration });
@@ -24,7 +24,7 @@ export const getRegistrationAttemptInfo = async (lrs, registration, options) =>
24
24
  // ltijs: https://cvmcosta.me/ltijs/#/grading
25
25
  // Note: "min" is currently completely ignored
26
26
  export const getScoreGrade = (entry, options) => {
27
- var _a, _b, _c, _d, _e;
27
+ var _a, _b;
28
28
  const { raw, scaled, max } = ((_b = (_a = entry.scored) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.score) || {};
29
29
  const { maxScore, userId } = options;
30
30
  const scoreMaximum = maxScore !== null && maxScore !== void 0 ? maxScore : 100;
@@ -37,8 +37,7 @@ export const getScoreGrade = (entry, options) => {
37
37
  startedAt: entry.attempt ? getStatementTimeString(entry.attempt) : undefined,
38
38
  submittedAt: entry.completed ? getStatementTimeString(entry.completed) : undefined,
39
39
  };
40
- const pendingManual = entry.scored === undefined
41
- && ((_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[EXT_PENDING_SCORING]) === 'true';
40
+ const pendingManual = entry.needsScoring;
42
41
  return {
43
42
  userId,
44
43
  activityProgress: entry.completed ? 'Completed' : 'Started',