From 56a669b2beba4630cc1b7077a388e1f222110739 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 6 Jan 2021 08:53:06 +0100 Subject: [PATCH] Feat: remove exQty in prompt --- recopytex/scripts/prompts.py | 5 ----- recopytex/scripts/recopytex.py | 11 ++++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/recopytex/scripts/prompts.py b/recopytex/scripts/prompts.py index 370e9f0..180bd98 100644 --- a/recopytex/scripts/prompts.py +++ b/recopytex/scripts/prompts.py @@ -128,11 +128,6 @@ def prompt_exam(**kwrd): validator=Validator.from_callable(lambda x: x.isdigit()), default=kwrd.get("term", "1"), ) - exam["ExQty"] = prompt( - "Nombre d'exercices: ", - validator=Validator.from_callable(lambda x: x.isdigit()), - default=kwrd.get("ExQty", "1"), - ) return exam diff --git a/recopytex/scripts/recopytex.py b/recopytex/scripts/recopytex.py index f6b2f59..caec83c 100644 --- a/recopytex/scripts/recopytex.py +++ b/recopytex/scripts/recopytex.py @@ -7,9 +7,10 @@ import sys import papermill as pm import pandas as pd from datetime import datetime +import yaml from .getconfig import config, CONFIGPATH -from .prompts import prompt_exam, prompt_exercise +from .prompts import prompt_exam, prompt_exercise, prompt_validate from ..config import NO_ST_COLUMNS @@ -57,8 +58,12 @@ def new_exam(): """ Create new exam csv file """ exam = prompt_exam() exam["exercices"] = [] - for ex in range(int(exam["ExQty"])): - exam["exercices"].append(prompt_exercise(ex + 1)) + new_exercise = prompt_validate("Ajouter un exercice? ") + while new_exercise: + exam["exercices"].append(prompt_exercise(len(exam["exercices"])+1)) + new_exercise = prompt_validate("Ajouter un exercice? ") + + print(yaml.dump(exam)) rows = exam_dict2row(exam)