// Numbas version: exam_results_page_options {"name": "Using hidden gaps", "extensions": [], "custom_part_types": [], "resources": [["question-resources/undefined_EiYwBiZ", "/srv/numbas/media/question-resources/undefined_EiYwBiZ"], ["question-resources/undefined_HQevITs", "/srv/numbas/media/question-resources/undefined_HQevITs"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {}, "ungrouped_variables": ["a", "c", "b", "d", "f", "p", "s", "v"], "name": "Using hidden gaps", "tags": ["hidden gaps", "zero marked gaps"], "preamble": {"css": "", "js": "\nquestion.signals.on('HTMLAttached',function() {\n//the variable values to be used throughout the parts are captured on running the question.\nvar scope = question.scope;\n \nvar x = Numbas.jme.unwrapValue(scope.variables.c);\nvar y = Numbas.jme.unwrapValue(scope.variables.d);\nvar v= Numbas.jme.unwrapValue(scope.variables.v);\nvar f= Numbas.jme.unwrapValue(scope.variables.f);\n//part a.\n/*Here the inputs to the two zero marked gap-fills are assigned to variables, and their sum is given as an answer \nto the question by assigning its value as an answer to the third gap-fill which has a mark allocated to it - \nthis gap-fill is hidden from the user by not quoting it in the prompt for this part*/\nko.computed(function() {\nvar ans1 = parseInt(question.parts[0].gaps[0].display.studentAnswer());\nvar ans2 = parseInt(question.parts[0].gaps[1].display.studentAnswer());\n\nvar ans =ans1+ans2;\n\nquestion.parts[0].gaps[2].display.studentAnswer(ans);\n });\n//part b\n/*gap-fills 0 and 1 are zero marked, so are content holders, 2 and 3 are not displayed but are used to mark the input*/\n ko.computed(function() {\nvar ans1 = parseInt(question.parts[1].gaps[0].display.studentAnswer());\nvar ans2 = parseInt(question.parts[1].gaps[1].display.studentAnswer());\n\nvar sum =ans1+ans2;\nvar prod=ans1*ans2;\n\nquestion.parts[1].gaps[2].display.studentAnswer(sum);\nquestion.parts[1].gaps[3].display.studentAnswer(prod);\n });\n//part c\n ko.computed(function() {\nvar a = parseInt(question.parts[2].gaps[0].display.studentAnswer());\nvar b = parseInt(question.parts[2].gaps[1].display.studentAnswer());\n\nvar det =x*y-a*b;\n\n\nquestion.parts[2].gaps[2].display.studentAnswer(det);\n\n });\n//part d)\n ko.computed(function() {\nvar ans1 = parseInt(question.parts[3].gaps[0].display.studentAnswer());\nvar ans2 = parseInt(question.parts[3].gaps[1].display.studentAnswer());\n\nvar ans =\"(x-\"+ans1+\")(x-\"+ans2+\")\";\n\n\nquestion.parts[3].gaps[2].display.studentAnswer(ans);\n\n });\n//part e)\n ko.computed(function() {\nvar a = parseInt(question.parts[4].gaps[0].display.studentAnswer());\nvar b = parseInt(question.parts[4].gaps[1].display.studentAnswer());\nvar c = parseInt(question.parts[4].gaps[2].display.studentAnswer());\nvar d = parseInt(question.parts[4].gaps[3].display.studentAnswer());\nvar ans1= a+d;\nvar ans2 =b*c+v*v-d*a;\n\nquestion.parts[4].gaps[4].display.studentAnswer(ans1);\nquestion.parts[4].gaps[5].display.studentAnswer(ans2);\n\n });\n//part f)\n ko.computed(function() {\n\nvar b = parseInt(question.parts[5].gaps[0].display.studentAnswer());\nvar c = parseInt(question.parts[5].gaps[1].display.studentAnswer());\n/*the following variable d is not used, however there is a gap fill (hidden) which takes it value, so is a dummy\nvariable not used, not quite sure how useful this is?*/\nvar d = parseInt(question.parts[5].gaps[2].display.studentAnswer());\nvar ans1 =b*c+v*v-d*f;\n \nquestion.parts[5].gaps[3].display.studentAnswer(ans1);\n\n\n });\n//part g)\n /*This version of part f) is better as it gives credit to users recognising the value of the diagonal element*/\n ko.computed(function() {\n\nvar b = parseInt(question.parts[6].gaps[0].display.studentAnswer());\nvar c = parseInt(question.parts[6].gaps[1].display.studentAnswer());\nvar d = parseInt(question.parts[6].gaps[2].display.studentAnswer());\nvar ans1=d;\nvar ans2 =b*c+v*v-d*f; \n//Feedback to user if the diagonal element is not correct once all numbers have been input.\nvar fin=isNaN(b)||isNaN(c)||isNaN(d);\nvar m;\n//if either the input has not been completed or the correct answer has been input - no message.\nif(fin||(ans1==-f)){ m='';}\n//all entries have been input and an incorrect diagonal value has been input.\nelse {m='You did not enter the correct value for the diagonal.';}\n//This is displayed in the question as an aid to the user.\nvar html = $(question.display.html);\nhtml.find('#mess').text(m);\n\n/*values for hidden gapfills which are marked*/\nquestion.parts[6].gaps[3].display.studentAnswer(ans1); \nquestion.parts[6].gaps[4].display.studentAnswer(ans2);\n\n\n });\n})"}, "advice": "", "rulesets": {}, "parts": [{"prompt": "

