Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a random quiz question from the Wolfram Knowledgebase
| ResourceFunction["RandomEntityQuestion"][] generates a QuestionObject about a random property of a random Entity. | |
| ResourceFunction["RandomEntityQuestion"][type] generates a QuestionObject about a random property of a random Entity of the specified type. | |
| ResourceFunction["RandomEntityQuestion"][type,prop] generates a QuestionObject about the property prop. | |
| ResourceFunction["RandomEntityQuestion"][EntityProperty[type,prop]] generates a QuestionObject about a property prop of a random Entity of the specified type. | 
| "AnswerProperty" | "Name" | which property is used in the answer choices | 
| "ChoiceCount" | 3 | the number of choices to offer as the answer to the question | 
| "QuestionText" | Automatic | the text to appear as the question prompt | 
| MaxRecursion | 4 | the number of times to seek nonduplicate, nonmissing answers | 
Ask a question about a random capital city from the "Country" Entity data:
| In[1]:= | ![ResourceFunction["RandomEntityQuestion"]["Country", "CapitalCity"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/646b73d9640884fa.png) | 
| Out[1]= |  | 
Ask a question about a random director from the "Movie" Entity data:
| In[2]:= | ![ResourceFunction["RandomEntityQuestion"]["Movie", "Director"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/1a8e55b342d5427c.png) | 
| Out[2]= |  | 
Ask a question about a random aspect of a movie:
| In[3]:= | ![ResourceFunction["RandomEntityQuestion"]["Movie"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/78f0d6bcf6416110.png) | 
| Out[3]= |  | 
Generate a question about any topic known to the Wolfram Knowledgebase:
| In[4]:= | ![ResourceFunction["RandomEntityQuestion"][]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/4acc41f8f28c2c93.png) | 
| Out[4]= |  | 
Generate a random question about dog breeds with images as answer choices:
| In[5]:= | ![ResourceFunction["RandomEntityQuestion"]["DogBreed", "Name", "AnswerProperty" -> "Image"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/6373449cdb0a1d00.png) | 
| Out[5]= |  | 
The Entity type can also be specified with EntityClass or related EntityClass constructors:
| In[6]:= | ![ResourceFunction["RandomEntityQuestion"][
 EntityClass["Mountain", "AtlasMountains"], "Elevation"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/5364b1c43870e036.png) | 
| Out[6]= |  | 
By default, the property value is used in the question prompt and the entity labels are used as the choices:
| In[7]:= | ![ResourceFunction["RandomEntityQuestion"]["Country", "CapitalCity"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/48cb31c356898f94.png) | 
| Out[7]= |  | 
To reverse the format, use the option "AnswerProperty":
| In[8]:= | ![ResourceFunction["RandomEntityQuestion"]["Country", "AnswerProperty" -> "CapitalCity"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/1c163b9640fb41de.png) | 
| Out[8]= |  | 
Use a specific property together with "AnswerProperty" to make questions that do not involve the Entity name:
| In[9]:= | ![ResourceFunction["RandomEntityQuestion"]["Country", "Area", "AnswerProperty" -> "CapitalCity"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/6285f3e358517f11.png) | 
| Out[9]= |  | 
Use "ChoiceCount" to change the number of choices provided:
| In[10]:= | ![ResourceFunction["RandomEntityQuestion"]["Airport", "Countries", "ChoiceCount" -> 6]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/48d8e20ca79188f4.png) | 
| Out[10]= |  | 
Use "QuestionText" to change the prompt:
| In[11]:= | ![ResourceFunction["RandomEntityQuestion"]["Airport", "Countries", "QuestionText" -> "Which of these airports would you find in `QuestionValue`?"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/0c3251bd777636ac.png) | 
| Out[11]= |  | 
If there are insufficient nonduplicate, nonmissing answers found, then RandomEntityQuestion will return $Failed:
| In[12]:= | ![ResourceFunction["RandomEntityQuestion"][
 EntityClass["Country", "Oceania"], "CrimeRate"]](https://www.wolframcloud.com/obj/resourcesystem/images/b1f/b1fa47d3-c59a-431c-9093-08bddf1eef1c/79faa1c147a0b0a0.png) | 
| Out[12]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License