// Numbas version: exam_results_page_options {"name": "Ed's copy of 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": [{"showQuestionGroupNames": false, "rulesets": {}, "advice": "", "ungrouped_variables": ["index", "chosenimage2", "chosenimage", "images", "facts", "chosenfact"], "variable_groups": [], "parts": [], "metadata": {"notes": "

The images are uploaded through the Resources tab, which lists their URLs. They're embedded in the page using the image function.

", "description": "

Example of displaying a randomly chosen image.

", "licence": "Creative Commons Attribution 4.0 International"}, "name": "Ed's copy of Using a randomly chosen image", "tags": ["demo", "image"], "preamble": {"css": "", "js": ""}, "functions": {}, "type": "question", "variablesTest": {"maxRuns": 100, "condition": ""}, "question_groups": [{"name": "", "pickQuestions": 0, "pickingStrategy": "all-ordered", "questions": []}], "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]}

", "variables": {"chosenimage2": {"name": "chosenimage2", "definition": "images[index]", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "chosenfact": {"name": "chosenfact", "definition": "facts[index]", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "index": {"name": "index", "definition": "random(0..len(images)-1)", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "images": {"name": "images", "definition": "['dogs.jpg','panda.jpg','koala.jpg']", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "chosenimage": {"name": "chosenimage", "definition": "random(images)", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "facts": {"name": "facts", "definition": "['Some clever dogs.','A panda.','A koala chilling out in a tree.']", "description": "", "templateType": "anything", "group": "Ungrouped variables"}}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Ed Stewart", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3232/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Ed Stewart", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3232/"}]}