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.
-
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
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b0aa0ce7719468a0430b17088e86ca0d455bd7c21ad9e151013b004f7a11af1 |
|
MD5 | e56c39a0dd06d248da1b98f811901cd5 |
|
BLAKE2b-256 | 06012780577390dd7ef1eba1ea6d42ac654da12577af157ea1ddc08e2fc5f640 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 130261daa34cfafb0b98ab9a4221bb4eea955449f61e16963038e23907f84bfc |
|
MD5 | f3ca708f298158277afc38f33b7296c8 |
|
BLAKE2b-256 | 75da59f3bc0c30c6ba8d4890c98d1e7ecf49a01ed97522e2330219334f5541b1 |