// Numbas version: finer_feedback_settings {"name": "Use the Tyne and Wear Metro API", "extensions": ["programming"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "feedback": {"showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "allowrevealanswer": true, "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview"}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Use the Tyne and Wear Metro API", "tags": [], "metadata": {"description": "

Shows how to fetch data from an external API and use it in question variables.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "extensions": ["programming"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"train_data": {"name": "train_data", "group": "Train data", "definition": "fetch_json(api_url)", "description": "", "templateType": "anything", "can_override": false}, "trains": {"name": "trains", "group": "Train data", "definition": "train_data[\"trains\"]", "description": "", "templateType": "anything", "can_override": false}, "num_trains": {"name": "num_trains", "group": "Train data", "definition": "len(trains)", "description": "", "templateType": "anything", "can_override": false}, "last_events": {"name": "last_events", "group": "Train data", "definition": "t[\"status\"][\"timesAPI\"][\"lastEvent\"][\"type\"] for: t of: values(trains)", "description": "", "templateType": "anything", "can_override": false}, "num_arriving": {"name": "num_arriving", "group": "Train data", "definition": "len(x for: x of: last_events where: x = status)", "description": "

The number of trains that have just arrived at a station.

", "templateType": "anything", "can_override": false}, "train_table": {"name": "train_table", "group": "Train data", "definition": "table(\n [number, d[\"status\"][\"timesAPI\"][\"lastEvent\"][\"type\"], d[\"status\"][\"timesAPI\"][\"lastEvent\"][\"location\"]] for: [number, d] of: items(trains),\n [\"Train\", \"Status\", \"Location\"]\n)", "description": "", "templateType": "anything", "can_override": false}, "api_url": {"name": "api_url", "group": "Ungrouped variables", "definition": "\"https://metro.hopperelec.co.uk/api/trains\"", "description": "", "templateType": "anything", "can_override": false}, "possible_statuses": {"name": "possible_statuses", "group": "Train data", "definition": "[ \"ARRIVED\", \"DEPARTED\", \"APPROACHING\" ]", "description": "", "templateType": "list of strings", "can_override": false}, "status": {"name": "status", "group": "Train data", "definition": "random(possible_statuses)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["api_url"], "variable_groups": [{"name": "Train data", "variables": ["train_data", "trains", "num_trains", "last_events", "possible_statuses", "status", "num_arriving", "train_table"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

The table below displays the status of every train on the Tyne and Wear Metro network.

\n

This data was loaded from {api_url} when this question was generated.

\n

{train_table}

"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

How many trains are currently on the network?

", "minValue": "num_trains", "maxValue": "num_trains", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

How many trains have the status {status}?

", "minValue": "num_arriving", "maxValue": "num_arriving", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "adaptiveMarkingUseCondition": "", "adaptiveMarkingNotUsedMessage": "", "exploreObjective": null, "prompt": "

Click \"Try another question like this one\" to try again with the most recent data.

"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "showAllParts": false, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Christian Lawson-Perfect", "profile_url": "http://clppc.local:8000/accounts/profile/1/"}], "resources": []}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Christian Lawson-Perfect", "profile_url": "http://clppc.local:8000/accounts/profile/1/"}]}