@edpire/sdk 0.14.0 → 0.16.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,61 @@ the package follows [semantic versioning](https://semver.org/spec/v2.0.0.html).
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [0.16.0] - 2026-12-04
15
+
16
+ Bundles runtime 3.24.0 (photos and handwriting, edpire.com T189 round 3).
17
+
18
+ ### Added
19
+
20
+ - Photos of a paper copy, read line by line: on a phone Photo opens the camera, each page is
21
+ stored as soon as it is taken, and the text and formulas appear in the answer while the page is
22
+ read. Words the reader was unsure of are underlined until the learner changes them. A sideways
23
+ photo is turned and read again. On a computer a QR code lets the learner take the photos with
24
+ their phone; it opens Edpire's own phone page (edpire.com), never your page, and the photos come
25
+ back to the embed. Upload and the computer's camera stay one click away.
26
+ - A page written by hand on tablets (or once a pen is used): lined paper, up to 4 pages, read the
27
+ same way. The formula pad reads the formula once it pauses and stops a read when the learner
28
+ writes on.
29
+ - A finished answer shows its pages beside the text in review.
30
+ - `AnswerSheetReader` gains optional `signPhoto`, `streamPhotos`, `startCapture` and
31
+ `captureStatus`; `readPhotos` takes `purpose` and returns `lines`; `readHandwriting` takes a
32
+ `signal`. Types `PageTurn` and `ReadingErrorCode`. `embedAnswerSheetHandler` uses all of them.
33
+ - `AssessmentShell` gains `wholeCopy` (off by default): "Photograph my copy" beside Submit, every
34
+ page read once and each part placed in its question. Edpire turns it on per workspace while it is
35
+ tried; embeds do not show it yet.
36
+
37
+ ### Upgrade notes
38
+
39
+ - Nothing to change in your code. A page with a Content-Security-Policy must allow
40
+ `https://storage.edpire.com` in `connect-src` and `img-src` (photos go straight to Edpire's
41
+ storage), plus `blob:` and `data:` in `img-src`; the computer's camera needs HTTPS and a page
42
+ that does not block `camera` in its `Permissions-Policy`.
43
+ - Older SDKs keep working: 0.13.0 to 0.15.0 show the earlier photo screen, whose photos are now
44
+ stored by the server first and read the same way.
45
+
46
+ ## [0.15.0] - 2026-12-02
47
+
48
+ Bundles runtime 3.23.0 (maths answers round 2, edpire.com T189).
49
+
50
+ ### Added
51
+
52
+ - One maths keyboard for every maths field. On a phone it sits on top of the phone's keyboard (∑,
53
+ x², fractions, roots, brackets, fx to turn text into a formula) and the two never stack; ∑ opens
54
+ the full panel, abc goes back. On a computer the key row under the box stays and "More" opens
55
+ the panel at the bottom of the window.
56
+ - A maths result can sit inside its sentence ("S = ▢."), as on a paper: the field grows with the
57
+ answer and shows ✓ or ✗ and its points in place.
58
+ - A detailed answer graded by AI shows each line of the teacher's marking scheme with its points
59
+ and one sentence, then the next step (`NodeDetail` type `aiAnswer`, `AiFeedbackLine`).
60
+ - In the answer box, a tap after a formula that ends a line puts the caret after it, and function
61
+ notation (`det(A)`, `ln(x)`, `u_n`, `f'(x)`) becomes maths.
62
+
63
+ ### Upgrade notes
64
+
65
+ - Nothing to change in your code. The maths keyboard is fixed at the bottom of the window, above
66
+ the page (z-index 9000): a page with its own fixed layer that must stay on top sets the CSS
67
+ variable `--edp-kb-z`.
68
+
14
69
  ## [0.14.0] - 2026-12-01
15
70
 
