@edpire/sdk 0.9.3 → 0.10.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/CHANGELOG.md CHANGED
@@ -11,6 +11,43 @@ the package follows [semantic versioning](https://semver.org/spec/v2.0.0.html).
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [0.10.0] - 2026-11-09
15
+
16
+ ### Changed
17
+
18
+ - **Tables fit their content.** Columns size to what is in them instead of sharing the width
19
+ equally, at 14 px with tighter rows, and a word or a number like `3 500` is never split. A
20
+ teacher's dragged column widths are kept. On a long accounting paper the tables took less than
21
+ half the height. Content and grading are unchanged; only the layout.
22
+ - **Wide tables swipe inside themselves** on a narrow screen, with the first column held (on the
23
+ right in Arabic).
24
+ - **A typed answer in a table cell fills the cell** and no longer grows while the learner types, so
25
+ the columns stay put.
26
+
27
+ ### Added
28
+
29
+ - Grey cells: a cell the teacher greyed out (`attrs.gray` on a table cell in `content_ast`) shows
30
+ grey. Older versions ignore the attribute.
31
+
32
+ ### Upgrade notes
33
+
34
+ - Nothing to change. It is a minor version because every table looks different after the
35
+ upgrade: check a page with tables before you move a pinned script URL. Bundles runtime 3.18.0.
36
+
37
+ ## [0.9.4] - 2026-11-09
38
+
39
+ ### Added
40
+
41
+ - **A question's explanation.** A teacher can write one explanation per question; the player and
42
+ the review draw it under the question once the learner has submitted. It arrives as an optional
43
+ `explanation` on `exercise_feedback[].questions[]` (`SubmitResult.exerciseFeedback[].questions[]`
44
+ in the shell, `explanation` on each `flattenReview()` step). Absent when there is none, or when
45
+ the teacher chose not to show the answers.
46
+
47
+ ### Upgrade notes
48
+
49
+ - Nothing to change. Older versions ignore the new field and keep working.
50
+
14
51
  ## [0.9.3] - 2026-11-02
15
52
 
16
53
  ### Fixed
package/README.md CHANGED
@@ -92,7 +92,7 @@ embed.unmount()
92
92
  **CDN (no bundler):**
93
93
 
94
94
  ```html
95
- <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.9.3/dist/umd/index.global.js"></script>
95
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.10.0/dist/umd/index.global.js"></script>
96
96
  <script>
97
97
  EdpireSDK.EdpireAssessment.mount({ token, container: "#root", onComplete: handleDone })
98
98
  </script>
@@ -330,7 +330,7 @@ The integration uses two parts:
330
330
  </head>
331
331
  <body>
332
332
  <div id="root"></div>
333
- <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.9.3/dist/umd/index.global.js"></script>
333
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.10.0/dist/umd/index.global.js"></script>
334
334
  <script>
335
335
  EdpireSDK.EdpireAssessment.mount({
336
336
  token: "{{EMBED_TOKEN}}", // replace server-side before loading
package/dist/client.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RuntimeAnswer } from '@youssefalmia/edpire-runtime';
2
- import { RichContent } from '@youssefalmia/edpire-schema/authoring';
2
+ import { ContentAST, RichContent } from '@youssefalmia/edpire-schema/authoring';
3
3
 
4
4
  /** Flat per-question answer collected during a custom player session. */
5
5
  interface StoredAnswer {
@@ -72,6 +72,11 @@ interface EmbedResult {
72
72
  exercise_id: string;
73
73
  questions: Array<{
74
74
  question_id: string;
75
+ /**
76
+ * The teacher's explanation of the question, as content. Absent when
77
+ * there is none, or when the teacher chose not to show the answers.
78
+ */
79
+ explanation?: ContentAST;
75
80
  node_results: Array<{
76
81
  node_id: string;
77
82
  status: NodeFeedbackStatus;
package/dist/core.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RuntimeAnswer } from '@youssefalmia/edpire-runtime';
2
- import { RichContent } from '@youssefalmia/edpire-schema/authoring';
2
+ import { ContentAST, RichContent } from '@youssefalmia/edpire-schema/authoring';
3
3
 
4
4
  /** Flat per-question answer collected during a custom player session. */
5
5
  interface StoredAnswer {
@@ -106,6 +106,11 @@ interface EmbedResult {
106
106
  exercise_id: string;
107
107
  questions: Array<{
108
108
  question_id: string;
109
+ /**
110
+ * The teacher's explanation of the question, as content. Absent when
111
+ * there is none, or when the teacher chose not to show the answers.
112
+ */
113
+ explanation?: ContentAST;
109
114
  node_results: Array<{
110
115
  node_id: string;
111
116
  status: NodeFeedbackStatus;
@@ -373,6 +378,8 @@ interface ReviewStep {
373
378
  * Render it with renderQuestion too; it is plain content.
374
379
  */
375
380
  sharedContext: unknown | null;
381
+ /** The teacher's explanation of the question (content, like `content`), or null. */
382
+ explanation: unknown | null;
376
383
  /** What the learner answered. Pass to renderQuestion's `initialAnswers`. */
377
384
  answers: RuntimeAnswer[];
378
385
  /**
package/dist/core.mjs CHANGED
@@ -1 +1 @@
1
- function x(t){let n=[],s=0;for(let e of t.exercises)for(let i of e.questions)n.push({exerciseId:e.id,questionId:i.id,content:i.content_ast,points:i.points,sequenceNumber:i.sequence_number,index:s++});return n}function l(t){let n=new Map;for(let s of t){let e=new Map;for(let i of s.questions){let o=new Map;for(let r of i.nodeResults){let a={state:r.status,showFeedback:!0,score:r.score,...r.feedback!==void 0?{message:r.feedback}:{},...r.displayAnswer!==void 0?{displayAnswer:r.displayAnswer}:{},...r.teacherFeedback!==void 0?{teacherFeedback:r.teacherFeedback}:{}};r.detail?.type==="choiceSet"?a.correctChoiceIds=r.detail.correctChoiceIds:r.detail?.type==="matchingSet"&&(a.pairFeedback=r.detail.pairFeedback,a.correctPairings=r.detail.correctPairings),o.set(r.nodeId,a)}e.set(i.questionId,o)}n.set(s.exerciseId,e)}return n}function m(t){return(t??[]).map(n=>({exerciseId:n.exercise_id,questions:n.questions.map(s=>({questionId:s.question_id,nodeResults:s.node_results.map(e=>({nodeId:e.node_id,status:e.status,score:e.score,maxScore:e.max_score,...e.feedback!==void 0?{feedback:e.feedback}:{},...e.display_answer!==void 0?{displayAnswer:e.display_answer}:{},...e.detail!==void 0?{detail:e.detail}:{},...e.teacher_feedback!==void 0?{teacherFeedback:e.teacher_feedback}:{}}))}))}))}function b(t){let n=l(m(t.exercise_feedback)),s=new Map;for(let o of t.answers.exerciseAnswers)for(let r of o.questionAnswers)s.set(r.questionId,r.answers);let e=[],i=0;for(let o of t.assessment.exercises){let r=n.get(o.id);for(let a of o.questions){let p=r?.get(a.id),w=t.exercise_feedback.find(c=>c.exercise_id===o.id)?.questions.find(c=>c.question_id===a.id)?.node_results??[],d=0,u=0,f=!1;for(let c of w)d+=c.score,u+=c.max_score,c.status==="awaiting_review"&&(f=!0);e.push({exerciseId:o.id,questionId:a.id,content:a.content,sharedContext:o.sharedContext??null,answers:s.get(a.id)??[],feedback:p?Object.fromEntries(p):{},score:d,maxScore:u,status:f?"awaiting_review":u===0?"unscored":d>=u?"correct":d>0?"partial":"incorrect",index:i++})}}return e}function g(t){let n=new Map;for(let s of t)n.has(s.exerciseId)||n.set(s.exerciseId,[]),n.get(s.exerciseId).push({questionId:s.questionId,answers:s.answers});return{exerciseAnswers:Array.from(n.entries()).map(([s,e])=>({exerciseId:s,questionAnswers:e}))}}var h=new Set(["choiceSet","inlineChoiceSet","blank","aiAnswerInput","matchingSet","openResponseNode","mathResponse","codingResponse"]),k=new Set(["blankPool","inlinePool"]);function y(t){switch(t.type){case"choiceSet":case"inlineChoiceSet":return t.answer.selectedIds.length>0;case"blank":return t.answer.mode==="choice"?t.answer.choiceId.length>0:t.answer.text.trim().length>0;case"matchingSet":return t.answer.connections.length>0;case"aiAnswer":return t.answer.text.trim().length>0;case"openResponse":{let n=t.answer;return n.recording||n.files&&n.files.length>0?!0:(n.text?.wordCount??0)>0}case"mathResponse":return t.answer.latex.trim().length>0;case"codingResponse":return t.answer.source.trim().length>0;default:{let n=t;return!0}}}function A(t){let n=0,s=e=>{if(Array.isArray(e)){for(let r of e)s(r);return}if(!e||typeof e!="object")return;let{type:i,content:o}=e;if(typeof i=="string"){if(h.has(i)){n+=1;return}if(k.has(i))return}o!==void 0&&s(o)};return s(t),n}export{g as buildSubmitPayload,A as countAnswerableNodes,x as flattenAssessment,b as flattenReview,y as isAnswered};
1
+ function b(t){let n=[],s=0;for(let e of t.exercises)for(let i of e.questions)n.push({exerciseId:e.id,questionId:i.id,content:i.content_ast,points:i.points,sequenceNumber:i.sequence_number,index:s++});return n}function m(t){let n=new Map;for(let s of t){let e=new Map;for(let i of s.questions){let o=new Map;for(let r of i.nodeResults){let a={state:r.status,showFeedback:!0,score:r.score,...r.feedback!==void 0?{message:r.feedback}:{},...r.displayAnswer!==void 0?{displayAnswer:r.displayAnswer}:{},...r.teacherFeedback!==void 0?{teacherFeedback:r.teacherFeedback}:{}};r.detail?.type==="choiceSet"?a.correctChoiceIds=r.detail.correctChoiceIds:r.detail?.type==="matchingSet"&&(a.pairFeedback=r.detail.pairFeedback,a.correctPairings=r.detail.correctPairings),o.set(r.nodeId,a)}e.set(i.questionId,o)}n.set(s.exerciseId,e)}return n}function w(t){return(t??[]).map(n=>({exerciseId:n.exercise_id,questions:n.questions.map(s=>({questionId:s.question_id,...s.explanation?{explanation:s.explanation}:{},nodeResults:s.node_results.map(e=>({nodeId:e.node_id,status:e.status,score:e.score,maxScore:e.max_score,...e.feedback!==void 0?{feedback:e.feedback}:{},...e.display_answer!==void 0?{displayAnswer:e.display_answer}:{},...e.detail!==void 0?{detail:e.detail}:{},...e.teacher_feedback!==void 0?{teacherFeedback:e.teacher_feedback}:{}}))}))}))}function g(t){let n=m(w(t.exercise_feedback)),s=new Map;for(let o of t.answers.exerciseAnswers)for(let r of o.questionAnswers)s.set(r.questionId,r.answers);let e=[],i=0;for(let o of t.assessment.exercises){let r=n.get(o.id);for(let a of o.questions){let p=r?.get(a.id),l=t.exercise_feedback.find(c=>c.exercise_id===o.id)?.questions.find(c=>c.question_id===a.id),x=l?.node_results??[],d=0,u=0,f=!1;for(let c of x)d+=c.score,u+=c.max_score,c.status==="awaiting_review"&&(f=!0);e.push({exerciseId:o.id,questionId:a.id,content:a.content,sharedContext:o.sharedContext??null,explanation:l?.explanation??null,answers:s.get(a.id)??[],feedback:p?Object.fromEntries(p):{},score:d,maxScore:u,status:f?"awaiting_review":u===0?"unscored":d>=u?"correct":d>0?"partial":"incorrect",index:i++})}}return e}function h(t){let n=new Map;for(let s of t)n.has(s.exerciseId)||n.set(s.exerciseId,[]),n.get(s.exerciseId).push({questionId:s.questionId,answers:s.answers});return{exerciseAnswers:Array.from(n.entries()).map(([s,e])=>({exerciseId:s,questionAnswers:e}))}}var k=new Set(["choiceSet","inlineChoiceSet","blank","aiAnswerInput","matchingSet","openResponseNode","mathResponse","codingResponse"]),y=new Set(["blankPool","inlinePool"]);function A(t){switch(t.type){case"choiceSet":case"inlineChoiceSet":return t.answer.selectedIds.length>0;case"blank":return t.answer.mode==="choice"?t.answer.choiceId.length>0:t.answer.text.trim().length>0;case"matchingSet":return t.answer.connections.length>0;case"aiAnswer":return t.answer.text.trim().length>0;case"openResponse":{let n=t.answer;return n.recording||n.files&&n.files.length>0?!0:(n.text?.wordCount??0)>0}case"mathResponse":return t.answer.latex.trim().length>0;case"codingResponse":return t.answer.source.trim().length>0;default:{let n=t;return!0}}}function I(t){let n=0,s=e=>{if(Array.isArray(e)){for(let r of e)s(r);return}if(!e||typeof e!="object")return;let{type:i,content:o}=e;if(typeof i=="string"){if(k.has(i)){n+=1;return}if(y.has(i))return}o!==void 0&&s(o)};return s(t),n}export{h as buildSubmitPayload,I as countAnswerableNodes,b as flattenAssessment,g as flattenReview,A as isAnswered};
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { QuestionRuntimeProps, RuntimeAnswer } from '@youssefalmia/edpire-runtime';
2
2
  export { BlankChoiceAnswer, ChoiceSetAnswer, MatchingConnection, MatchingSetAnswer, OpenResponseAnswer, RuntimeAnswer, TypedBlankAnswer } from '@youssefalmia/edpire-runtime';
3
- import { RichContent } from '@youssefalmia/edpire-schema/authoring';
3
+ import { RichContent, ContentAST } from '@youssefalmia/edpire-schema/authoring';
4
4
 
5
5
  /**
6
6
  * Public types for the polished Assessment Shell.
@@ -80,6 +80,8 @@ interface NodeFeedback {
80
80
  interface QuestionFeedback {
81
81
  questionId: string;
82
82
  nodeResults: NodeFeedback[];
83
+ /** The teacher's explanation of the question, drawn under it once submitted. */
84
+ explanation?: ContentAST;
83
85
  }
84
86
  interface ExerciseFeedbackData {
85
87
  exerciseId: string;
@@ -167,6 +169,11 @@ interface EmbedResult {
167
169
  exercise_id: string;
168
170
  questions: Array<{
169
171
  question_id: string;
172
+ /**
173
+ * The teacher's explanation of the question, as content. Absent when
174
+ * there is none, or when the teacher chose not to show the answers.
175
+ */
176
+ explanation?: ContentAST;
170
177
  node_results: Array<{
171
178
  node_id: string;
172
179
  status: NodeFeedbackStatus;
@@ -619,6 +626,8 @@ interface ReviewStep {
619
626
  * Render it with renderQuestion too; it is plain content.
620
627
  */
621
628
  sharedContext: unknown | null;
629
+ /** The teacher's explanation of the question (content, like `content`), or null. */
630
+ explanation: unknown | null;
622
631
  /** What the learner answered. Pass to renderQuestion's `initialAnswers`. */
623
632
  answers: RuntimeAnswer[];
624
633
  /**