// Numbas version: finer_feedback_settings {"name": "Functions: floor and roof", "extensions": [], "custom_part_types": [], "resources": [["question-resources/Floor_function.svg.png", "Floor_function.svg.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "metadata": {"description": "
Introduces students to the floor and ceiling functions
", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "ungrouped_variables": ["x1"], "functions": {}, "extensions": [], "variablesTest": {"condition": "", "maxRuns": 100}, "type": "question", "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", "preamble": {"js": "", "css": ""}, "tags": [], "parts": [{"showPreview": true, "customMarkingAlgorithm": "", "variableReplacements": [], "scripts": {"mark": {"order": "instead", "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(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}"}}, "answer": "{floor(x1)}", "failureRate": 1, "checkingType": "absdiff", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "jme", "vsetRange": [0, 1], "showFeedbackIcon": true, "marks": 1, "vsetRangePoints": 5, "checkVariableNames": false, "expectedVariableNames": [], "unitTests": [], "prompt": "$\\lfloor \\var{x1}\\rfloor$
", "checkingAccuracy": 0.001}, {"showPreview": true, "customMarkingAlgorithm": "", "variableReplacements": [], "scripts": {"mark": {"order": "instead", "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}"}}, "answer": "{ceil(x1)}", "failureRate": 1, "checkingType": "absdiff", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "jme", "vsetRange": [0, 1], "showFeedbackIcon": true, "marks": 1, "vsetRangePoints": 5, "checkVariableNames": false, "expectedVariableNames": [], "unitTests": [], "prompt": "$\\lceil \\var{x1}\\rceil$
", "checkingAccuracy": 0.001}, {"showPreview": true, "customMarkingAlgorithm": "", "variableReplacements": [{"part": "p1", "must_go_first": false, "variable": ""}], "scripts": {"mark": {"order": "instead", "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}"}}, "answer": "{floor(-x1)}", "failureRate": 1, "checkingType": "absdiff", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "jme", "vsetRange": [0, 1], "showFeedbackIcon": true, "marks": 1, "vsetRangePoints": 5, "checkVariableNames": false, "expectedVariableNames": [], "unitTests": [], "prompt": "$\\lfloor - \\var{x1}\\rfloor$
", "checkingAccuracy": 0.001}, {"showPreview": true, "customMarkingAlgorithm": "", "variableReplacements": [], "scripts": {"mark": {"order": "instead", "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}"}}, "answer": "{ceil(-x1)}", "failureRate": 1, "checkingType": "absdiff", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "jme", "vsetRange": [0, 1], "showFeedbackIcon": true, "marks": 1, "vsetRangePoints": 5, "checkVariableNames": false, "expectedVariableNames": [], "unitTests": [], "prompt": "$\\lceil -\\var{x1}\\rceil$
", "checkingAccuracy": 0.001}], "rulesets": {}, "variables": {"x1": {"templateType": "anything", "definition": "random(1..9)+random(1..9)/10", "description": "", "group": "Ungrouped variables", "name": "x1"}}, "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$.
\nThe floor and ceiling functions are two different ways of rounding a number.
\n