// Numbas version: exam_results_page_options {"name": "Show a block of HTML based on a random value", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {}, "ungrouped_variables": ["a"], "statement": "
This is block ONE
\n
This is block TWO
\n
This is block THREE
\n\n
{showdiv(a)}
\n

Click Try another question like this one to re-randomise the question and see a different block of text.

", "variablesTest": {"maxRuns": 100, "condition": ""}, "tags": ["demo"], "question_groups": [{"name": "", "pickQuestions": 0, "questions": [], "pickingStrategy": "all-ordered"}], "showQuestionGroupNames": false, "parts": [], "variable_groups": [], "variables": {"a": {"name": "a", "description": "", "group": "Ungrouped variables", "definition": "random(1,2,3)", "templateType": "anything"}}, "metadata": {"notes": "

In this question, each possible bit of content is given a unique ID and set to be hidden by default. A custom javascript function shows the relevant content based on the random variable. 

\n

Turn off the rich text editor on the statement to see what's going on.

", "description": "

Update: you can now use the conditional visibility button to do this more easily - see the documentation.

\n

If the statement or advice for your question differs greatly depending on a random variable (for instance, if you're picking from a selection of scenarios), you only want to show content for the relevant scenario.

\n

This question shows one way of doing that.

", "licence": "Creative Commons Attribution 4.0 International"}, "preamble": {"js": "", "css": ""}, "name": "Show a block of HTML based on a random value", "advice": "", "type": "question", "functions": {"showdiv": {"parameters": [["n", "number"]], "language": "javascript", "definition": "//hide all the divs\n$('.choosediv').hide();\n\n//show the one corresponding to the parameter n.\n$('#statement-'+n).show();\n return $('');", "type": "html"}}, "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/"}]}