@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;
@@ -9,7 +9,7 @@ const __1 = require("../..");
9
9
  const attempt_utils_1 = require("./attempt-utils");
10
10
  const getRegistrationAttemptInfo = async (lrs, registration, options) => {
11
11
  const { currentPreference, ...xapiOptions } = options !== null && options !== void 0 ? options : {};
12
- const allStatements = await lrs.getAllXapiStatements({ ...xapiOptions, registration, ensureSync: true });
12
+ const allStatements = await lrs.getAllXapiStatements({ ...xapiOptions, registration });
13
13
  // Partition statements for each user
14
14
  const statementsPerUser = {};
15
15
  allStatements.forEach((statement) => {
@@ -40,7 +40,9 @@ const getScoreGrade = (score, completed, userId, maxScore) => {
40
40
  return {
41
41
  userId,
42
42
  activityProgress: completed ? 'Completed' : 'Started',
43
- gradingProgress: completed ? 'FullyGraded' : 'NotReady',
43
+ // canvas assumes that anything that isn't 'FullyGraded' requires manual grading and displays a "needs grading" icon.
44
+ // if you warp your mind you can consider the portion of the assignment which is completed to be fully graded.
45
+ gradingProgress: 'FullyGraded',
44
46
  scoreMaximum,
45
47
  scoreGiven: (0, __1.roundToPrecision)(scoreGiven, -2),
46
48
  };
@@ -76,9 +78,9 @@ const getCurrentGrade = async (services, registration, options) => {
76
78
  return incompleteAttemptCallback(userInfo);
77
79
  };
78
80
  exports.getCurrentGrade = getCurrentGrade;
79
- const getAssignmentGrades = async (services, registration, options) => {
81
+ const getAssignmentGrades = async (services, assignmentIRI, registration, options) => {
80
82
  const { anyUser, currentPreference, incompleteAttemptsCallback, platformId, scoreMaximum, user } = options !== null && options !== void 0 ? options : {};
81
- const infoPerUserUuid = await (0, exports.getRegistrationAttemptInfo)(services.lrs, registration, { anyUser, currentPreference, user });
83
+ const infoPerUserUuid = await (0, exports.getRegistrationAttemptInfo)(services.lrs, registration, { activity: assignmentIRI, anyUser, currentPreference, user });
82
84
  const mappedInfo = await services.accountsGateway.mapUserUuids(infoPerUserUuid, services.logger, platformId);
83
85
  if (!incompleteAttemptsCallback) {
84
86
  return getCompletedUserInfosGradeAndProgress(mappedInfo, scoreMaximum);