@playcademy/sandbox 0.6.1-beta.1 → 0.6.1-beta.2
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/cli.js +42 -14
- package/dist/server.js +42 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1080,7 +1080,7 @@ var package_default;
|
|
|
1080
1080
|
var init_package = __esm(() => {
|
|
1081
1081
|
package_default = {
|
|
1082
1082
|
name: "@playcademy/sandbox",
|
|
1083
|
-
version: "0.6.1-beta.
|
|
1083
|
+
version: "0.6.1-beta.2",
|
|
1084
1084
|
description: "Local development server for Playcademy game development",
|
|
1085
1085
|
type: "module",
|
|
1086
1086
|
exports: {
|
|
@@ -31047,7 +31047,7 @@ var init_schemas4 = __esm(() => {
|
|
|
31047
31047
|
subject: TimebackSubjectSchema,
|
|
31048
31048
|
appName: exports_external.string().optional(),
|
|
31049
31049
|
sensorUrl: exports_external.string().url().optional(),
|
|
31050
|
-
courseId: exports_external.string().optional(),
|
|
31050
|
+
courseId: exports_external.string().min(1).optional(),
|
|
31051
31051
|
courseName: exports_external.string().optional(),
|
|
31052
31052
|
studentEmail: exports_external.string().email().optional()
|
|
31053
31053
|
});
|
|
@@ -80373,6 +80373,24 @@ var init_timeback_service = __esm(async () => {
|
|
|
80373
80373
|
}
|
|
80374
80374
|
};
|
|
80375
80375
|
}
|
|
80376
|
+
static resolveRuntimeCourse(resolvedCourseId, requestedCourseId, courseName) {
|
|
80377
|
+
let requestedCourseIdStatus = "absent";
|
|
80378
|
+
if (requestedCourseId === resolvedCourseId) {
|
|
80379
|
+
requestedCourseIdStatus = "accepted";
|
|
80380
|
+
} else if (requestedCourseId !== undefined) {
|
|
80381
|
+
requestedCourseIdStatus = "ignored_mismatch";
|
|
80382
|
+
}
|
|
80383
|
+
return {
|
|
80384
|
+
courseId: resolvedCourseId,
|
|
80385
|
+
courseName: requestedCourseIdStatus === "ignored_mismatch" ? undefined : courseName,
|
|
80386
|
+
attributes: {
|
|
80387
|
+
"app.timeback.course_id": resolvedCourseId,
|
|
80388
|
+
"app.timeback.resolved_course_id": resolvedCourseId,
|
|
80389
|
+
"app.timeback.requested_course_id": requestedCourseId,
|
|
80390
|
+
"app.timeback.requested_course_id_status": requestedCourseIdStatus
|
|
80391
|
+
}
|
|
80392
|
+
};
|
|
80393
|
+
}
|
|
80376
80394
|
static recordRuntimeContext({
|
|
80377
80395
|
operation,
|
|
80378
80396
|
studentId,
|
|
@@ -81238,8 +81256,13 @@ var init_timeback_service = __esm(async () => {
|
|
|
81238
81256
|
if (!integration) {
|
|
81239
81257
|
throw new NotFoundError(`Timeback integration for game (grade ${activityData.grade}, subject ${activityData.subject})`);
|
|
81240
81258
|
}
|
|
81259
|
+
const {
|
|
81260
|
+
courseId: runtimeCourseId,
|
|
81261
|
+
courseName: runtimeCourseName,
|
|
81262
|
+
attributes: courseAttributes
|
|
81263
|
+
} = TimebackService.resolveRuntimeCourse(integration.courseId, activityData.courseId, activityData.courseName);
|
|
81241
81264
|
const scorePercentage = scoreData.totalQuestions > 0 ? scoreData.correctQuestions / scoreData.totalQuestions * 100 : 0;
|
|
81242
|
-
const result = await client.activity.record(
|
|
81265
|
+
const result = await client.activity.record(runtimeCourseId, studentId, {
|
|
81243
81266
|
gameId,
|
|
81244
81267
|
score: scorePercentage,
|
|
81245
81268
|
totalQuestions: scoreData.totalQuestions,
|
|
@@ -81254,8 +81277,8 @@ var init_timeback_service = __esm(async () => {
|
|
|
81254
81277
|
subject: activityData.subject,
|
|
81255
81278
|
appName: activityData.appName,
|
|
81256
81279
|
sensorUrl: activityData.sensorUrl,
|
|
81257
|
-
courseId:
|
|
81258
|
-
courseName:
|
|
81280
|
+
courseId: runtimeCourseId,
|
|
81281
|
+
courseName: runtimeCourseName,
|
|
81259
81282
|
studentEmail: activityData.studentEmail,
|
|
81260
81283
|
courseTotalXp: integration.totalXp,
|
|
81261
81284
|
...runId ? { runId } : {}
|
|
@@ -81264,7 +81287,7 @@ var init_timeback_service = __esm(async () => {
|
|
|
81264
81287
|
const sessionEndInactiveSeconds = sessionTimingData?.inactiveSeconds;
|
|
81265
81288
|
const sessionEndEmitted = sessionEndActiveSeconds > 0 || (sessionEndInactiveSeconds ?? 0) > 0;
|
|
81266
81289
|
if (sessionEndEmitted) {
|
|
81267
|
-
await client.activity.session(
|
|
81290
|
+
await client.activity.session(runtimeCourseId, studentId, {
|
|
81268
81291
|
gameId,
|
|
81269
81292
|
activeTimeSeconds: sessionEndActiveSeconds,
|
|
81270
81293
|
...sessionEndInactiveSeconds !== undefined ? { inactiveTimeSeconds: sessionEndInactiveSeconds } : {},
|
|
@@ -81273,15 +81296,15 @@ var init_timeback_service = __esm(async () => {
|
|
|
81273
81296
|
subject: activityData.subject,
|
|
81274
81297
|
appName: activityData.appName,
|
|
81275
81298
|
sensorUrl: activityData.sensorUrl,
|
|
81276
|
-
courseId:
|
|
81277
|
-
courseName:
|
|
81299
|
+
courseId: runtimeCourseId,
|
|
81300
|
+
courseName: runtimeCourseName,
|
|
81278
81301
|
studentEmail: activityData.studentEmail,
|
|
81279
81302
|
extensions: extensionsWithResumeId,
|
|
81280
81303
|
...runId ? { runId } : {}
|
|
81281
81304
|
});
|
|
81282
81305
|
}
|
|
81283
81306
|
setAttributes({
|
|
81284
|
-
|
|
81307
|
+
...courseAttributes,
|
|
81285
81308
|
"app.timeback.grade": activityData.grade,
|
|
81286
81309
|
"app.timeback.subject": activityData.subject,
|
|
81287
81310
|
"app.timeback.total_questions": scoreData.totalQuestions,
|
|
@@ -81298,7 +81321,7 @@ var init_timeback_service = __esm(async () => {
|
|
|
81298
81321
|
});
|
|
81299
81322
|
return {
|
|
81300
81323
|
status: "ok",
|
|
81301
|
-
courseId:
|
|
81324
|
+
courseId: runtimeCourseId,
|
|
81302
81325
|
xpAwarded: result.xpAwarded,
|
|
81303
81326
|
masteredUnits: result.masteredUnitsApplied,
|
|
81304
81327
|
pctCompleteApp: result.pctCompleteApp,
|
|
@@ -81509,10 +81532,15 @@ var init_timeback_service = __esm(async () => {
|
|
|
81509
81532
|
if (!integration) {
|
|
81510
81533
|
throw new NotFoundError(`Timeback integration for game (grade ${activityData.grade}, subject ${activityData.subject})`);
|
|
81511
81534
|
}
|
|
81535
|
+
const {
|
|
81536
|
+
courseId: runtimeCourseId,
|
|
81537
|
+
courseName: runtimeCourseName,
|
|
81538
|
+
attributes: courseAttributes
|
|
81539
|
+
} = TimebackService.resolveRuntimeCourse(integration.courseId, activityData.courseId, activityData.courseName);
|
|
81512
81540
|
const activeTimeSeconds = timingData.activeMs / 1000;
|
|
81513
81541
|
const inactiveTimeSeconds = timingData.pausedMs / 1000;
|
|
81514
81542
|
if (activeTimeSeconds > 0 || inactiveTimeSeconds > 0) {
|
|
81515
|
-
await client.activity.session(
|
|
81543
|
+
await client.activity.session(runtimeCourseId, studentId, {
|
|
81516
81544
|
gameId,
|
|
81517
81545
|
activeTimeSeconds,
|
|
81518
81546
|
...inactiveTimeSeconds > 0 ? { inactiveTimeSeconds } : {},
|
|
@@ -81521,15 +81549,15 @@ var init_timeback_service = __esm(async () => {
|
|
|
81521
81549
|
subject: activityData.subject,
|
|
81522
81550
|
appName: activityData.appName,
|
|
81523
81551
|
sensorUrl: activityData.sensorUrl,
|
|
81524
|
-
courseId:
|
|
81525
|
-
courseName:
|
|
81552
|
+
courseId: runtimeCourseId,
|
|
81553
|
+
courseName: runtimeCourseName,
|
|
81526
81554
|
studentEmail: activityData.studentEmail,
|
|
81527
81555
|
extensions: TimebackService.addResumeIdToExtensions(undefined, effectiveResumeId),
|
|
81528
81556
|
...runId ? { runId } : {}
|
|
81529
81557
|
});
|
|
81530
81558
|
}
|
|
81531
81559
|
setAttributes({
|
|
81532
|
-
|
|
81560
|
+
...courseAttributes,
|
|
81533
81561
|
"app.timeback.grade": activityData.grade,
|
|
81534
81562
|
"app.timeback.subject": activityData.subject,
|
|
81535
81563
|
"app.timeback.active_time_seconds": activeTimeSeconds,
|
package/dist/server.js
CHANGED
|
@@ -1079,7 +1079,7 @@ var package_default;
|
|
|
1079
1079
|
var init_package = __esm(() => {
|
|
1080
1080
|
package_default = {
|
|
1081
1081
|
name: "@playcademy/sandbox",
|
|
1082
|
-
version: "0.6.1-beta.
|
|
1082
|
+
version: "0.6.1-beta.2",
|
|
1083
1083
|
description: "Local development server for Playcademy game development",
|
|
1084
1084
|
type: "module",
|
|
1085
1085
|
exports: {
|
|
@@ -31046,7 +31046,7 @@ var init_schemas4 = __esm(() => {
|
|
|
31046
31046
|
subject: TimebackSubjectSchema,
|
|
31047
31047
|
appName: exports_external.string().optional(),
|
|
31048
31048
|
sensorUrl: exports_external.string().url().optional(),
|
|
31049
|
-
courseId: exports_external.string().optional(),
|
|
31049
|
+
courseId: exports_external.string().min(1).optional(),
|
|
31050
31050
|
courseName: exports_external.string().optional(),
|
|
31051
31051
|
studentEmail: exports_external.string().email().optional()
|
|
31052
31052
|
});
|
|
@@ -80372,6 +80372,24 @@ var init_timeback_service = __esm(async () => {
|
|
|
80372
80372
|
}
|
|
80373
80373
|
};
|
|
80374
80374
|
}
|
|
80375
|
+
static resolveRuntimeCourse(resolvedCourseId, requestedCourseId, courseName) {
|
|
80376
|
+
let requestedCourseIdStatus = "absent";
|
|
80377
|
+
if (requestedCourseId === resolvedCourseId) {
|
|
80378
|
+
requestedCourseIdStatus = "accepted";
|
|
80379
|
+
} else if (requestedCourseId !== undefined) {
|
|
80380
|
+
requestedCourseIdStatus = "ignored_mismatch";
|
|
80381
|
+
}
|
|
80382
|
+
return {
|
|
80383
|
+
courseId: resolvedCourseId,
|
|
80384
|
+
courseName: requestedCourseIdStatus === "ignored_mismatch" ? undefined : courseName,
|
|
80385
|
+
attributes: {
|
|
80386
|
+
"app.timeback.course_id": resolvedCourseId,
|
|
80387
|
+
"app.timeback.resolved_course_id": resolvedCourseId,
|
|
80388
|
+
"app.timeback.requested_course_id": requestedCourseId,
|
|
80389
|
+
"app.timeback.requested_course_id_status": requestedCourseIdStatus
|
|
80390
|
+
}
|
|
80391
|
+
};
|
|
80392
|
+
}
|
|
80375
80393
|
static recordRuntimeContext({
|
|
80376
80394
|
operation,
|
|
80377
80395
|
studentId,
|
|
@@ -81237,8 +81255,13 @@ var init_timeback_service = __esm(async () => {
|
|
|
81237
81255
|
if (!integration) {
|
|
81238
81256
|
throw new NotFoundError(`Timeback integration for game (grade ${activityData.grade}, subject ${activityData.subject})`);
|
|
81239
81257
|
}
|
|
81258
|
+
const {
|
|
81259
|
+
courseId: runtimeCourseId,
|
|
81260
|
+
courseName: runtimeCourseName,
|
|
81261
|
+
attributes: courseAttributes
|
|
81262
|
+
} = TimebackService.resolveRuntimeCourse(integration.courseId, activityData.courseId, activityData.courseName);
|
|
81240
81263
|
const scorePercentage = scoreData.totalQuestions > 0 ? scoreData.correctQuestions / scoreData.totalQuestions * 100 : 0;
|
|
81241
|
-
const result = await client.activity.record(
|
|
81264
|
+
const result = await client.activity.record(runtimeCourseId, studentId, {
|
|
81242
81265
|
gameId,
|
|
81243
81266
|
score: scorePercentage,
|
|
81244
81267
|
totalQuestions: scoreData.totalQuestions,
|
|
@@ -81253,8 +81276,8 @@ var init_timeback_service = __esm(async () => {
|
|
|
81253
81276
|
subject: activityData.subject,
|
|
81254
81277
|
appName: activityData.appName,
|
|
81255
81278
|
sensorUrl: activityData.sensorUrl,
|
|
81256
|
-
courseId:
|
|
81257
|
-
courseName:
|
|
81279
|
+
courseId: runtimeCourseId,
|
|
81280
|
+
courseName: runtimeCourseName,
|
|
81258
81281
|
studentEmail: activityData.studentEmail,
|
|
81259
81282
|
courseTotalXp: integration.totalXp,
|
|
81260
81283
|
...runId ? { runId } : {}
|
|
@@ -81263,7 +81286,7 @@ var init_timeback_service = __esm(async () => {
|
|
|
81263
81286
|
const sessionEndInactiveSeconds = sessionTimingData?.inactiveSeconds;
|
|
81264
81287
|
const sessionEndEmitted = sessionEndActiveSeconds > 0 || (sessionEndInactiveSeconds ?? 0) > 0;
|
|
81265
81288
|
if (sessionEndEmitted) {
|
|
81266
|
-
await client.activity.session(
|
|
81289
|
+
await client.activity.session(runtimeCourseId, studentId, {
|
|
81267
81290
|
gameId,
|
|
81268
81291
|
activeTimeSeconds: sessionEndActiveSeconds,
|
|
81269
81292
|
...sessionEndInactiveSeconds !== undefined ? { inactiveTimeSeconds: sessionEndInactiveSeconds } : {},
|
|
@@ -81272,15 +81295,15 @@ var init_timeback_service = __esm(async () => {
|
|
|
81272
81295
|
subject: activityData.subject,
|
|
81273
81296
|
appName: activityData.appName,
|
|
81274
81297
|
sensorUrl: activityData.sensorUrl,
|
|
81275
|
-
courseId:
|
|
81276
|
-
courseName:
|
|
81298
|
+
courseId: runtimeCourseId,
|
|
81299
|
+
courseName: runtimeCourseName,
|
|
81277
81300
|
studentEmail: activityData.studentEmail,
|
|
81278
81301
|
extensions: extensionsWithResumeId,
|
|
81279
81302
|
...runId ? { runId } : {}
|
|
81280
81303
|
});
|
|
81281
81304
|
}
|
|
81282
81305
|
setAttributes({
|
|
81283
|
-
|
|
81306
|
+
...courseAttributes,
|
|
81284
81307
|
"app.timeback.grade": activityData.grade,
|
|
81285
81308
|
"app.timeback.subject": activityData.subject,
|
|
81286
81309
|
"app.timeback.total_questions": scoreData.totalQuestions,
|
|
@@ -81297,7 +81320,7 @@ var init_timeback_service = __esm(async () => {
|
|
|
81297
81320
|
});
|
|
81298
81321
|
return {
|
|
81299
81322
|
status: "ok",
|
|
81300
|
-
courseId:
|
|
81323
|
+
courseId: runtimeCourseId,
|
|
81301
81324
|
xpAwarded: result.xpAwarded,
|
|
81302
81325
|
masteredUnits: result.masteredUnitsApplied,
|
|
81303
81326
|
pctCompleteApp: result.pctCompleteApp,
|
|
@@ -81508,10 +81531,15 @@ var init_timeback_service = __esm(async () => {
|
|
|
81508
81531
|
if (!integration) {
|
|
81509
81532
|
throw new NotFoundError(`Timeback integration for game (grade ${activityData.grade}, subject ${activityData.subject})`);
|
|
81510
81533
|
}
|
|
81534
|
+
const {
|
|
81535
|
+
courseId: runtimeCourseId,
|
|
81536
|
+
courseName: runtimeCourseName,
|
|
81537
|
+
attributes: courseAttributes
|
|
81538
|
+
} = TimebackService.resolveRuntimeCourse(integration.courseId, activityData.courseId, activityData.courseName);
|
|
81511
81539
|
const activeTimeSeconds = timingData.activeMs / 1000;
|
|
81512
81540
|
const inactiveTimeSeconds = timingData.pausedMs / 1000;
|
|
81513
81541
|
if (activeTimeSeconds > 0 || inactiveTimeSeconds > 0) {
|
|
81514
|
-
await client.activity.session(
|
|
81542
|
+
await client.activity.session(runtimeCourseId, studentId, {
|
|
81515
81543
|
gameId,
|
|
81516
81544
|
activeTimeSeconds,
|
|
81517
81545
|
...inactiveTimeSeconds > 0 ? { inactiveTimeSeconds } : {},
|
|
@@ -81520,15 +81548,15 @@ var init_timeback_service = __esm(async () => {
|
|
|
81520
81548
|
subject: activityData.subject,
|
|
81521
81549
|
appName: activityData.appName,
|
|
81522
81550
|
sensorUrl: activityData.sensorUrl,
|
|
81523
|
-
courseId:
|
|
81524
|
-
courseName:
|
|
81551
|
+
courseId: runtimeCourseId,
|
|
81552
|
+
courseName: runtimeCourseName,
|
|
81525
81553
|
studentEmail: activityData.studentEmail,
|
|
81526
81554
|
extensions: TimebackService.addResumeIdToExtensions(undefined, effectiveResumeId),
|
|
81527
81555
|
...runId ? { runId } : {}
|
|
81528
81556
|
});
|
|
81529
81557
|
}
|
|
81530
81558
|
setAttributes({
|
|
81531
|
-
|
|
81559
|
+
...courseAttributes,
|
|
81532
81560
|
"app.timeback.grade": activityData.grade,
|
|
81533
81561
|
"app.timeback.subject": activityData.subject,
|
|
81534
81562
|
"app.timeback.active_time_seconds": activeTimeSeconds,
|