16
71
  Bundles runtime 3.22.1 (maths for real papers, edpire.com T189).
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.14.0/dist/umd/index.global.js"></script>
95
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.16.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.14.0/dist/umd/index.global.js"></script>
333
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.16.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/core.mjs CHANGED
@@ -1 +1 @@
1
- function k(t){let n=[],r=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:r++});return n}function x(t){let n=new Map;for(let r of t){let e=new Map;for(let i of r.questions){let a=new Map;for(let s of i.nodeResults){let o={state:s.status,showFeedback:!0,score:s.score,...s.feedback!==void 0?{message:s.feedback}:{},...s.displayAnswer!==void 0?{displayAnswer:s.displayAnswer}:{},...s.teacherFeedback!==void 0?{teacherFeedback:s.teacherFeedback}:{}};s.detail?.type==="choiceSet"?o.correctChoiceIds=s.detail.correctChoiceIds:s.detail?.type==="matchingSet"&&(o.pairFeedback=s.detail.pairFeedback,o.correctPairings=s.detail.correctPairings),a.set(s.nodeId,o)}e.set(i.questionId,a)}n.set(r.exerciseId,e)}return n}function b(t){return(t??[]).map(n=>({exerciseId:n.exercise_id,questions:n.questions.map(r=>({questionId:r.question_id,...r.explanation?{explanation:r.explanation}:{},nodeResults:r.node_results.map(e=>({nodeId:e.node_id,status:e.status,...e.score!==void 0?{score:e.score}:{},...e.max_score!==void 0?{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 y(t){let n=x(b(t.exercise_feedback)),r=new Map;for(let s of t.answers.exerciseAnswers)for(let o of s.questionAnswers)r.set(o.questionId,o.answers);let e=t.submission.score_hidden===!0,i=[],a=0;for(let s of t.assessment.exercises){let o=n.get(s.id);for(let d of s.questions){let l=o?.get(d.id),f=t.exercise_feedback.find(c=>c.exercise_id===s.id)?.questions.find(c=>c.question_id===d.id),m=f?.node_results??[],u=0,p=0,w=!1;for(let c of m)u+=c.score??0,p+=c.max_score??0,c.status==="awaiting_review"&&(w=!0);i.push({exerciseId:s.id,questionId:d.id,content:d.content,sharedContext:s.sharedContext??null,explanation:f?.explanation??null,answers:r.get(d.id)??[],feedback:l?Object.fromEntries(l):{},score:u,maxScore:p,scoreHidden:e,status:w?"awaiting_review":e?A(m.map(c=>c.status)):p===0?"unscored":u>=p?"correct":u>0?"partial":"incorrect",index:a++})}}return i}function A(t){return t.length===0?"unscored":t.every(n=>n==="correct")?"correct":t.every(n=>n==="incorrect")?"incorrect":"partial"}function I(t){let n=new Map;for(let r of t)n.has(r.exerciseId)||n.set(r.exerciseId,[]),n.get(r.exerciseId).push({questionId:r.questionId,answers:r.answers});return{exerciseAnswers:Array.from(n.entries()).map(([r,e])=>({exerciseId:r,questionAnswers:e}))}}var S=new Set(["choiceSet","inlineChoiceSet","blank","aiAnswerInput","matchingSet","openResponseNode","mathResponse","codingResponse"]),q=new Set(["blankPool","inlinePool"]);function g(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 h(t){let n=0,r=e=>{if(Array.isArray(e)){for(let s of e)r(s);return}if(!e||typeof e!="object")return;let{type:i,content:a}=e;if(typeof i=="string"){if(S.has(i)){n+=1;return}if(q.has(i))return}a!==void 0&&r(a)};return r(t),n}function R(t,n){let r=new Map;for(let i of n?.exerciseAnswers??[])for(let a of i.questionAnswers){let s=r.get(a.questionId);s||(s=new Set,r.set(a.questionId,s));for(let o of a.answers)g(o)&&s.add(o.nodeId)}let e=[];return t.exercises.forEach((i,a)=>{i.questions.forEach((s,o)=>{let d=h(s.content);d!==0&&(r.get(s.id)?.size??0)<d&&e.push({questionId:s.id,exerciseIndex:a,...i.title?{exerciseTitle:i.title}:{},questionIndex:o,only:i.questions.length===1})})}),e}function F(t,n,r){let e=new Set(r);return e.size===0?[]:R(t,n).filter(i=>e.has(i.questionId))}export{I as buildSubmitPayload,h as countAnswerableNodes,k as flattenAssessment,y as flattenReview,g as isAnswered,F as missingRequired};
1
+ function y(n){let s=[],r=0;for(let e of n.exercises)for(let i of e.questions)s.push({exerciseId:e.id,questionId:i.id,content:i.content_ast,points:i.points,sequenceNumber:i.sequence_number,index:r++});return s}function w(n){let s=new Map;for(let r of n){let e=new Map;for(let i of r.questions){let a=new Map;for(let t of i.nodeResults){let o={state:t.status,showFeedback:!0,score:t.score,...t.feedback!==void 0?{message:t.feedback}:{},...t.displayAnswer!==void 0?{displayAnswer:t.displayAnswer}:{},...t.teacherFeedback!==void 0?{teacherFeedback:t.teacherFeedback}:{}};t.detail?.type==="choiceSet"?o.correctChoiceIds=t.detail.correctChoiceIds:t.detail?.type==="matchingSet"?(o.pairFeedback=t.detail.pairFeedback,o.correctPairings=t.detail.correctPairings):t.detail?.type==="aiAnswer"&&(o.lines=t.detail.lines,t.detail.next&&(o.next=t.detail.next)),a.set(t.nodeId,o)}e.set(i.questionId,a)}s.set(r.exerciseId,e)}return s}function b(n){return(n??[]).map(s=>({exerciseId:s.exercise_id,questions:s.questions.map(r=>({questionId:r.question_id,...r.explanation?{explanation:r.explanation}:{},nodeResults:r.node_results.map(e=>({nodeId:e.node_id,status:e.status,...e.score!==void 0?{score:e.score}:{},...e.max_score!==void 0?{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 A(n){let s=w(b(n.exercise_feedback)),r=new Map;for(let t of n.answers.exerciseAnswers)for(let o of t.questionAnswers)r.set(o.questionId,o.answers);let e=n.submission.score_hidden===!0,i=[],a=0;for(let t of n.assessment.exercises){let o=s.get(t.id);for(let d of t.questions){let p=o?.get(d.id),f=n.exercise_feedback.find(c=>c.exercise_id===t.id)?.questions.find(c=>c.question_id===d.id),m=f?.node_results??[],u=0,l=0,x=!1;for(let c of m)u+=c.score??0,l+=c.max_score??0,c.status==="awaiting_review"&&(x=!0);i.push({exerciseId:t.id,questionId:d.id,content:d.content,sharedContext:t.sharedContext??null,explanation:f?.explanation??null,answers:r.get(d.id)??[],feedback:p?Object.fromEntries(p):{},score:u,maxScore:l,scoreHidden:e,status:x?"awaiting_review":e?k(m.map(c=>c.status)):l===0?"unscored":u>=l?"correct":u>0?"partial":"incorrect",index:a++})}}return i}function k(n){return n.length===0?"unscored":n.every(s=>s==="correct")?"correct":n.every(s=>s==="incorrect")?"incorrect":"partial"}function I(n){let s=new Map;for(let r of n)s.has(r.exerciseId)||s.set(r.exerciseId,[]),s.get(r.exerciseId).push({questionId:r.questionId,answers:r.answers});return{exerciseAnswers:Array.from(s.entries()).map(([r,e])=>({exerciseId:r,questionAnswers:e}))}}var S=new Set(["choiceSet","inlineChoiceSet","blank","aiAnswerInput","matchingSet","openResponseNode","mathResponse","codingResponse"]),q=new Set(["blankPool","inlinePool"]);function g(n){switch(n.type){case"choiceSet":case"inlineChoiceSet":return n.answer.selectedIds.length>0;case"blank":return n.answer.mode==="choice"?n.answer.choiceId.length>0:n.answer.text.trim().length>0;case"matchingSet":return n.answer.connections.length>0;case"aiAnswer":return n.answer.text.trim().length>0;case"openResponse":{let s=n.answer;return s.recording||s.files&&s.files.length>0?!0:(s.text?.wordCount??0)>0}case"mathResponse":return n.answer.latex.trim().length>0;case"codingResponse":return n.answer.source.trim().length>0;default:{let s=n;return!0}}}function h(n){let s=0,r=e=>{if(Array.isArray(e)){for(let t of e)r(t);return}if(!e||typeof e!="object")return;let{type:i,content:a}=e;if(typeof i=="string"){if(S.has(i)){s+=1;return}if(q.has(i))return}a!==void 0&&r(a)};return r(n),s}function R(n,s){let r=new Map;for(let i of s?.exerciseAnswers??[])for(let a of i.questionAnswers){let t=r.get(a.questionId);t||(t=new Set,r.set(a.questionId,t));for(let o of a.answers)g(o)&&t.add(o.nodeId)}let e=[];return n.exercises.forEach((i,a)=>{i.questions.forEach((t,o)=>{let d=h(t.content);d!==0&&(r.get(t.id)?.size??0)<d&&e.push({questionId:t.id,exerciseIndex:a,...i.title?{exerciseTitle:i.title}:{},questionIndex:o,only:i.questions.length===1})})}),e}function F(n,s,r){let e=new Set(r);return e.size===0?[]:R(n,s).filter(i=>e.has(i.questionId))}export{I as buildSubmitPayload,h as countAnswerableNodes,y as flattenAssessment,A as flattenReview,g as isAnswered,F as missingRequired};
package/dist/index.d.mts CHANGED
@@ -66,7 +66,20 @@ type NodeDetail = {
66
66
  leftId: string;
67
67
  rightId: string;
68
68
  }>;
69
+ }
70
+ /** An AI-graded answer's barème lines, each with its sentence, then the next step (T189 D23). */
71
+ | {
72
+ type: "aiAnswer";
73
+ lines: AiFeedbackLine[];
74
+ next?: string;
69
75
  };
76
+ /** One barème line of an AI-graded answer; no points when the score is hidden from learners. */
77
+ interface AiFeedbackLine {
78
+ label: string;
79
+ score?: number;
80
+ maxScore?: number;
81
+ feedback?: string;
82
+ }
70
83
  interface NodeFeedback {
71
84
  nodeId: string;
72
85
  status: "correct" | "partial" | "incorrect" | "awaiting_review";