@edpire/sdk 0.6.12 → 0.8.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.
package/dist/react.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { RuntimeAnswer, QuestionRuntimeProps, AssessmentContent, AssessmentAnswers } from '@youssefalmia/edpire-runtime';
2
+ import { RuntimeAnswer, AssessmentAnswers, QuestionRuntimeProps, AssessmentContent } from '@youssefalmia/edpire-runtime';
3
3
  export { RuntimeAnswer } from '@youssefalmia/edpire-runtime';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { RichContent } from '@youssefalmia/edpire-schema/authoring';
@@ -40,6 +40,11 @@ interface EdpireQuestionProps {
40
40
  * Pre-fill answers — useful for restoring state when navigating back.
41
41
  */
42
42
  initialAnswers?: RuntimeAnswer[];
43
+ /**
44
+ * Lock the question: answers show but cannot be changed. For reviewing a
45
+ * finished attempt, with `initialAnswers` and `feedback` from `flattenReview()`.
46
+ */
47
+ readOnly?: boolean;
43
48
  /**
44
49
  * CSS class added to the question root div.
45
50
  */
@@ -80,6 +85,28 @@ interface TakeBranding {
80
85
  showPoweredBy?: boolean;
81
86
  } | null;
82
87
  }
88
+ /**
89
+ * Geometry of the question column. Branding covers colour and type; this covers
90
+ * the one thing branding could not reach.
91
+ */
92
+ interface ShellLayout {
93
+ /**
94
+ * Max width of the question column. Any CSS length, or `"none"` to fill the
95
+ * container. Default `"48rem"` (768px).
96
+ *
97
+ * The default is a reading measure, not an arbitrary cap: at the runtime's
98
+ * base size it yields roughly 70–90 characters per line, already the top of
99
+ * the comfortable range. Past about `"60rem"` the eye starts losing its place
100
+ * on the return sweep, which costs a learner more on a long comprehension
101
+ * passage than the empty gutters ever did.
102
+ *
103
+ * Keep the default when the player owns the whole page (`h-dvh`, no host
104
+ * chrome) — that is what it was measured for. Set `"none"` when you mount the
105
+ * player inside your own layout and your container already supplies the
106
+ * measure, otherwise learners see a column inside a column.
107
+ */
108
+ maxWidth?: string;
109
+ }
83
110
  type NodeDetail = {
84
111
  type: "choiceSet";
85
112
  correctChoiceIds: string[];
@@ -113,6 +140,13 @@ interface ExerciseFeedbackData {
113
140
  exerciseId: string;
114
141
  questions: QuestionFeedback[];
115
142
  }
143
+ /** What the shell needs to open on a finished attempt. See `AssessmentShellProps.review`. */
144
+ interface ShellReview {
145
+ /** The answers given in the attempt, in the shape `onSubmit` receives them. */
146
+ answers: AssessmentAnswers;
147
+ /** The attempt's marking. Drives the score banner and every per-node mark. */
148
+ result: SubmitResult;
149
+ }
116
150
  interface SubmitResult {
117
151
  submissionId: string;
118
152
  totalScore: number;
@@ -204,6 +238,12 @@ interface EmbedResult {
204
238
  rightId: string;
205
239
  }>;
206
240
  };
241
+ /**
242
+ * The teacher's written feedback on an open response. Only ever present
243
+ * in a review (`GET /submissions/{id}/review`), since at submit time no
244
+ * teacher has graded anything yet.
245
+ */
246
+ teacher_feedback?: RichContent[];
207
247
  }>;
208
248
  }>;
209
249
  }>;
