// Numbas version: exam_results_page_options {"name": "Style a table of sales figures", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Style a table of sales figures", "tags": ["demo"], "metadata": {"description": "

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

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

The FruitCo fruit company's sales figures for 2013 are presented below.

\n
{tab}
", "advice": "

Advice!

", "rulesets": {}, "extensions": ["stats"], "variables": {"sales": {"name": "sales", "group": "Ungrouped variables", "definition": "repeat(random(1000..10000#100),numfruit)", "description": "", "templateType": "anything"}, "numfruit": {"name": "numfruit", "group": "Ungrouped variables", "definition": "4", "description": "", "templateType": "anything"}, "names": {"name": "names", "group": "Ungrouped variables", "definition": "shuffle(\n [\"Banana\",\"Apple\",\"Orange\",\"Mango\",\"Pineapple\"]\n)[0..numfruit]", "description": "", "templateType": "anything"}, "totals": {"name": "totals", "group": "Ungrouped variables", "definition": "map(sales[j]*prices[j],j,0..numfruit-1)", "description": "", "templateType": "anything"}, "tab": {"name": "tab", "group": "Ungrouped variables", "definition": "table(data+[['Total','','',thousandsformat(sum(totals))]],['Fruit','Units sold','Price (\u00a3)','Total (\u00a3)'])", "description": "", "templateType": "anything"}, "data": {"name": "data", "group": "Ungrouped variables", "definition": "map(\n [\nnames[j],\nthousandsformat(sales[j]),\ndpformat(prices[j],2),\nthousandsformat(totals[j])\n ],\n j,\n 0..numfruit-1\n)", "description": "", "templateType": "anything"}, "prices": {"name": "prices", "group": "Ungrouped variables", "definition": "repeat(\n precround(\nrandom(\n random(0.2..0.6#0.01),\n random(1..1.2#0.01)\n),\n 2),\n numfruit\n)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["sales", "numfruit", "totals", "names", "tab", "prices", "data"], "variable_groups": [], "functions": {"thousandsformat": {"parameters": [["n", "number"]], "type": "string", "language": "javascript", "definition": "n = Math.round(n)+'';\nreturn n.replace(/(\\d{1,3}?)(\\d{3})$/,'$1,$2');"}}, "preamble": {"js": "", "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) td {\n background: #eee;\n}\n\n/* number columns in monospace font */\n#sales-table td:not(:first-child) {\n font-family: monospace;\n}\n\n/* style for final totals row */\n#sales-table tr:last-child {\n background: #aaa;\n font-weight: bold;\n border-top: 2px solid black;\n}\n"}, "parts": [], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}