Skip to content
Tomáš Effenberger edited this page Oct 12, 2015 · 19 revisions

Task fixture

Tasks are defined in practice/fixtures/tasks.xml.

Changes can be transferred from the fixture to the DB using make db-load-data command.

Fixture format

<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0">

  <!-- definition of one task -->
  <object model="practice.taskmodel">
    <field type="TextField" name="maze_settings">
    // maze settings in JSON
    </field>
    <field type="TextField" name="workspace_settings">
    // workspace settings in JSON
    </field>
  </object>

  <!-- definition of another task -->
  <object model="practice.taskmodel">
    <field type="TextField" name="maze_settings">
    // maze settings in JSON
    </field>
    <field type="TextField" name="workspace_settings">
    // workspace settings in JSON
    </field>
  </object>

  <!-- ... -->

</django-objects>

Maze settings

{
  "grid": "2D array of square types: 0 = free space, 1 = wall, 2 = goal",
  "hero": {
    "position": "[x, y], indexed from zero",
    "direction": "0 = east, 1 = north, 2 = west, 3 = south"
  }
}

Example:

{
  "grid": [
    [1, 1, 1, 1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1, 1, 1, 1],
    [1, 1, 1, 1, 2, 1, 1, 1],
    [1, 1, 1, 1, 0, 1, 1, 1],
    [1, 0, 0, 0, 0, 1, 1, 1],
    [1, 1, 1, 1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1, 1, 1, 1]],
  "hero": {
    "position": [1, 4],
    "direction": 0
  }
}

Workspace settings

{
  "toolbox": "list of blocks names"
}

Example:

{
  "toolbox": ["maze_move_forward", "maze_turn_left", "maze_turn_right"]
}

Available blocks

  • maze_move_forward
  • maze_move_backward
  • maze_turn_left
  • maze_turn_right
  • maze_check_path_left
  • maze_check_path_right
  • maze_if_then
  • maze_if_then_else

Inspiration for new blocks: blockly maze-game (from Google), code.org

Clone this wiki locally