@openstax/ts-utils 1.5.6 → 1.5.8

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.
@@ -12,8 +12,10 @@ export interface Grade {
12
12
  userId: string;
13
13
  }
14
14
  export declare const getRegistrationAttemptInfo: (lrs: LrsGateway, registration: string, options?: {
15
+ activity?: string | undefined;
15
16
  anyUser?: boolean | undefined;
16
17
  currentPreference?: "latest" | "oldest" | undefined;
18
+ ensureSync?: boolean | undefined;
17
19
  user?: string | undefined;
18
20
  } | undefined) => Promise<{
19
21
  [key: string]: ActivityState;
@@ -47,7 +49,7 @@ export declare const getAssignmentGrades: (services: {
47
49
  accountsGateway: AccountsGateway;
48
50
  lrs: LrsGateway;
49
51
  logger: Logger;
50
- }, registration: string, options?: {
52
+ }, assignmentIRI: string, registration: string, options?: {
51
53
  anyUser?: boolean | undefined;
52
54
  currentPreference?: "latest" | "oldest" | undefined;
53
55
  incompleteAttemptsCallback?: ((mappedInfo: UserActivityInfo[]) => Promise<GradeAndProgress[]>) | undefined;
@@ -3,7 +3,7 @@ import { roundToPrecision } from '../..';
3
3
  import { 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
- const allStatements = await lrs.getAllXapiStatements({ ...xapiOptions, registration, ensureSync: true });
6
+ const allStatements = await lrs.getAllXapiStatements({ ...xapiOptions, registration });
7
7
  // Partition statements for each user
8
8
  const statementsPerUser = {};
9
9
  allStatements.forEach((statement) => {
@@ -33,7 +33,9 @@ export const getScoreGrade = (score, completed, userId, maxScore) => {
33
33
  return {
34
34
  userId,
35
35
  activityProgress: completed ? 'Completed' : 'Started',
36
- gradingProgress: completed ? 'FullyGraded' : 'NotReady',
36
+ // canvas assumes that anything that isn't 'FullyGraded' requires manual grading and displays a "needs grading" icon.
37
+ // if you warp your mind you can consider the portion of the assignment which is completed to be fully graded.
38
+ gradingProgress: 'FullyGraded',
37
39
  scoreMaximum,
38
40
  scoreGiven: roundToPrecision(scoreGiven, -2),
39
41
  };
@@ -67,9 +69,9 @@ export const getCurrentGrade = async (services, registration, options) => {
67
69
  }
68
70
  return incompleteAttemptCallback(userInfo);
69
71
  };
70
- export const getAssignmentGrades = async (services, registration, options) => {
72
+ export const getAssignmentGrades = async (services, assignmentIRI, registration, options) => {
71
73
  const { anyUser, currentPreference, incompleteAttemptsCallback, platformId, scoreMaximum, user } = options !== null && options !== void 0 ? options : {};
72
- const infoPerUserUuid = await getRegistrationAttemptInfo(services.lrs, registration, { anyUser, currentPreference, user });
74
+ const infoPerUserUuid = await getRegistrationAttemptInfo(services.lrs, registration, { activity: assignmentIRI, anyUser, currentPreference, user });
73
75
  const mappedInfo = await services.accountsGateway.mapUserUuids(infoPerUserUuid, services.logger, platformId);
74
76
  if (!incompleteAttemptsCallback) {
75
77
  return getCompletedUserInfosGradeAndProgress(mappedInfo, scoreMaximum);