WEEE-Open / skeeelled

An e-learning platform for the modern age
https://weee-open.github.io/skeeelled
6 stars 7 forks source link

Add API to upload MoodleXML file #34

Open e-caste opened 2 years ago

e-caste commented 2 years ago

POST /v1/uploadQuestionsFile

Request body:

{
  "user": {"id": "dXXX", "otherdata": ...},
  "isExamSimulation": bool,  // from frontend checkbox
  "file": {"type": "moodlexml", "contents": file xml as string}
}
  1. check authorization (user is teacher, user is teacher of that course)
  2. convert XML to JSON
  3. for each question block in the JSON load it into DB questions table (with loadedByUser, exam tag, official tag (if uploaded by teacher, for now always true), course, incremental ID for each question, quiz ID (quiz is a set of questions uploaded with the same file))

Needed models: Quiz, Question