Table of Contents

Importing Game from JSON

Import Tools

Importing a game or its components from its JSON can be done in several ways:

  1. In the game editor, click “Paste tasks from the clipboard…“ under the task list. This is the everyday way: the editor parses the JSON, shows what it found in it, and adds what you pick to the draft — it travels to the server after “Save…”. More on it: The JSON of a task and of a game.
  2. Paste the desired JSON object on the page https://qeng.org/import_tasks.php, specify the game ID, and click Import. This link is also available from the “Import tasks” item in the “Useful links” tab of the editor.
  3. On a task card, click the “JSON” button in its header and paste the JSON of one level there. This allows you to quickly update the settings, codes, bonuses, and hints of a specific level.
  4. (for developers) Send a POST request to `https://qeng.org/import_tasks.php?gid=<your game ID>&json=1` with a correctly formatted JSON object in the request body. For authentication, you need to retain the cookie from the authorization request, which is described in detail here: Embedding the engine into other services

Objects for Import

Each object that can be imported can be exported to retrieve its structure in the current game, as described in the export instructions section.

Uploading New Levels

If you need to add NEW levels to the game, the JSON should be a list of one or more levels, separated by commas. For the level to be added (rather than updating an existing one), it must NOT have a `number` field inside the `task` settings section. A description of the level structure can be found here.

Editing Existing Levels

If you need to update EXISTING levels in the game, the JSON should be a list of one or more levels, separated by commas, and the `number` field in the `task` settings section must be passed (corresponding to the level number being edited). A description of the level structure can be found here.

If present in the JSON, game settings from the `task` section will replace the existing values in the engine. If fields are omitted from the provided JSON, they will remain as they were.

For other sections (`codes`, `bonuses`, `hints`), if the section is present in the JSON, it will completely replace the existing one. If omitted, the section remains unchanged.

A level can be found by more than its number: pass the level id in the task section (an export with ids=1 hands it out) and exactly that level is updated, even when you are changing its number at the same time. If the game has no level with that id, the import fails instead of creating a new one.

To change single codes, bonuses or hints without resending the whole list, see the *_edit sections.

Uploading the Entire Game

It is possible to upload the entire game from a JSON object. For this, the JSON must be a complete game JSON, as described on the JSON structure description page. Additionally, you must add the field "delete_all_tasks": 1 to the JSON to delete all existing levels and reload the game from scratch, for example:

{
    "game": {
        "name": "#New Unnamed Game 2",
    },
    "tasks": [{"task": {"number": 1, "working_name": "Title"}, "codes": [], "bonuses": [], "hints": []}],
    "gbonuses": [],
    "lines": [],
    "delete_all_tasks": 1,
}

If present in the JSON, game settings from the `game` section will replace the existing values in the engine. If fields are omitted from the provided JSON, they will remain as they were in the game before.

For other sections (`gbonuses`, `lines`), if the section is present in the JSON, it will completely replace the existing one. If omitted, the section remains unchanged.

Editing single items

The codes, bonuses, hints, gbonuses and tasks sections replace a whole list. That is convenient when you build a game from scratch, but it means resending a whole level because of one changed code.

Next to each of those sections there is an “editing” one: codes_edit, bonuses_edit, hints_edit, gbonuses_edit, tasks_edit. It lists only the items you are changing:

{
    "tasks_edit": [
        {
            "task": {"id": 123, "working_name": "New title"},
            /* only the title changes - the task text does not have to travel */
            "codes_edit": [
                {"id": 56, "delete": 1},
                /* this code is removed */
                {"id": 55, "code": "abc"},
                /* only the code field of this one changes */
                {"code": "new code"}
                /* and this one is appended to the list */
            ]
        }
    ]
}

The rules:

Naming both codes and codes_edit for one list is refused: the second one would edit items the first one has just thrown away.

Deleting a level

A level is deleted through tasks_edit:

{
    "tasks_edit": [
        {"task": {"id": 123}, "delete": 1},
        {"task": {"id": 124, "number": 1}}
        /* and, for instance, move the next level into the freed number */
    ]
}

The level takes its codes, bonuses, hints and the teams' answers with it - which is why deleting a level is not allowed in a game that has already started. To delete every level at once, use "delete_all_tasks": 1 (see above).

Level numbers are left alone: the lines refer to them, so after a deletion you decide yourself how to renumber the rest, in the same request.

Errors

Uploading Game Settings

You only need to pass the game settings structure in the JSON, as described on the JSON structure page.

Uploading Global Bonuses

You only need to pass the global bonuses structure in the JSON, as described on the JSON structure page.

Uploading Lines

You only need to pass the global bonuses structure in the JSON, as described on the JSON structure page.

Using AI (chatbots) to Create and Edit Levels

Modern chatbots (ChatGPT, Claude, Gemini, etc.) do an excellent job of generating and editing levels, codes, hints, and bonuses in JSON format for the qeng.org engine.

You can find the ready-to-use system prompt for chatbot configuration in the section: Using AI to create tasks.