// Numbas version: exam_results_page_options {"name": "Functions: floor and roof", "extensions": [], "custom_part_types": [], "resources": [["question-resources/Floor_function.svg.png", "/srv/numbas/media/question-resources/Floor_function.svg.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Functions: floor and roof", "tags": [], "metadata": {"description": "

Introduces students to the floor and ceiling functions

", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "

The floor of $x$ is defined to be the largest integer smaller than $x$. Similarly the ceiling of $x$ is defined to be the smallest integer bigger than $x$. We use the notation $\\lfloor x\\rfloor$ for the floor and $\\lceil x\\rceil$ for the ceiling. Evaluate the following:

\n

", "advice": "

Normally, when you round a number you round up to the nearest integer. For example $3.51$ gets rounded up to $4$, but $3.49$ gets rounded down to $3$.

\n

The floor and ceiling functions are two different ways of rounding a number.

\n", "rulesets": {}, "extensions": [], "variables": {"x1": {"name": "x1", "group": "Ungrouped variables", "definition": "decimal(random(1..9)+random(1..9)/10)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["x1"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"mark": {"script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = unwrap(variables.x1);\n\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(1,\"Correct. This is the floor of $\" + x1 + \"$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(0,\"Close. This is the ceiling of $\" + x1 + \"$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$\\lfloor \\var{x1}\\rfloor$

", "answer": "{floor(x1)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"mark": {"script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = unwrap(variables.x1);\n\n// compute its derivative\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(0,\"Close. This is the floor of $\" + x1 + \"$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(1,\"Correct. This is the ceiling of $\" + x1 + \"$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$\\lceil \\var{x1}\\rceil$

", "answer": "{ceil(x1)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"mark": {"script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = -1*unwrap(variables.x1);\n\n// compute its derivative\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(1,\"Correct. This is the floor of $\" + x1 + \"$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(0,\"Close. This is the ceiling of $\" + x1 + \"$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [{"variable": "", "part": "p1", "must_go_first": false}], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$\\lfloor - \\var{x1}\\rfloor$

", "answer": "{floor(-x1)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"mark": {"script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = -1*unwrap(variables.x1);\n\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(0,\"Close. This is the floor of $\" + x1 + \"$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(1,\"Correct. This is the ceiling of $\" + x1 + \"$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$\\lceil -\\var{x1}\\rceil$

", "answer": "{ceil(-x1)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}]}