---
jupytext:
    formats: md:myst
    text_representation:
        extension: .md
        format_name: myst
kernelspec:
    display_name: Python 3 (ipykernel)
    language: python
    name: python3
---

(world-structure-manipulation-quiz)=
# World Structure Manipulation Quiz

This page provides a self-check quiz for the tutorial: [](world-structure-manipulation).  
Source: Jupyter quiz. $ $

% NOTE: The lone `$ $` above ensures some math is rendered before the quiz,
% which fixes a known math-rendering quirk inside the quiz widget.

```{code-cell} ipython3
:tags: [remove-input]
from jupyterquiz import display_quiz

questions = [
    {
      "question": "What context is required when changing the world (e.g., adding bodies or connections)?",
      "type": "multiple_choice",
      "answers": [
        {"answer": "with world.modify_world():", "correct": True},
        {"answer": "with world.lock():", "correct": False},
        {"answer": "world.begin(); ...; world.end();", "correct": False},
        {"answer": "No special context is required", "correct": False}
      ],
    },
    {
      "question": "Which of the following is a valid structural entity to add/remove?",
      "type": "multiple_select",
      "answers": [
        {"answer": "Body", "correct": True},
        {"answer": "Connection", "correct": True},
        {"answer": "DegreeOfFreedom", "correct": True},
        {"answer": "RayTracer", "correct": False}
      ],
    },
    {
      "question": "How to handle DoFs when creating connections, for example a RevoluteConnection?",
      "type": "many_choice",
      "answer_cols": 2,
      "answers": [
        {"answer": "Add the DoF to the world, then reference it in RevoluteConnection", "correct": True},
        {"answer": "If you create RevoluteConnection without a DoF and add it to a world, a DoF is autogenerated", "correct": True},
        {"answer": "Set world.state['joint'] = 0 and it is created", "correct": False},
        {"answer": "Use FixedConnection with a DoF", "correct": False}
      ],
    },
    {
      "question": "What happens when removing a RevoluteConnection whose DoF is unused elsewhere?",
      "type": "multiple_choice",
      "answers": [
        {"answer": "Its DoF is removed as well", "correct": True},
        {"answer": "The DoF persists forever", "correct": False},
        {"answer": "All DoFs are cleared", "correct": False},
        {"answer": "World validation is skipped", "correct": False}
      ],
    },
    {
      "question": "What is the kinematic structure required to be?",
      "type": "multiple_choice",
      "answers": [
        {"answer": "A tree", "correct": True},
        {"answer": "A cyclic graph", "correct": False},
        {"answer": "A lattice", "correct": False},
        {"answer": "A complete graph", "correct": False}
      ],
    },
        {
      "question": "Why must structural changes be grouped inside with world.modify_world():?",
      "type": "many_choice",
      "answer_cols": 2,
      "answers": [
        {"answer": "To ensure world validity is checked after the block", "correct": True},
        {"answer": "To enable GPU acceleration", "correct": False},
        {"answer": "To auto-serialize the world", "correct": False},
        {"answer": "To group together world updates, to prevent invalid model states", "correct": True}
      ],
    }
]

import json
json_str = json.dumps(questions)
json.loads(json_str) 

display_quiz(questions)
```
