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)
for question in part.questions:
print(question.question_title)
print(question.text)
for answer in question.answers:
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
### 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.
-
A title must be found
-
title, parts and questions can't have empty string after
#
,##
or###
tag## valid part ## wrong part
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for qcm_parser-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7be8200f8c273ca9ac4e5e7c6b04a7262a3eeb7baec9ea3029a2072f90d92b2 |
|
MD5 | 5de7fad82ca8446af26ded0431474a26 |
|
BLAKE2b-256 | a3e9a6ebc27b8b0eaa282a7b2b9bd064d52986cba1cd93b626332df67e7ffaf6 |