// Numbas version: finer_feedback_settings {"name": "Using a randomly chosen image", "extensions": [], "custom_part_types": [], "resources": [["question-resources/koala.jpg", "/srv/numbas/media/question-resources/koala.jpg"], ["question-resources/panda.jpg", "/srv/numbas/media/question-resources/panda.jpg"], ["question-resources/dogs.jpg", "/srv/numbas/media/question-resources/dogs.jpg"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Using a randomly chosen image", "tags": ["demo", "image"], "metadata": {"description": "

Example of displaying a randomly chosen image.

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

Here's {chosenimage}, chosen at random from {images}.

\n

{image('resources/question-resources/'+chosenimage)}

\n

Or, you can generate an array index, which lets you have a supplementary array giving some more information:

\n

{image('resources/question-resources/'+chosenimage2)}

\n

{facts[index]}

", "advice": "", "rulesets": {}, "extensions": [], "variables": {"facts": {"name": "facts", "group": "Ungrouped variables", "definition": "['Some clever dogs.','A panda.','A koala chilling out in a tree.']", "description": "", "templateType": "anything"}, "index": {"name": "index", "group": "Ungrouped variables", "definition": "random(0..len(images)-1)", "description": "", "templateType": "anything"}, "chosenfact": {"name": "chosenfact", "group": "Ungrouped variables", "definition": "facts[index]", "description": "", "templateType": "anything"}, "chosenimage": {"name": "chosenimage", "group": "Ungrouped variables", "definition": "random(images)", "description": "", "templateType": "anything"}, "chosenimage2": {"name": "chosenimage2", "group": "Ungrouped variables", "definition": "images[index]", "description": "", "templateType": "anything"}, "images": {"name": "images", "group": "Ungrouped variables", "definition": "['dogs.jpg','panda.jpg','koala.jpg']", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["index", "chosenimage2", "chosenimage", "images", "facts", "chosenfact"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "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/"}]}