CLI
This module contains the entrypoint to quizli.
We use the typer
package to create a CLI.
For more information see the CLI reference
demo()
¶
start(from_csv=<typer.models.OptionInfo object at 0x7f8c41a142e0>, mode=<typer.models.OptionInfo object at 0x7f8c41a16050>, quiz_name=<typer.models.OptionInfo object at 0x7f8c41a17790>, randomize=<typer.models.OptionInfo object at 0x7f8c41a16170>)
¶
Start the quiz with the configuration of your choice.
Select Quiz Content¶
There are 2 ways to create a quiz with quizli
:
- From a csv file containing question-answer pairs: e.g.
quizli start --from-csv examples/quiz.csv
- From a function in the
example
module: e.g.quizli start --quiz-name python_quiz
Select Quiz Settings¶
You can choose to
-
Shuffle the quiz with the
--randomize
flag (default), or keep it--in-order
. -
Terminate the quiz with the first wrong answer with
mode=sudden_death
, or continue on failure withmode=complete
(default).
Source code in quizli/main.py
@app.command()
def start(
from_csv: Optional[Path] = typer.Option(
None, exists=True, help="Read a quiz from a csv-file"
),
mode: QuizMode = typer.Option(
QuizMode.COMPLETE,
help="Select the condition for the quiz to end",
),
quiz_name: QuizKind = typer.Option(
QuizKind.PYTHON_QUIZ, help="Select a built-in quiz"
),
randomize: bool = typer.Option(
True,
"--randomize/--in-order",
help="Shuffle the quiz before starting it",
),
):
# {==(4)==} The docstring below will automatically be inserted into the help message
# and can be shown with `quizli start --help`. The same is true for the help
# strings we defined above for the parameters of the `start` function.
"""
Start the quiz with the configuration of your choice.
### Select Quiz Content
There are 2 ways to create a quiz with `quizli`:
1. From a csv file containing question-answer pairs: e.g. `quizli start --from-csv examples/quiz.csv`
2. From a function in the `example` module: e.g. `quizli start --quiz-name python_quiz`
### Select Quiz Settings
You can choose to
- Shuffle the quiz with the `--randomize` flag (default), or keep it `--in-order`.
- Terminate the quiz with the first wrong answer with `mode=sudden_death`, or continue on failure with `mode=complete` (default).
"""
config = QuizConfig(mode=mode, randomize=randomize)
if from_csv is not None:
quiz = Quiz.from_csv(Path(from_csv))
else:
quiz = getattr(examples, quiz_name)()
quiz_session = QuizSession(quiz, config)
quiz_session.start()
Last update:
March 11, 2022