diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8305a04..871fa63 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -26,6 +26,7 @@
"dans",
"displaystyle",
"dsolve",
+ "eigenvals",
"ejecuta",
"elif",
"erreurs",
diff --git a/CHANGELOG b/CHANGELOG
index 8485309..bfc6a41 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+# v1.2.4
+
+- bug fix: the internal counter for single/multiple choice sections was not reset after retrying a question
+- bug fix: context-sensitive boolean variables were not correctly compared.
+
# v1.2.3
- bug fix: single-choice answers with at least 5 options no longer produce strange progress hints to the student
diff --git a/docs/ex1.html b/docs/ex1.html
index 1953f25..de2cf4b 100644
--- a/docs/ex1.html
+++ b/docs/ex1.html
@@ -1,4 +1,4 @@
-
pySELL Quiz DEBUG VERSION
This quiz was created using pySELL, the Python-based Simple E-Learning Language, written by Andreas Schwenk, GPLv3
last update on
DEBUG VERSION
This quiz was created using pySELL, the Python-based Simple E-Learning Language, written by Andreas Schwenk, GPLv3
last update on
\ No newline at end of file
+ `.includes(s)==!1&&(this.token+=s),this.pos++}}isNum(e){return e.charCodeAt(0)>=48&&e.charCodeAt(0)<=57}isAlpha(e){return e.charCodeAt(0)>=65&&e.charCodeAt(0)<=90||e.charCodeAt(0)>=97&&e.charCodeAt(0)<=122||e==="_"}toString(){return this.root==null?"":this.root.toString()}toTexString(){return this.root==null?"":this.root.toTexString()}},f=class r{constructor(e,t,i=0,s=0){this.op=e,this.c=t,this.re=i,this.im=s,this.explicitParentheses=!1}clone(){let e=new r(this.op,this.c.map(t=>t.clone()),this.re,this.im);return e.explicitParentheses=this.explicitParentheses,e}static const(e=0,t=0){return new r("const",[],e,t)}compare(e,t=0,i=1e-9){let s=this.re-e,l=this.im-t;return Math.sqrt(s*s+l*l)1e-14,i=Math.abs(this.im)>1e-14;t&&i&&this.im>=0?e="("+this.re+"+"+this.im+"i)":t&&i&&this.im<0?e="("+this.re+"-"+-this.im+"i)":t&&this.re>0?e=""+this.re:t&&this.re<0?e="("+this.re+")":i?e="("+this.im+"i)":e="0"}else this.op.startsWith("var")?e=this.op.split(":")[1]:this.c.length==1?e=(this.op===".-"?"-":this.op)+"("+this.c.toString()+")":e="("+this.c.map(t=>t.toString()).join(this.op)+")";return e}toTexString(e=!1){let i="";switch(this.op){case"const":{let s=Math.abs(this.re)>1e-9,l=Math.abs(this.im)>1e-9,a=s?""+this.re:"",h=l?""+this.im+"i":"";h==="1i"?h="i":h==="-1i"&&(h="-i"),!s&&!l?i="0":(l&&this.im>=0&&s&&(h="+"+h),i=a+h);break}case".-":i="-"+this.c[0].toTexString();break;case"+":case"-":case"*":case"^":{let s=this.c[0].toTexString(),l=this.c[1].toTexString(),a=this.op==="*"?"\\cdot ":this.op;i="{"+s+"}"+a+"{"+l+"}";break}case"/":{let s=this.c[0].toTexString(!0),l=this.c[1].toTexString(!0);i="\\frac{"+s+"}{"+l+"}";break}case"sin":case"sinc":case"cos":case"tan":case"cot":case"exp":case"ln":{let s=this.c[0].toTexString(!0);i+="\\"+this.op+"\\left("+s+"\\right)";break}case"sqrt":{let s=this.c[0].toTexString(!0);i+="\\"+this.op+"{"+s+"}";break}case"abs":{let s=this.c[0].toTexString(!0);i+="\\left|"+s+"\\right|";break}default:if(this.op.startsWith("var:")){let s=this.op.substring(4);switch(s){case"pi":s="\\pi";break}i=" "+s+" "}else{let s="warning: Node.toString(..):";s+=" unimplemented operator '"+this.op+"'",console.log(s),i=this.op,this.c.length>0&&(i+="\\left({"+this.c.map(l=>l.toTexString(!0)).join(",")+"}\\right)")}}return!e&&this.explicitParentheses&&(i="\\left({"+i+"}\\right)"),i}};function ie(r,e){let t=1e-9;if(k.compare(r,e))return!0;r=r.clone(),e=e.clone(),N(r.root),N(e.root);let i=new Set;r.getVars(i),e.getVars(i);let s=[],l=[];for(let n of i.keys())n.startsWith("C")?s.push(n):l.push(n);let a=s.length;for(let n=0;n{r.feedbackPopupDiv.style.display="none"},500),r.state===b.passed?r.src.instances.length>0?r.checkAndRepeatBtn.innerHTML=te:r.checkAndRepeatBtn.style.display="none":r.checkAndRepeatBtn.innerHTML=I}var A=class{constructor(e,t,i,s){this.question=t,this.inputId=i,i.length==0&&(this.inputId=i="gap-"+t.gapIdx,t.types[this.inputId]="string",t.expected[this.inputId]=s,t.gapIdx++),i in t.student||(t.student[i]="");let l=s.split("|"),a=0;for(let c=0;ca&&(a=u.length)}let h=v("");e.appendChild(h);let n=Math.max(a*15,24),o=R(n);if(t.gapInputs[this.inputId]=o,o.addEventListener("keyup",()=>{this.question.editedQuestion(),o.value=o.value.toUpperCase(),this.question.student[this.inputId]=o.value.trim()}),h.appendChild(o),this.question.showSolution&&(this.question.student[this.inputId]=o.value=l[0],l.length>1)){let c=v("["+l.join("|")+"]");c.style.fontSize="small",c.style.textDecoration="underline",h.appendChild(c)}}},D=class{constructor(e,t,i,s,l,a,h=!1){i in t.student||(t.student[i]=""),this.question=t,this.inputId=i,this.outerSpan=v(""),this.outerSpan.style.position="relative",e.appendChild(this.outerSpan),this.inputElement=R(Math.max(s*12,48)),this.outerSpan.appendChild(this.inputElement),this.equationPreviewDiv=x(),this.equationPreviewDiv.classList.add("equationPreview"),this.equationPreviewDiv.style.display="none",this.outerSpan.appendChild(this.equationPreviewDiv),this.inputElement.addEventListener("click",()=>{this.question.editedQuestion(),this.edited()}),this.inputElement.addEventListener("keyup",()=>{this.question.editedQuestion(),this.edited()}),this.inputElement.addEventListener("focusout",()=>{this.equationPreviewDiv.innerHTML="",this.equationPreviewDiv.style.display="none"}),this.inputElement.addEventListener("keydown",n=>{let o="abcdefghijklmnopqrstuvwxyz";o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ",o+="0123456789",o+="+-*/^(). <>=|",a&&(o="-0123456789"),n.key.length<3&&o.includes(n.key)==!1&&n.preventDefault();let c=this.inputElement.value.length*12;this.inputElement.offsetWidth0&&!i?"block":"none",this.question.student[this.inputId]=e}},V=class{constructor(e,t,i,s){this.parent=e,this.question=t,this.inputId=i,this.matExpected=new E(0,0),this.matExpected.fromString(s),this.matStudent=new E(this.matExpected.m==1?1:3,this.matExpected.n==1?1:3),t.showSolution&&this.matStudent.fromMatrix(this.matExpected),this.genMatrixDom(!0)}genMatrixDom(e){let t=x();this.parent.innerHTML="",this.parent.appendChild(t),t.style.position="relative",t.style.display="inline-block";let i=document.createElement("table");t.appendChild(i);let s=this.matExpected.getMaxCellStrlen();for(let p=0;p=10,this.matStudent.n<=1,this.matStudent.m>=10,this.matStudent.m<=1];for(let p=0;p<4;p++){if(u[p]==!1)continue;let m=v(l[p]);n[p]!=888&&(m.style.top=""+n[p]+"px"),o[p]!=888&&(m.style.bottom=""+o[p]+"px"),c[p]!=888&&(m.style.right=""+c[p]+"px"),m.classList.add("matrixResizeButton"),t.appendChild(m),d[p]?m.style.opacity="0.5":m.addEventListener("click",()=>{for(let g=0;g=5&&(this.feedbackSpan.innerHTML=""+this.numCorrect+" / "+this.numChecked);break}this.questionDiv.style.color=this.feedbackSpan.style.color=this.titleDiv.style.color=this.checkAndRepeatBtn.style.backgroundColor=this.questionDiv.style.borderColor=e,this.questionDiv.style.backgroundColor=t}populateDom(){if(this.parentDiv.innerHTML="",this.questionDiv=x(),this.parentDiv.appendChild(this.questionDiv),this.questionDiv.classList.add("question"),this.feedbackPopupDiv=x(),this.feedbackPopupDiv.classList.add("questionFeedback"),this.questionDiv.appendChild(this.feedbackPopupDiv),this.feedbackPopupDiv.innerHTML="awesome",this.debug&&"src_line"in this.src){let s=x();s.classList.add("debugInfo"),s.innerHTML="Source code: lines "+this.src.src_line+"..",this.questionDiv.appendChild(s)}if(this.titleDiv=x(),this.questionDiv.appendChild(this.titleDiv),this.titleDiv.classList.add("questionTitle"),this.titleDiv.innerHTML=this.src.title,this.src.error.length>0){let s=v(this.src.error);this.questionDiv.appendChild(s),s.style.color="red";return}let e=this.getCurrentInstance();if(e!=null&&"__svg_image"in e){let s=e.__svg_image.v,l=x();this.questionDiv.appendChild(l);let a=document.createElement("img");l.appendChild(a),a.classList.add("img"),a.src="data:image/svg+xml;base64,"+s}for(let s of this.src.text.c)this.questionDiv.appendChild(this.generateText(s));let t=x();this.questionDiv.appendChild(t),t.classList.add("buttonRow"),this.hasCheckButton=Object.keys(this.expected).length>0,this.hasCheckButton&&(this.checkAndRepeatBtn=j(),t.appendChild(this.checkAndRepeatBtn),this.checkAndRepeatBtn.innerHTML=I,this.checkAndRepeatBtn.style.backgroundColor="black");let i=v(" ");if(t.appendChild(i),this.feedbackSpan=v(""),t.appendChild(this.feedbackSpan),this.debug){if(this.src.variables.length>0){let a=x();a.classList.add("debugInfo"),a.innerHTML="Variables generated by Python Code",this.questionDiv.appendChild(a);let h=x();h.classList.add("debugCode"),this.questionDiv.appendChild(h);let n=this.getCurrentInstance(),o="",c=[...this.src.variables];c.sort();for(let u of c){let d=n[u].t,p=n[u].v;switch(d){case"vector":p="["+p+"]";break;case"set":p="{"+p+"}";break}o+=d+" "+u+" = "+p+"
"}h.innerHTML=o}let s=["python_src_html","text_src_html"],l=["Python Source Code","Text Source Code"];for(let a=0;a0){let n=x();n.classList.add("debugInfo"),n.innerHTML=l[a],this.questionDiv.appendChild(n);let o=x();o.classList.add("debugCode"),this.questionDiv.append(o),o.innerHTML=this.src[h]}}}this.hasCheckButton&&this.checkAndRepeatBtn.addEventListener("click",()=>{this.state==b.passed?(this.state=b.init,this.reset(),this.populateDom()):se(this)})}generateMathString(e){let t="";switch(e.t){case"math":case"display-math":for(let i of e.c){let s=this.generateMathString(i);i.t==="var"&&t.includes("!PM")&&(s.startsWith("{-")?(s="{"+s.substring(2),t=t.replaceAll("!PM","-")):t=t.replaceAll("!PM","+")),t+=s}break;case"text":return e.d;case"plus_minus":{t+=" !PM ";break}case"var":{let i=this.getCurrentInstance(),s=i[e.d].t,l=i[e.d].v;switch(s){case"vector":return"\\left["+l+"\\right]";case"set":return"\\left\\{"+l+"\\right\\}";case"complex":{let a=l.split(","),h=parseFloat(a[0]),n=parseFloat(a[1]);return f.const(h,n).toTexString()}case"matrix":{let a=new E(0,0);return a.fromString(l),t=a.toTeXString(e.d.includes("augmented"),this.language!="de"),t}case"term":{try{t=k.parse(l).toTexString()}catch{}break}default:t=l}}}return e.t==="plus_minus"?t:"{"+t+"}"}generateText(e,t=!1){switch(e.t){case"paragraph":case"span":{let i=document.createElement(e.t=="span"||t?"span":"p");for(let s of e.c)i.appendChild(this.generateText(s));return i}case"text":return v(e.d);case"code":{let i=v(e.d);return i.classList.add("code"),i}case"italic":case"bold":{let i=v("");return i.append(...e.c.map(s=>this.generateText(s))),e.t==="bold"?i.style.fontWeight="bold":i.style.fontStyle="italic",i}case"math":case"display-math":{let i=this.generateMathString(e);return T(i,e.t==="display-math")}case"string_var":{let i=v(""),s=this.getCurrentInstance(),l=s[e.d].t,a=s[e.d].v;return l==="string"?i.innerHTML=a:(i.innerHTML="EXPECTED VARIABLE OF TYPE STRING",i.style.color="red"),i}case"gap":{let i=v("");return new A(i,this,"",e.d),i}case"input":case"input2":{let i=e.t==="input2",s=v("");s.style.verticalAlign="text-bottom";let l=e.d,a=this.getCurrentInstance()[l];if(this.expected[l]=a.v,this.types[l]=a.t,!i)switch(a.t){case"set":s.append(T("\\{"),v(" "));break;case"vector":s.append(T("["),v(" "));break}if(a.t==="string")new A(s,this,l,this.expected[l]);else if(a.t==="vector"||a.t==="set"){let h=a.v.split(","),n=h.length;for(let o=0;o0&&s.appendChild(v(" , "));let c=l+"-"+o;new D(s,this,c,h[o].length,h[o],!1)}}else if(a.t==="matrix"){let h=x();s.appendChild(h),new V(h,this,l,a.v)}else if(a.t==="complex"){let h=a.v.split(",");new D(s,this,l+"-0",h[0].length,h[0],!1),s.append(v(" "),T("+"),v(" ")),new D(s,this,l+"-1",h[1].length,h[1],!1),s.append(v(" "),T("i"))}else{let h=a.t==="int";new D(s,this,l,a.v.length,a.v,h)}if(!i)switch(a.t){case"set":s.append(v(" "),T("\\}"));break;case"vector":s.append(v(" "),T("]"));break}return s}case"itemize":return z(e.c.map(i=>U(this.generateText(i))));case"single-choice":case"multi-choice":{let i=e.t=="multi-choice";i||(this.includesSingleChoice=!0);let s=document.createElement("table"),l=e.c.length,a=this.debug==!1,h=P(l,a),n=i?J:ee,o=i?G:$,c=[],u=[];for(let d=0;d{this.editedQuestion(),this.student[g]=this.student[g]==="true"?"false":"true",this.student[g]==="true"?S.innerHTML=n:S.innerHTML=o}):C.addEventListener("click",()=>{this.editedQuestion();for(let L of u)this.student[L]="false";this.student[g]="true";for(let L=0;L";document.getElementById("courseInfo2").innerHTML=F[r.lang].replace("*",t);let i=[],s=document.getElementById("questions"),l=1;for(let a of r.questions){a.title=""+l+". "+a.title;let h=x();s.appendChild(h);let n=new H(h,a,r.lang,e);n.showSolution=e,i.push(n),n.populateDom(),e&&a.error.length==0&&n.hasCheckButton&&n.checkAndRepeatBtn.click(),l++}}return he(de);})();sell.init(quizSrc,debug);