Simple Quizz application, one single python file.
http://pascalmolin.pythonanywhere.com
$ python app.py server --allow-register
launches a webserver on localhost:5000
,
with a valid link to generate token.
$ python app.py server --help
Usage: app.py server [OPTIONS]
Options:
--debug turn on Flask debug mode
--verbose log requests
--allow-register provide registration link at index page
--number_questions INTEGER number of questions per quizz
--number_choices INTEGER number of choices per question
--secret_key TEXT secret key
--token_method [none|default] token method
--lang [en|fr] language
--port INTEGER http port
--help Show this message and exit.
flask
itsdangerous
pyqrcode
click
-
for each user an assignment is generated from a list of possible questions. The anwsers are stored.
-
all this is currently handled with a stupid database made of python lists and classes
-
each action (see question, answer it, validate...) must be allowed by a valid token, which contains a signed version of
- quizz id
- user id
- question id
- expiration time
-
a minimal flask setup makes this possible
one yaml file, structured as follows
---
text: This question is
choices:
- { text: "easy", correct: True }
- { text: "impossible" }
- { text: "red" }
tag: [stupid]
(may add fields id, title, image, hints... they are ignored)
- images,...
- sql database
Install the required packages (pip install
)
Edit app.py
and hard-code your settings, and load the question file
manually. For example:
quiz = QuizApp()
quiz.load_questions_yaml('example.yaml')
app = Flask('quiz')
app.config['lang'] = 'en'
app.config['verbose'] = True
app.config['SECRET_KEY'] = '<random>'
app.config['token_method'] = 'none'
app.config['number_questions'] = 8
app.config['number_choices'] = 3
see unbit/uwsgi#1126
for python >= 3.6, configuration wsgi.ini
needs option wsgi-disable-file-wrapper = true