rw-moore / SciLO

GNU General Public License v3.0
0 stars 0 forks source link

Fix: json structure of creating question #44

Closed haotianzhu closed 5 years ago

haotianzhu commented 5 years ago

Check List

Comment

REQUEST

{
  "title": "Mock Question 2",
  "text": "Some interesting multiple choice questions.",
  "tags": [
    {
      "name": "fun"
    },
    {
      "name": "color"
    }
  ],
  "responses": [
    {
      "name": "r1",
      "type": {
        "name": "multiple",
        "single": true,
        "dropdown": false
      },
      "text": "Select 'Red'",
      "answers": [
        {
          "text": "Blue",
          "grade": 0
        },
        {
          "text": "Red",
          "grade": 100
        },
        {
          "text": "red",
          "grade": 50
        }
      ]
    },
    {
      "name": "r2",
      "type": {
        "name": "multiple",
        "single": false,
        "dropdown": false
      },
      "text": "Select red color",
      "answers": [
        {
          "text": "Blue",
          "grade": -50
        },
        {
          "text": "Red",
          "grade": 50
        },
        {
          "text": "red",
          "grade": 50
        }
      ]
    },
    {
      "name": "r3",
      "type": {
        "name": "multiple",
        "single": false,
        "dropdown": true
      },
      "text": "Select red color",
      "answers": [
        {
          "text": "Blue",
          "grade": -50
        },
        {
          "text": "Red",
          "grade": 50
        },
        {
          "text": "red",
          "grade": 50
        }
      ]
    }
  ]
}

RESPONSE

{
  "status": "success",
  "question": {
    "id": 34,
    "tags": [
      {
        "id": 6,
        "name": "fun"
      },
      {
        "id": 7,
        "name": "color"
      }
    ],
    "title": "Mock Question 2",
    "text": "Some interesting multiple choice questions.",
    "weight": 100,
    "create_date": "2019-05-28T02:30:53.502501Z",
    "last_modify_date": "2019-05-28T02:30:53.502515Z",
    "author": null,
    "quizzes": [],
    "responses": [
      {
        "id": 70,
        "answers": [
          {
            "text": "red",
            "grade": 50.0,
            "comment": null
          },
          {
            "text": "Red",
            "grade": 100.0,
            "comment": null
          },
          {
            "text": "Blue",
            "grade": 0.0,
            "comment": null
          }
        ],
        "name": "r1",
        "text": "Select 'Red'",
        "weight": 100,
        "algorithm": {
          "ignore_case": false,
          "__alg_type__": "string"
        },
        "grade_policy": {
          "penalty_per_try": 0,
          "penalty_type": "int",
          "max_tries": 3,
          "policy": "average"
        },
        "question": 34,
        "type": {
          "single": true,
          "dropdown": false,
          "name": "string"
        }
      },
      {
        "id": 71,
        "answers": [
          {
            "text": "red",
            "grade": 50.0,
            "comment": null
          },
          {
            "text": "Red",
            "grade": 50.0,
            "comment": null
          },
          {
            "text": "Blue",
            "grade": -50.0,
            "comment": null
          }
        ],
        "name": "r2",
        "text": "Select red color",
        "weight": 100,
        "algorithm": {
          "ignore_case": false,
          "__alg_type__": "string"
        },
        "grade_policy": {
          "penalty_per_try": 0,
          "penalty_type": "int",
          "max_tries": 3,
          "policy": "average"
        },
        "question": 34,
        "type": {
          "single": false,
          "dropdown": false,
          "name": "string"
        }
      },
      {
        "id": 72,
        "answers": [
          {
            "text": "red",
            "grade": 50.0,
            "comment": null
          },
          {
            "text": "Red",
            "grade": 50.0,
            "comment": null
          },
          {
            "text": "Blue",
            "grade": -50.0,
            "comment": null
          }
        ],
        "name": "r3",
        "text": "Select red color",
        "weight": 100,
        "algorithm": {
          "ignore_case": false,
          "__alg_type__": "string"
        },
        "grade_policy": {
          "penalty_per_try": 0,
          "penalty_type": "int",
          "max_tries": 3,
          "policy": "average"
        },
        "question": 34,
        "type": {
          "single": false,
          "dropdown": true,
          "name": "string"
        }
      }
    ]
  }
}

Put 'closes #.' in your comment to auto-close the issue that your PR fixes (if such).

closes #45

haotianzhu commented 5 years ago

I keep using rtype in the backend while I write middleware to convert rtype into type

haotianzhu commented 5 years ago

For the algorithm part and grade policy, I will make it more readable after @TianqiCS finish those two front Ul.

haotianzhu commented 5 years ago

important @TianqiCS The name for response is required since a pair of id and name is unique in the backend.

haotianzhu commented 5 years ago

Bug #45

haotianzhu commented 5 years ago

Fix #45 @d9bfcf0