Skip to content

Gridimage content format

Daniel Gerhardt requested to merge gridimage-content-format into master

The model of grid image contents has been overhauled to store data more efficient. Fields are now represented as a single index int value instead of a semicolon separated String. Instead of storing all selectable fields (up to 256!) now only the correct ones are stored. Answers for GridImageContents are stored as ChoiceAnswers.

Further changes

  • Field size instead of scale factor and zoom level for grid
  • Normalized values for offsets and field size
  • A single scale factor value for the image
  • Rotation in degrees
  • Removed coloring settings

With this MR the last missing content format and overall the last missing entity type of v2 is added. Data of all v2 entity types can be migrated. The v2 endpoint behavior intentionally differs slightly from the original API in that it filters possibleAnswers so it only includes correct options.

Example to showcase differences between the v3 model and the original v2 model

v3

{
  "format": "GRID",
  "id": "c11593179048aecd5cd9d0c119001ff7",
  "roomId": "c11593179048aecd5cd9d0c1190013d6",
  "subject": "Grid Example",
  "body": "Some description",
  "abstentionsAllowed": true,
  "state": {
    "round": 1,
    "visible": true,
    "additionalTextVisible": true,
    "responsesEnabled": true,
    "responsesVisible": false
  },
  "extensions": {
    "v2": {
      "gridImageAbsoluteX": -19,
      "gridType": "image",
      "gridImageAbsoluteY": -19
    }
  },
  "grid": {
    "columns": 16,
    "rows": 16,
    "normalizedX": 0.01,
    "normalizedY": 0.01,
    "normalizedFieldSize": 0.051418904674492616,
    "visible": true
  },
  "image": {
    "url": "https://...",
    "normalizedX": 0,
    "normalizedY": 0,
    "scaleFactor": 1.2155062500000002,
    "rotation": 90
  },
  "correctOptionIndexes": [
    72,
    120,
    75,
    123
  ],
  "revision": "6-8e86820d0a14d4746777a438fa2d9531"
}

v2

{
  "type": "skill_question",
  "questionType": "grid",
  "questionVariant": "lecture",
  "subject": "Grid Example",
  "text": "Some description",
  "active": true,
  "releasedFor": "all",
  "possibleAnswers": [
    {
      "id": "",
      "text": "0;0",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "0;1",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "0;2",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "0;3",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "0;4",
      "correct": false,
      "value": -10
    },

    /*********************
     *****    ...    *****
     *********************/

    {
      "id": "",
      "text": "15;11",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "15;12",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "15;13",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "15;14",
      "correct": false,
      "value": -10
    },
    {
      "id": "",
      "text": "15;15",
      "correct": false,
      "value": -10
    }
  ],
  "noCorrect": false,
  "sessionId": "35ec1f34bb88cfee0522c02d8c6a25fa",
  "sessionKeyword": "41386431",
  "timestamp": 1570350417,
  "number": 0,
  "duration": 0,
  "piRound": 1,
  "piRoundEndTime": 0,
  "piRoundStartTime": 0,
  "piRoundFinished": false,
  "piRoundActive": false,
  "votingDisabled": false,
  "showStatistic": true,
  "showAnswer": false,
  "abstention": true,
  "ignoreCaseSensitive": false,
  "ignoreWhitespaces": false,
  "ignorePunctuation": false,
  "fixedAnswer": false,
  "strictMode": false,
  "rating": 0,
  "correctAnswer": "",
  "_id": "35ec1f34bb88cfee0522c02d8c6a391e",
  "_rev": "3-d1e0a5c77136d9b734b37228a103cf70",
  "image": "https://...",
  "fcImage": null,
  "gridSize": 16,
  "offsetX": -19,
  "offsetY": -19,
  "zoomLvl": 4,
  "gridOffsetX": 4,
  "gridOffsetY": 4,
  "gridZoomLvl": -4,
  "gridSizeX": 16,
  "gridSizeY": 16,
  "gridIsHidden": false,
  "imgRotation": 1,
  "toggleFieldsLeft": false,
  "numClickableFields": 0,
  "thresholdCorrectAnswers": 0,
  "cvIsColored": false,
  "gridLineColor": "#4a5c66",
  "numberOfDots": 0,
  "gridType": "image",
  "scaleFactor": "1.05",
  "gridScaleFactor": "1.05",
  "imageQuestion": false,
  "textAnswerEnabled": false,
  "hint": null,
  "solution": null,
  "session": "35ec1f34bb88cfee0522c02d8c6a25fa"
}
Edited by Daniel Gerhardt

Merge request reports