// Numbas version: finer_feedback_settings {"name": "Discounted prices", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

A randomised table is contained in a div tag with the id #sales-table, so it can be styled using the CSS preamble.

"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"tab": {"group": "Ungrouped variables", "templateType": "anything", "name": "tab", "definition": "table(data+[['Total','','',dpformat(sum(new_price),2)]],['Item','Previous','Discount','New Price'])", "description": ""}, "discount": {"group": "Ungrouped variables", "templateType": "anything", "name": "discount", "definition": "repeat(random(5..50#1),numitems)", "description": ""}, "previous_price": {"group": "Ungrouped variables", "templateType": "anything", "name": "previous_price", "definition": "repeat(\n precround(\n random(\n random(0.2..0.6#0.01),\n random(1..1.2#0.01)\n ),\n 2),\n numitems\n )", "description": ""}, "names": {"group": "Ungrouped variables", "templateType": "anything", "name": "names", "definition": "shuffle(\n [\"ZX Giant\",\"ZX Budget\",\"Bugsy Bear\",\"Champion\",\"Frenzy\",\"Go-Cart\",\"rocket\"]\n)[0..numitems]", "description": ""}, "data": {"group": "Ungrouped variables", "templateType": "anything", "name": "data", "definition": "map(\n [\nnames[j],\ndpformat(previous_price[j],2),\nthousandsformat(discount[j]),\ndpformat(new_price[j],2)\n ],\n j,\n 0..numitems-1\n)", "description": ""}, "numitems": {"group": "Ungrouped variables", "templateType": "anything", "name": "numitems", "definition": "6", "description": ""}, "new_price": {"group": "Ungrouped variables", "templateType": "anything", "name": "new_price", "definition": "map(previous_price[j]-(previous_price[j]*discount[j]/100),j,0..numitems-1)", "description": ""}}, "rulesets": {}, "variable_groups": [], "extensions": ["stats"], "name": "Discounted prices", "statement": "

The Greenslate Discounted Price List for 2018 is below

\n
{tab}
", "ungrouped_variables": ["previous_price", "numitems", "new_price", "names", "tab", "data", "discount"], "parts": [], "tags": [], "advice": "

Advice!

", "functions": {"thousandsformat": {"type": "string", "definition": "n = Math.round(n)+'';\nreturn n.replace(/(\\d{1,3}?)(\\d{3})$/,'$1,$2');", "parameters": [["n", "number"]], "language": "javascript"}}, "preamble": {"css": "/* left-align fruit names */\n#sales-table td:first-child, #sales-table:first-child th {\n text-align: left;\n}\n\n/* rows alternate background colour so they're easier to read */\n#sales-table tr:nth-child(even) {\n background: #eee;\n}\n\n/* number columns in monospace font */\n#sales-table td:not(:first-child) {\nfont-family: monospace;\n}\n\n/* style for final totals row */\n#sales-table tr:last-child {\nbackground: #aaa;\nfont-weight: bold;\nborder-top: 2px solid black;\n}\n", "js": ""}, "type": "question", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Colin Whitehead", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2486/"}], "resources": []}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Colin Whitehead", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2486/"}]}