I am trying to implement custom javascript problem. I have my javascript application.
But when I submit my problem it shows “Could not grade your answer. The submission was aborted.”
Here code
<h2>Is causal relationship explicitly stated in the statement?</h2>
<label class="container">Yes
<input type="radio" name="radio" id="checkBox" onclick="func.showQue()">
<span class="checkmark-1"></span>
</label>
<label class="container">No
<input type="radio" name="radio" onclick="func.showQue()">
<span class="checkmark-1"></span>
</label>
<div style="display: none;" id="question">
<h2>If yes, which is the cause? </h2>
<label class="container">Supreme court declares the statute unenforceable
<input type="radio" name="final" id="checkbox2">
<span class="checkmark-2"></span>
</label>
<label class="container">He goes free
<input type="radio" name="final">
<span class="checkmark-2"></span>
</label>
</div>
<script>
let func = (function() {
function showQue() {
let checkBox = document.getElementById("checkBox");
let text = document.getElementById("question");
if (checkBox.checked == true){
text.style.display = "block";
} else {
text.style.display = "none";
}
}
function getGrade() {
let checkans = document.getElementById("checkbox")
let check2ans = document.getElementById("checkbox2")
if (checkans.checked == true){
if (check2ans.checked == true) {
return JSON.stringify("correct")
}
} else {
/ return JSON.stringify("wrong")
}
}
state = {
choice: "correct"
}
function getState() {
return JSON.stringify(state);
}
return {
showQue: showQue,
getGrade: getGrade,
getState: getState
}
})();
</script>
and the problem “cms-modules.2b7ffc378730.js:175 Uncaught TypeError: Cannot read property ‘getGrade’ of undefined”. Not sure what I am missing.
and code from edx
<problem>
<script type="loncapa/python">
import json
def all_true(exp, ans):
response = json.loads(ans)
return response["answer"] == "correct"
</script>
<customresponse cfn="all_true">
<jsinput gradefn="func.getGrade"
height="500"
html_file="/static/inputjs.html"
title="iframe Title"
sop="true"/>
</customresponse>
</problem>