Skip to main content

A parser of QCM file

Project description

QCM parser

It's a basic and quite strict QCM (Multiple Choices Questions) parser.

It parses a file .md file into Python objects. That's all.

There's no rendering, no export. It must be done separetaly.

Installation

It requires python>=3.7 and markdown package.

$ pip install qcm_parser

Usage

In your script :

from qcm_parser.parser import ParseQCM

qcm = ParseQCM.from_file("my_qcm_file.md")

print(qcm)

Will display your QCM as a text.

In memory, you qcm object is represented as a tree which holds parts.

Those parts holds questions, holding answers.

It is then easy to navigate through it like this :

print(qcm.title)
for part in qcm.parts:
    print(part.title)
    print(part.text)
    for question in part.questions:
        print(question.title)
        print(question.text)
        for answer in question.title:
            print(answer.answer)

Modes

There's 2 modes :

  • for web export (qcm_part.from_file(filename, mode="web")), the default one, mode named parameter can be ommitted.
  • for pdf export (qcm_part.from_file(filename, mode="pdf")).

The mode=web should be used if you want to serve a QCM like I do here

It replaces markdown syntax with html syntax using markdown module.

The mode=pdf can be used to create a randomized QCM in a .md file, then to export it with pandoc.

QCM file description

Files should be utf-8 encoded text files with .md extensions.

They should respect the example format :

# title

## part

the text of the part

### question with multiple choices

optional sub text. Can contains code, latex, whatever

- [x] right answer
- [ ] wrong answer a
- [ ] wrong answer b

### question with text allowed

- [t]

Known limitations

Only a little subset of markdown is supported.

  1. A title must be found

  2. title, parts and questions can't have empty string after #, ## or ### tag

    ## valid part
    
    ##
    wrong part
    
  3. Code blocks with triple backticks are supported not ~~~. Those will creates bugs.

    # title
    
    ## part
    
    ### question
    
    ```python
    # comment
    def f():
        return 1
    ```
    

    is valid.

    but :

    # title
    
    ## part
    
    ### question
    
    ```python
    # comment
    def f():
        return 1
    ```
    
    
    **is not valid.**
    
    The `# comment` line will be interpreted as a new title etc.
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qcm_parser-0.1.5.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

qcm_parser-0.1.5-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file qcm_parser-0.1.5.tar.gz.

File metadata

  • Download URL: qcm_parser-0.1.5.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for qcm_parser-0.1.5.tar.gz
Algorithm Hash digest
SHA256 7b0aa0ce7719468a0430b17088e86ca0d455bd7c21ad9e151013b004f7a11af1
MD5 e56c39a0dd06d248da1b98f811901cd5
BLAKE2b-256 06012780577390dd7ef1eba1ea6d42ac654da12577af157ea1ddc08e2fc5f640

See more details on using hashes here.

File details

Details for the file qcm_parser-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: qcm_parser-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for qcm_parser-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 130261daa34cfafb0b98ab9a4221bb4eea955449f61e16963038e23907f84bfc
MD5 f3ca708f298158277afc38f33b7296c8
BLAKE2b-256 75da59f3bc0c30c6ba8d4890c98d1e7ecf49a01ed97522e2330219334f5541b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page