@openstax/ts-utils 1.41.5 → 1.43.0

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.
@@ -81,6 +81,6 @@ export declare const putAttemptActivityStatement: (gateway: LrsGateway, attemptS
81
81
  export declare const createCompletedStatement: (attemptStatement: UXapiStatement, result?: UXapiStatement["result"]) => Pick<UXapiStatement, "object" | "verb" | "context" | "result">;
82
82
  export declare const putCompletedStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement, result: UXapiStatement["result"], user?: string) => Promise<import(".").EagerXapiStatement>;
83
83
  export declare const createCompletedPendingScoringStatement: (attemptStatement: UXapiStatement) => Pick<UXapiStatement, "object" | "verb" | "context" | "result">;
84
- export declare const putCompletedPendingScoringStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement) => Promise<import(".").EagerXapiStatement>;
84
+ export declare const putCompletedPendingScoringStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement, user?: string) => Promise<import(".").EagerXapiStatement>;
85
85
  export declare const createScoredStatement: (attemptStatement: UXapiStatement, result: UXapiStatement["result"]) => Pick<UXapiStatement, "object" | "verb" | "context" | "result">;
86
- export declare const putScoredStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement, result: UXapiStatement["result"]) => Promise<import(".").EagerXapiStatement>;
86
+ export declare const putScoredStatement: (gateway: LrsGateway, attemptStatement: UXapiStatement, result: UXapiStatement["result"], user?: string) => Promise<import(".").EagerXapiStatement>;
@@ -295,10 +295,10 @@ export const putCompletedStatement = async (gateway, attemptStatement, result, u
295
295
  export const createCompletedPendingScoringStatement = (attemptStatement) => createCompletedStatement(attemptStatement, {
296
296
  extensions: { [EXT_PENDING_SCORING]: 'true' },
297
297
  });
298
- export const putCompletedPendingScoringStatement = async (gateway, attemptStatement) => {
298
+ export const putCompletedPendingScoringStatement = async (gateway, attemptStatement, user) => {
299
299
  return (await gateway.putXapiStatements([
300
300
  createCompletedPendingScoringStatement(attemptStatement),
301
- ]))[0];
301
+ ], user))[0];
302
302
  };
303
303
  // scored statement for when the open written response has been graded.
304
304
  export const createScoredStatement = (attemptStatement, result) => {
@@ -327,6 +327,6 @@ export const createScoredStatement = (attemptStatement, result) => {
327
327
  }
328
328
  };
329
329
  };
330
- export const putScoredStatement = async (gateway, attemptStatement, result) => {
331
- return (await gateway.putXapiStatements([createScoredStatement(attemptStatement, result)]))[0];
330
+ export const putScoredStatement = async (gateway, attemptStatement, result, user) => {
331
+ return (await gateway.putXapiStatements([createScoredStatement(attemptStatement, result)], user))[0];
332
332
  };
@@ -62,15 +62,17 @@ export const fileSystemLrsGateway = (initializer) => (configProvider) => ({ auth
62
62
  }));
63
63
  let previousSave;
64
64
  let previousStateSave;
65
- const putXapiStatements = async (statements) => {
66
- const user = assertDefined(await authProvider.getUser(), new UnauthorizedError);
65
+ const putXapiStatements = async (statements, user) => {
66
+ const author = user
67
+ ? { uuid: user }
68
+ : assertDefined(await authProvider.getUser(), new UnauthorizedError);
67
69
  const statementsWithDefaults = statements.map(statement => ({
68
70
  ...statement,
69
71
  id: uuid(),
70
72
  actor: {
71
73
  account: {
72
74
  homePage: 'https://openstax.org',
73
- name: user.uuid,
75
+ name: author.uuid,
74
76
  },
75
77
  objectType: 'Agent',
76
78
  },