@edpire/sdk 0.9.2 → 0.9.4

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,33 @@ the package follows [semantic versioning](https://semver.org/spec/v2.0.0.html).
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [0.9.4] - 2026-11-09
15
+
16
+ ### Added
17
+
18
+ - **A question's explanation.** A teacher can write one explanation per question; the player and
19
+ the review draw it under the question once the learner has submitted. It arrives as an optional
20
+ `explanation` on `exercise_feedback[].questions[]` (`SubmitResult.exerciseFeedback[].questions[]`
21
+ in the shell, `explanation` on each `flattenReview()` step). Absent when there is none, or when
22
+ the teacher chose not to show the answers.
23
+
24
+ ### Upgrade notes
25
+
26
+ - Nothing to change. Older versions ignore the new field and keep working.
27
+
28
+ ## [0.9.3] - 2026-11-02
29
+
30
+ ### Fixed
31
+
32
+ - **A finger on a word can scroll the page.** On phones, a word in a word bank was picked up after
33
+ 120 ms, so a student who paused before swiping dragged it. Picking a word up now takes a 250 ms
34
+ press. A tap still fills the first empty blank.
35
+ - **Dragging moves the page more slowly,** and only near the top and bottom edges, so the blanks can
36
+ be seen going by. This also applies to the mouse.
37
+ - **A long press on a word no longer opens iOS's callout menu.**
38
+
39
+ Runtime 3.17.2. Upgrade notes: nothing to change.
40
+
14
41
  ## [0.9.2] - 2026-11-02
15
42
 
16
43
  ### 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.2/dist/umd/index.global.js"></script>
95
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.9.4/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.2/dist/umd/index.global.js"></script>
333
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.9.4/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
  /**