Question bulk import resources

Upload question import file

Allows to upload and validate a question bulk import file. No questions or solutions are written to the database.

Uploads MUST be performed using the multipart/form-data Content-Type.

Only the Starmind question bulk import file is supported.

Due to the heavy memory usage of the .xslx parser, you should not try to import more than 1000 questions in one file.

POST /import/questions/upload
Parameter Type Default Required Description
file file The question bulk import file

Response

The request will return immediately while the actual validation is running async in the background where an import process of "type" validation will be triggered.

{
  "import_id": 45,
  "user_id": 1,
  "file_name": "question_starmind.xlsx"
}

If no validation errors occurred, the file is persisted within Starmind (import_id) and ready for being imported.


Import question import file

PUT /import/questions/:ID

Triggers the import of the question bulk import file. This will create the actual questions or solutions in the database. Updating existing content is not supported. :ID correlates with the "import_id" returned from the uploaded response.

Response

The request will return immediately while the actual import is running async in the background where an import process of "type" import will be triggered.

{
  "import_id": 43,
  "user_id": 1,
  "file_name": "question_starmind.xlsx"
}

Check process status

Since the validation / import is executed async, the process status must be checked before proceeding to the next step. The :ID correlates with the "import_id" returned from the upload / import response.

GET /import/questions/:ID/status

Returns the current state of a validation / import process.

The process "status" field can have following values:

"success", "processing", "error"

The process "type" field can have following values:

"validation", "import"

So, per import two import processes will be created.

Response

Example for a successful xlsx import.

[
  {
    "start_date": "2016-04-19T08:19:48.000Z",
    "result": {
      "import_id": 44,
      "user_id": 1,
      "file_name": "prefilling_questions.xlsx",
      "errors": []
    },
    "end_date": "2016-04-19T08:19:51.000Z",
    "status": "success",
    "import_id": 44,
    "type": "import"
  },
  {
    "start_date": "2016-04-19T08:17:56.000Z",
    "result": {
      "import_id": 44,
      "user_id": 1,
      "file_name": "prefilling_questions.xlsx",
      "errors": []
    },
    "end_date": "2016-04-19T08:19:02.000Z",
    "status": "success",
    "import_id": 44,
    "type": "validation"
  }
]

Example for a failed xlsx validation.

[
  {
    "start_date": "2016-04-19T08:51:52.000Z",
    "result": {
      "import_id": 43,
      "user_id": 1,
      "file_name": "question_starmind.xlsx",
      "errors": [
                  {
                    "msg": "Value 'a' is invalid!",
                    "metadata": "Who is Sherlock?",
                    "row": 3,
                    "field": "Language"
                  },
                  {
                    "msg": "must not be empty",
                    "metadata": null,
                    "row": 4,
                    "field": "question.title"
                  },
                  {
                    "msg": "A user with email 'questioner@starmind.com' doesn't exist",
                    "metadata": "Who is Sherlock?",
                    "row": 5,
                    "field": "Questioner Email"
                  },
                  {
                    "msg": "requirement failed: Tag length must be between 2 and 255 characters.",
                    "metadata": "Who is Sherlock?",
                    "row": 5,
                    "field": "Keyword (required)"
                  }
                ]
        },
      "end_date": "2016-04-19T08:51:53.000Z",
      "status": "error",
      "import_id": 43,
      "type": "validation"
  }
]

List process states

List all question validation / import process states.

GET /import/questions/status
[
  {
    "start_date": "2016-04-19T08:19:48.000Z",
    "result": {
      "import_id": 44,
      "user_id": 1,
      "file_name": "prefilling_questions.xlsx",
      "errors": []
    },
    "end_date": "2016-04-19T08:19:51.000Z",
    "status": "success",
    "import_id": 44,
    "type": "import"
  },
  {
    "start_date": "2016-04-19T08:17:56.000Z",
    "result": {
      "import_id": 44,
      "user_id": 1,
      "file_name": "prefilling_questions.xlsx",
      "errors": []
    },
    "end_date": "2016-04-19T08:19:02.000Z",
    "status": "success",
    "import_id": 44,
    "type": "validation"
  },
  {
    "start_date": "2016-04-19T08:51:52.000Z",
    "result": {
    "import_id": 43,
    "user_id": 1,
    "file_name": "question_starmind.xlsx",
    "errors": [
                {
                  "msg": "Value 'a' is invalid!",
                  "metadata": "Who is Sherlock?",
                  "row": 3,
                  "field": "Language"
                },
                {
                  "msg": "must not be empty",
                  "metadata": null,
                  "row": 4,
                  "field": "question.title"
                },
                {
                  "msg": "A user with email 'questioner@starmind.com' doesn't exist",
                  "metadata": "Who is Sherlock?",
                  "row": 5,
                  "field": "Questioner Email"
                },
                {
                  "msg": "requirement failed: Tag length must be between 2 and 255 characters.",
                  "metadata": "Who is Sherlock?",
                  "row": 5,
                  "field": "Keyword (required)"
                }
              ]
      },
    "end_date": "2016-04-19T08:51:53.000Z",
    "status": "error",
    "import_id": 43,
    "type": "validation"
    }
]