@@ -241,6 +281,16 @@ interface EdpireAssessmentPlayerProps {
241
281
  locale?: ShellLocale;
242
282
  /** Branding overrides. Org branding loads from Edpire automatically; pass this to override (white-labelling). */
243
283
  branding?: TakeBranding;
284
+ /**
285
+ * Geometry of the question column.
286
+ *
287
+ * `className` sizes the player's outer box; this sizes the question column
288
+ * inside it. They are different boxes: by default the questions sit in a
289
+ * centred 768px reading column whatever the outer box is. Keep that for a
290
+ * full-page player, pass `{ maxWidth: "none" }` when the player is embedded
291
+ * in a layout that already constrains width.
292
+ */
293
+ layout?: ShellLayout;
244
294
  /**
245
295
  * When set, the post-submit "View Full Report" button redirects here with
246
296
  * `?submission_id=...&score=...&max_score=...` appended. Omit to hide the button.
@@ -343,11 +393,17 @@ interface AssessmentShellProps {
343
393
  startedAt?: string;
344
394
  /** Called when the learner submits. Should throw on error. */
345
395
  onSubmit: (answers: AssessmentAnswers) => Promise<SubmitResult>;
396
+ /**
397
+ * Opens the shell on a finished attempt instead of a blank paper: already
398
+ * submitted, the learner's answers filled in and locked, marking shown. There
399
+ * is no way to submit from here, so `onSubmit` is never called.
400
+ */
401
+ review?: ShellReview;
346
402
  /** Called when the learner clicks "View Full Report". Omit to hide the button. */
347
403
  onViewReport?: (result: SubmitResult) => void;
348
404
  /** Custom label for the post-submit redirect button (overrides default). */
349
405
  reportLabel?: string;
350
- /** Called when the learner clicks the back button (shown only BEFORE submission). */
406
+ /** Called when the learner clicks the back button (shown before submission, and throughout a review). */
351
407
  onBack?: () => void;
352
408
  /** Custom label for the back button (default: localized "Back"). */
353
409
  backLabel?: string;
@@ -360,6 +416,12 @@ interface AssessmentShellProps {
360
416
  overlayConfig?: OverlayConfig;
361
417
  /** Scope grading/time-up overlays to this component instead of the viewport. */
362
418
  contained?: boolean;
419
+ /**
420
+ * Geometry of the question column. Omit for the default reading measure,
421
+ * which is what a full-page player wants. Pass `{ maxWidth: "none" }` when
422
+ * the shell is embedded inside a host layout that already constrains width.
423
+ */
424
+ layout?: ShellLayout;
363
425
  /** Media upload handler — required for file-upload and recording modes in
364
426
  * OpenResponse questions. */
365
427
  mediaHandler?: QuestionRuntimeProps["mediaHandler"];
@@ -379,6 +441,6 @@ interface AssessmentShellProps {
379
441
  */
380
442
  fallbackLogoUrl?: string;
381
443
  }
382
- declare function AssessmentShell({ assessment, meta, locale, branding, timeLimitMinutes, startedAt, onSubmit, onViewReport, reportLabel, onBack, backLabel, allowReset, onReset, overlayConfig, contained, onClose, mediaHandler, onAddAnnex, fallbackLogoUrl, }: AssessmentShellProps): react_jsx_runtime.JSX.Element;
444
+ declare function AssessmentShell({ assessment, meta, locale, branding, timeLimitMinutes, startedAt, onSubmit, review, onViewReport, reportLabel, onBack, backLabel, allowReset, onReset, overlayConfig, contained, layout, onClose, mediaHandler, onAddAnnex, fallbackLogoUrl, }: AssessmentShellProps): react_jsx_runtime.JSX.Element;
383
445
 
384
- export { AssessmentShell, type AssessmentShellProps, EdpireAssessmentPlayer, type EdpireAssessmentPlayerProps, EdpireQuestion, type EdpireQuestionProps, type ExerciseFeedbackData, type NodeDetail, type NodeFeedback, type OverlayConfig, type QuestionFeedback, type ShellLocale, type SpinnerTheme, type SubmitResult, type TakeBranding };
446
+ export { AssessmentShell, type AssessmentShellProps, EdpireAssessmentPlayer, type EdpireAssessmentPlayerProps, EdpireQuestion, type EdpireQuestionProps, type ExerciseFeedbackData, type NodeDetail, type NodeFeedback, type OverlayConfig, type QuestionFeedback, type ShellLayout, type ShellLocale, type ShellReview, type SpinnerTheme, type SubmitResult, type TakeBranding };