// Numbas version: exam_results_page_options {"name": "Exam using custom logo theme", "metadata": {"description": "

This exam uses a custom theme which provides a new logo image.

", "licence": "Creative Commons Attribution 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": [""], "questions": [{"name": "Integrate an expression", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "functions": {}, "ungrouped_variables": ["a", "b"], "tags": ["demo"], "preamble": {"css": "", "js": "//*************\n// differentiation\nvar jme = Numbas.jme;\nvar TNum = Numbas.jme.types.TNum;\n\nvar functionDerivatives = {\n 'cos': '-sin(x)',\n 'sin': 'cos(x)'\n};\nvar generalFunctionDerivative = jme.compile(\"f'(x)\");\nfor(var name in functionDerivatives) {\n functionDerivatives[name] = jme.compile(functionDerivatives[name]);\n}\nvar chainRule = jme.compile(\"x'*f'\")\n var opDerivatives = {\n '+': \"u'+v'\",\n '+u': \"+u'\",\n '-u': \"-u'\",\n '-': \"u'-v'\",\n '*': \"u'*v+u*v'\",\n \"/\": \"(v*u'-v'*u)/(v^2)\"\n }\n var powerRule = jme.compile(\"v*u'*u^(v-1)\");\nvar exponentialRule = jme.compile(\"ln(u)*v'*u^v\");\nfor(var name in opDerivatives) {\n opDerivatives[name] = jme.compile(opDerivatives[name]);\n}\n\nvar differentiate = jme.differentiate = function(tree,x) {\n var tok = tree.tok;\n \n switch(tok.type) {\n case 'number':\n return {tok: new TNum(0)};\n break;\n case 'name':\n return {tok: new TNum(tok.name==x ? 1 : 0)};\n case 'op':\n var l = differentiate(tree.args[0],x,1);\n if(tree.args.length>1)\n var r = differentiate(tree.args[1],x,1);\n var scope = {variables: {\"u\": tree.args[0], \"u'\": l, \"v\": tree.args[1], \"v'\": r}};\n if(tok.name=='^') {\n if(tree.args[1].tok.type=='number' || (tree.args[1].tok.type=='op' && tree.args[1].tok.name=='-u' && tree.args[1].args[0].tok.type=='number')) {\t// f(x)^n\n return jme.substituteTree(powerRule,scope);\n }\n else if(tree.args[0].tok.type=='number' || (tree.args[0].tok.type=='op' && tree.args[0].tok.name=='-u' && tree.args[0].args[0].tok.type=='number')) {\t// n^x\n return jme.substituteTree(exponentialRule,scope);\n }\n else {\n throw(new Numbas.Error('jme.differentiate.hard exponential'));\n }\n }\n return jme.substituteTree(opDerivatives[tok.name],scope);\n case 'function':\n var df = jme.substituteTree(tok.name in functionDerivatives ? functionDerivatives[tok.name] : generalFunctionDerivative,{variables:{x:tree.args[0], \"f'\": tok.name+\"'\"}});\n var dx = differentiate(tree.args[0],x);\n return jme.substituteTree(chainRule,{variables: {\"f'\": df, \"x'\": dx}});\n }\n}\n // end of differentiation code\n // ***************************\n \n question.signals.on('HTMLAttached',function() {\n var gap = question.parts[0].gaps[0];\n var omark = gap.mark;\n var add_constant_rule = new Numbas.jme.display.Rule('x+y',[]);\n gap.mark = function() {\n var integral = gap.studentAnswer;\n var tree;\n var derivative;\n var derivative_tree;\n try {\n tree = Numbas.jme.compile(integral);\n derivative_tree = differentiate(tree,'x');\n derivative = Numbas.jme.display.treeToJME(derivative_tree);\n derivative = Numbas.jme.display.simplifyExpression(derivative,'all',Numbas.jme.builtinScope);\n }\n catch(e) {\n derivative = '';\n }\n // set the \"student's answer\" to the derivative\n this.studentAnswer = derivative;\n \n // mark the JME part\n omark.apply(this);\n \n // set the student's answer back to what they typed\n this.studentAnswer = integral;\n \n this.markingFeedback = [];\n \n if(this.credit==1) { // derivative matches\n this.markingComment('Your answer is correct. Well done!');\n \n // check there's a constant of integration\n if(Numbas.jme.findvars(tree).length!=2) {\n this.multCredit(0.5,'You need to add a constant of integration, but otherwise this is correct.');\n }\n }\n else {\n var derivativeTeX = Numbas.jme.display.exprToLaTeX(derivative,[],Numbas.jme.builtinScope);\n this.markingComment('The derivative of your answer should be equal to the expression you were asked to integrate, i.e.: \\\\[ \\\\simplify{cos({a}x) + e^(x/{b})} \\\\] The derivative of your function is \\\\['+derivativeTeX+'\\\\]');\n }\n }\n });"}, "advice": "", "rulesets": {}, "parts": [{"prompt": "

This part is marked by calculating the derivative of your answer and comparing it to the original expression.

\n

$\\displaystyle{\\int \\simplify{cos({a}x) + e^(x/{b})} \\,\\mathrm{d}x = }$ [[0]]

", "marks": 0, "gaps": [{"expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "vsetrangepoints": 5, "showCorrectAnswer": true, "scripts": {}, "answer": "cos({a}x)+e^(x/{b})", "marks": 2, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme"}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}], "statement": "", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "type": "question", "variables": {"a": {"definition": "random(1..10)", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "b": {"definition": "random(-10..10 except 0)", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"notes": "", "description": "

Demo question: do some sneaky symbolic differentiation to check that the student's answer is the integral of the expression they're given.

\n

Needs an advice section before it can be used.

", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}]}], "allowPrinting": true, "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": true, "showresultspage": "never", "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": true, "startpassword": ""}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"showactualmark": true, "showtotalmark": true, "showanswerstate": true, "allowrevealanswer": true, "advicethreshold": 0, "intro": "", "reviewshowscore": true, "reviewshowfeedback": true, "reviewshowexpectedanswer": true, "reviewshowadvice": true, "feedbackmessages": []}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "extensions": [], "custom_part_types": [], "resources": []}