Input two integers whose sum is 100.

\n

[[0]] $+$   [[1]] $=100$

\n

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "100", "minValue": "100", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Input two integers whose sum is {s} and product is {p}

\n

[[0]]           [[1]]

\n

\n

Hence factorise  $\\simplify[all,!collectNumbers]{x^2-{s}*x+{p}}$

\n

[[4]]

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "s", "minValue": "s", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "p", "minValue": "p", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}, {"notallowed": {"message": "

Factorise the expression.

", "showStrings": false, "strings": ["^"], "partialCredit": 0}, "vsetrangepoints": 5, "expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "answersimplification": "all", "scripts": {}, "answer": "(x-{a})(x-{b})", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme", "musthave": {"message": "

Factorise the expression.

", "showStrings": false, "strings": ["("], "partialCredit": 0}}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Input the two missing integer entries in the following matrix $A$ so that the resulting  matrix has determinant 1.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$A = \\Bigg($$\\var{c}$[[0]]$\\Bigg)$
[[1]]$\\var{d}$
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Input the two roots $r_1$ and $r_2$  of 

\n

$\\simplify[all,!collectNumbers]{x^2-{s}*x+{p}}=0$

\n

$r_1\\;=\\;$[[0]], $r_2\\;=\\;$[[1]]

\n

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"vsetrangepoints": 5, "expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "answer": "(x-{a})*(x-{b})", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Fill in the entries of the following matrix $A$ so that the resulting  matrix has the following properties:

\n

$\\operatorname{Trace}(A)=0$

\n

The eigenvalues are : $\\lambda_1=\\simplify{{v}*i},\\;\\lambda_2=\\simplify{-{v}*i}$

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$A = \\Bigg($[[0]][[1]]$\\Bigg)$
[[2]][[3]]
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Same as part e) except that no need to ask for trace=0 as this is aways true for purely imaginary eigenvalues. Also force users to use some other number other than 0 for diagonal elements.

\n

Fill in the missing entries of the following matrix $A$ so that the resulting  matrix has the following property:

\n

The eigenvalues are : $\\lambda_1=\\simplify{{v}*i},\\;\\lambda_2=\\simplify{-{v}*i}$

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$A = \\Bigg($$\\var{f}$[[0]]$\\Bigg)$
[[1]][[2]]
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 2, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

Same as part f) except that we split the marking so that one mark is given for inputting the correct value on the diagonal and 2 marks for finishing off the question properly.

\n

Also there is an immediate feedback to to the user if the wrong value for the diagonal element is input once all matrix values have been input.

\n

Fill in the missing entries of the following matrix $A$ so that the resulting  matrix has the following property:

\n

The eigenvalues are : $\\lambda_1=\\simplify{{v}*i},\\;\\lambda_2=\\simplify{-{v}*i}$

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$A = \\Bigg($$\\var{f}$[[0]]$\\Bigg)$
[[1]][[2]]
\n

\n

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "-f", "minValue": "-f", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 2, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "extensions": [], "statement": "

Demonstrating some techniques in Numbas, so that user input is less constrained and can be more exploratory and open-ended. 

\n

The basic idea is to use zero-weighted gap-fills, which act as holders for input without being assessed and these are then used to answer questions and/or to meet criteria set by the question.

\n

Note that to stop Numbas marking such gap-fills as incorrect (the default is that anything with a zero mark is incorrect), you turn off the marking via the following in the 'Mark student's answer' script content area and choose 'Run this script instead of the built-in script'.

\n

!doesMarking;
this.answered=true;

\n

Another  useful tool is to use hidden gap-fills which are used for marking by checking the question criteria.

\n

You hide a gap-fill by simply not quoting it in the prompt, thus if the third gap-fill is to be hidden you would not put [[2]] in the prompt for the part.

\n

One thing to be aware of at present is that a zero weighted gap-fill should still have an input in 'correct answer' for a Mathematical expression question  or inputs of min and max values in a Number entry question etc. - these can be any value consistent with the question type and can bear little or no relation to the expected answers. However, you can opt out of displaying these usually arbitrary values when Reveal answers is used by unticking'Show Preview of student's answer' in the Marking section of a question.

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(1..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "c": {"definition": "random(2..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "c", "description": ""}, "b": {"definition": "random(1..9 except a)", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}, "d": {"definition": "random(2..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "d", "description": ""}, "f": {"definition": "random(-9..9 except[-1,0,2])", "templateType": "anything", "group": "Ungrouped variables", "name": "f", "description": ""}, "p": {"definition": "a*b", "templateType": "anything", "group": "Ungrouped variables", "name": "p", "description": ""}, "s": {"definition": "a+b", "templateType": "anything", "group": "Ungrouped variables", "name": "s", "description": ""}, "v": {"definition": "random(1..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "v", "description": ""}}, "metadata": {"description": "

This question uses the technique of allocating zero marks to gaps so that they act as holders of values input by the user but are not assessed. The values so input are then gathered using the code found in the preamble and suitable combinations are assigned as answers to gap fills which are then assessed to see if they meet the requirements of the question. Note that is a gap fill is created, but not addressed in the prompt of the part then it is hidden from the user.

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}]}], "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}