@edpire/sdk 0.12.1 → 0.12.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/CHANGELOG.md CHANGED
@@ -11,6 +11,25 @@ the package follows [semantic versioning](https://semver.org/spec/v2.0.0.html).
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [0.12.2] - 2026-11-25
15
+
16
+ ### Fixed
17
+
18
+ - **`flattenReview()` on an assessment whose score is hidden.** The review carries no points then,
19
+ so every step came back `unscored` ("not marked") instead of right, partly right or wrong. The
20
+ status now comes from each answer's marking when the score is hidden.
21
+
22
+ ### Added
23
+
24
+ - `ReviewStep.scoreHidden`: true when the teacher keeps the score from students. `score` and
25
+ `maxScore` are then 0: show no points.
26
+
27
+ ### Upgrade notes
28
+
29
+ - Nothing to change unless you draw a review one question at a time with `flattenReview()`: then
30
+ hide the points when `scoreHidden` is true. The player and `EdpireAssessment.review()` are
31
+ unchanged.
32
+
14
33
  ## [0.12.1] - 2026-11-24
15
34
 
16
35
  ### Added
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.12.1/dist/umd/index.global.js"></script>
95
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.12.2/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.12.1/dist/umd/index.global.js"></script>
333
+ <script src="https://cdn.jsdelivr.net/npm/@edpire/sdk@0.12.2/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.d.mts CHANGED
@@ -414,8 +414,15 @@ interface ReviewStep {
414
414
  * missed and the teacher's comment on an open response.
415
415
  */
416
416
  feedback: Record<string, unknown>;
417
+ /** 0 when `scoreHidden`: the review carries no points then. */
417
418
  score: number;
418
419
  maxScore: number;
420
+ /**
421
+ * True when the teacher chose not to show the score to students (SDK 0.12.2).
422
+ * `score` and `maxScore` are then 0 and mean nothing: show no points. `status`
423
+ * still says right, partly right or wrong.
424
+ */
425
+ scoreHidden: boolean;
419
426
  /**
420
427
  * The question as a whole. `awaiting_review` while a teacher has yet to mark
421
428
  * any part of it; its score is then provisional. `unscored` when it is worth
package/dist/core.mjs CHANGED
@@ -1 +1 @@
1
- function h(t){let i=[],n=0;for(let e of t.exercises)for(let r of e.questions)i.push({exerciseId:e.id,questionId:r.id,content:r.content_ast,points:r.points,sequenceNumber:r.sequence_number,index:n++});return i}function m(t){let i=new Map;for(let n of t){let e=new Map;for(let r of n.questions){let o=new Map;for(let s of r.nodeResults){let a={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"?a.correctChoiceIds=s.detail.correctChoiceIds:s.detail?.type==="matchingSet"&&(a.pairFeedback=s.detail.pairFeedback,a.correctPairings=s.detail.correctPairings),o.set(s.nodeId,a)}e.set(r.questionId,o)}i.set(n.exerciseId,e)}return i}function w(t){return(t??[]).map(i=>({exerciseId:i.exercise_id,questions:i.questions.map(n=>({questionId:n.question_id,...n.explanation?{explanation:n.explanation}:{},nodeResults:n.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 k(t){let i=m(w(t.exercise_feedback)),n=new Map;for(let o of t.answers.exerciseAnswers)for(let s of o.questionAnswers)n.set(s.questionId,s.answers);let e=[],r=0;for(let o of t.assessment.exercises){let s=i.get(o.id);for(let a of o.questions){let d=s?.get(a.id),l=t.exercise_feedback.find(c=>c.exercise_id===o.id)?.questions.find(c=>c.question_id===a.id),g=l?.node_results??[],u=0,p=0,f=!1;for(let c of g)u+=c.score??0,p+=c.max_score??0,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:n.get(a.id)??[],feedback:d?Object.fromEntries(d):{},score:u,maxScore:p,status:f?"awaiting_review":p===0?"unscored":u>=p?"correct":u>0?"partial":"incorrect",index:r++})}}return e}function A(t){let i=new Map;for(let n of t)i.has(n.exerciseId)||i.set(n.exerciseId,[]),i.get(n.exerciseId).push({questionId:n.questionId,answers:n.answers});return{exerciseAnswers:Array.from(i.entries()).map(([n,e])=>({exerciseId:n,questionAnswers:e}))}}var y=new Set(["choiceSet","inlineChoiceSet","blank","aiAnswerInput","matchingSet","openResponseNode","mathResponse","codingResponse"]),I=new Set(["blankPool","inlinePool"]);function x(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 i=t.answer;return i.recording||i.files&&i.files.length>0?!0:(i.text?.wordCount??0)>0}case"mathResponse":return t.answer.latex.trim().length>0;case"codingResponse":return t.answer.source.trim().length>0;default:{let i=t;return!0}}}function b(t){let i=0,n=e=>{if(Array.isArray(e)){for(let s of e)n(s);return}if(!e||typeof e!="object")return;let{type:r,content:o}=e;if(typeof r=="string"){if(y.has(r)){i+=1;return}if(I.has(r))return}o!==void 0&&n(o)};return n(t),i}function S(t,i){let n=new Map;for(let r of i?.exerciseAnswers??[])for(let o of r.questionAnswers){let s=n.get(o.questionId);s||(s=new Set,n.set(o.questionId,s));for(let a of o.answers)x(a)&&s.add(a.nodeId)}let e=[];return t.exercises.forEach((r,o)=>{r.questions.forEach((s,a)=>{let d=b(s.content);d!==0&&(n.get(s.id)?.size??0)<d&&e.push({questionId:s.id,exerciseIndex:o,...r.title?{exerciseTitle:r.title}:{},questionIndex:a,only:r.questions.length===1})})}),e}function q(t,i,n){let e=new Set(n);return e.size===0?[]:S(t,i).filter(r=>e.has(r.questionId))}export{A as buildSubmitPayload,b as countAnswerableNodes,h as flattenAssessment,k as flattenReview,x as isAnswered,q as missingRequired};
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};
package/dist/index.d.mts CHANGED
@@ -673,8 +673,15 @@ interface ReviewStep {
673
673
  * missed and the teacher's comment on an open response.
674
674
  */
675
675
  feedback: Record<string, unknown>;
676
+ /** 0 when `scoreHidden`: the review carries no points then. */
676
677
  score: number;
677
678
  maxScore: number;
679
+ /**
680
+ * True when the teacher chose not to show the score to students (SDK 0.12.2).
681
+ * `score` and `maxScore` are then 0 and mean nothing: show no points. `status`
682
+ * still says right, partly right or wrong.
683
+ */
684
+ scoreHidden: boolean;
678
685
  /**
679
686
  * The question as a whole. `awaiting_review` while a teacher has yet to mark
680
687
  * any part of it; its score is then provisional. `unscored` when it is worth