Skip to content

Samagra-Development/quml2xform

Repository files navigation

quml2xform

Description

QuML to ODK form conversion tool written in Nest framework.

Installation

$ yarn install

Running the app

Create .env file (can be copied from .env.example) and configure all the variables as per need & development environment.

Using docker

Simply hit docker-compose up -d, or use manual installation as per below steps:

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

Note: For Manual installation, make sure the python tool is installed system wide: https://github.com/XLSForm/pyxform#running-the-latest-release-of-pyxform. We are using this tool to generate XML from XLSX form using command line utility available from the tool: xls2xform path_to_XLSForm [output_path]

Routes

For Single Request

POST {{url}}/quml-to-odk
{
    "randomQuestionsCount": 5,
    "board": "CBSE",
    "grade": "Class 6",
    "subject": "Mathematics",
    "competency":"Data Handling",
    "qType": "MCQ"
}

For Bulk requests

POST {{url}}/quml-to-odk/bulk
[
    {
        "randomQuestionsCount": 5,
        "board": "CBSE",
        "grade": "Class 6",
        "subject": "Mathematics",
        "competency":"Data Handling",
        "qType": "MCQ"
    },
    ...
]

The params randomQuestionsCount, board, grade, subject, competency can all be sent as per need & the filters will be applied under the hood. qType for now is limited to "MCQ" only.

To generate forms via CSV-JSON

A JSON body generated from the CSV should be passed as per below format:

POST {{url}}/quml-to-odk/via-json?randomQuestionsCount=3&board=State (Haryana)
[
  {
    "Grade": "Class 6",
    "Subject": "English",
    "Question": "How old was Tansen when he went away with Swami Haridas?",
    "option 1": "Twelve years old ",
    "option 2": "Ten years old ",
    "option 3": "Nine years old ",
    "option 4": "Eleven years old ",
    "CorrectAnswer(1/2/3/4)": 2,
    "Competencies": "ENG605 Students can respond to questions by gathering information from notices, charts, diagrams, etc.",
  },
    ...
]

CSV to JSON conversion tool: https://csvjson.com/csv2json

To generate forms via ZIP URLs

A JSON body generated from the CSV should be passed as per the format below:

POST {{url}}/xslx-to-odk/via-json
[
    {
        "url": "http://URL-TO-DOWNLOAD-ZIP",
        "grade": 1,
        "subject": "Hindi"
    },
    ...
]

Form IDs upload on Hasura

  • Ensure the tables competencies & workflow_refids_mapping exists on Hasura DB. Migration files exists at path hasura-migrations/
  • Configure variables HASURA_DUMP_FORMS_MAPPING, HASURA_GRAPHQL_URL & HASURA_ADMIN_SECRET

That's it. Now form IDs mapping will be uploaded on Hasura in the above mentioned tables.

Generated Files

  • XLSX files will be generated at path: ./gen/xlsx
  • XML files will be generated at path: ./gen/xml
  • Image files will be generated at path: ./gen/images

Postman Collection link

https://www.getpostman.com/collections/4b5106be932558e0b96a