Giter Site home page Giter Site logo

quml2xform's Introduction

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

quml2xform's People

Contributors

ajay-maury avatar chakshugautam avatar choxx avatar tushar5526 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

choxx

quml2xform's Issues

Rendering inline HTML

Also Image questions need to be handled separately. Same is the case with formatting. ODK allows markdown based formatting. So html to makrdown conversion needs to happen as well.
https://github.com/Sunbird-Ed/program-service/blob/8dfbf3efb65e886933bb0d788dd5281000d1aa07/src/service/print/pdf.js#L209
https://github.com/Sunbird-Ed/program-service/blob/8dfbf3efb65e886933bb0d788dd5281000d1aa07/src/service/print/pdf.js#L274
This method can be directly used.

I tweaked the first part and am now excluding tags from stripping out: ref

For the second, I'm not sure where exactly & how to use this function


Please also elaborate how to handle media-based questions.

UPDATE (2022-08-10): Image-based questions & other issues have been resolved now. Rest pending is the rendering of inline HTML support in Android phones (which is to be clarified with Android dev separately as discussed)

Upload XML to ODK Service

For the last part of the task, I cannot make it work yet. There are several service files being used for the handler: https://github.com/samagra-comms/uci-apis/blob/8d90af5563d551a6dded5078f9878542788a72f6/v2/uci/src/modules/form/form.service.ts#L65 e.g. TelemetryService.

Shall I include all these files/classes/services in the current module & use them as it is? Are any 3rd party dev credentials required for that?

Also, I'm finding it quite tricky to call the uploadForm() function with the file as the first argument. Could you please share any reference for initializing the object from the raw XML file to be passed into this?

Naming convention & path of the generated XSLX & XML forms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.