Feat: Prepare prompt to creat new csv score file
This commit is contained in:
parent
409b80994a
commit
7d2cde304d
10
recopytex/scripts/config.py
Normal file
10
recopytex/scripts/config.py
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import yaml
|
||||
|
||||
CONFIGPATH = "recoconfig.yml"
|
||||
|
||||
with open(CONFIGPATH, "r") as configfile:
|
||||
config = yaml.load(configfile, Loader=yaml.FullLoader)
|
||||
|
120
recopytex/scripts/prepare_csv.py
Normal file
120
recopytex/scripts/prepare_csv.py
Normal file
@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import click
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from PyInquirer import prompt, print_json
|
||||
|
||||
from .config import config
|
||||
|
||||
def prepare_csv():
|
||||
click.echo(f"Préparation d'un nouveau devoir")
|
||||
|
||||
eval_questions = [
|
||||
{
|
||||
"type": "input",
|
||||
"name": "evalname",
|
||||
"message": "Nom de l'évaluation",
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"name": "tribe",
|
||||
"message": "Classe concernée",
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"name": "date",
|
||||
"message": "Date du devoir",
|
||||
"filter": lambda val: datetime.strptime(val, "%y%m%d")
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"name": "term",
|
||||
"message": "Trimestre",
|
||||
"choices": ["1", "2", "3"],
|
||||
}
|
||||
]
|
||||
|
||||
exercise_questions = [
|
||||
{
|
||||
"type": "input",
|
||||
"name": "exercisename",
|
||||
"message": "Nom de l'exercice"
|
||||
},
|
||||
]
|
||||
|
||||
item_questions = [
|
||||
{
|
||||
"type": "input",
|
||||
"name": "itemname",
|
||||
"message": "Nom de l'item",
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"name": "comment",
|
||||
"message": "Description",
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"name": "competence",
|
||||
"message": "Competence",
|
||||
"choices": ["Cher", "Rep", "Mod", "Rai", "Cal", "Com"],
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"name": "domain",
|
||||
"message": "Domaine",
|
||||
},
|
||||
{
|
||||
"type": "confirm",
|
||||
"name": "is_leveled",
|
||||
"message": "Évaluation par niveau",
|
||||
"default": True
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"name": "scorerate",
|
||||
"message": "Bareme"
|
||||
},
|
||||
{
|
||||
"type": "confirm",
|
||||
"name": "correct",
|
||||
"message": "Tout est correct?",
|
||||
"default": True
|
||||
},
|
||||
{
|
||||
"type": "confirm",
|
||||
"name": "add_item",
|
||||
"message": "Ajouter un autre item",
|
||||
"default": True,
|
||||
},
|
||||
]
|
||||
|
||||
eval_ans = prompt(eval_questions)
|
||||
|
||||
|
||||
items = []
|
||||
add_exo = True
|
||||
while add_exo:
|
||||
click.echo(f"Nouvel exercice")
|
||||
exercise_ans = prompt(exercise_questions)
|
||||
|
||||
add_item = True
|
||||
while add_item:
|
||||
click.echo(f"Nouvelle question pour l'exercice {exercise_ans['exercisename']}")
|
||||
item_ans = prompt(item_questions)
|
||||
if item_ans["correct"]:
|
||||
add_item = item_ans["add_item"]
|
||||
item_ans.update(eval_ans)
|
||||
item_ans.update(exercise_ans)
|
||||
items.append(item_ans)
|
||||
|
||||
add_exo = prompt([{
|
||||
"type": "confirm",
|
||||
"name": "add_exo",
|
||||
"message": "Ajouter un autre exercice",
|
||||
"default": True
|
||||
}])["add_exo"]
|
||||
|
||||
return items
|
@ -8,10 +8,8 @@ import sys
|
||||
import papermill as pm
|
||||
from datetime import datetime
|
||||
|
||||
CONFIGPATH = "recoconfig.yml"
|
||||
|
||||
with open(CONFIGPATH, "r") as config:
|
||||
config = yaml.load(config, Loader=yaml.FullLoader)
|
||||
from .prepare_csv import prepare_csv
|
||||
from .config import config
|
||||
|
||||
|
||||
@click.group()
|
||||
@ -27,7 +25,7 @@ def print_config():
|
||||
|
||||
|
||||
def reporting(csv_file):
|
||||
#csv_file = Path(csv_file)
|
||||
# csv_file = Path(csv_file)
|
||||
tribe_dir = csv_file.parent
|
||||
csv_filename = csv_file.name.split(".")[0]
|
||||
|
||||
@ -50,10 +48,14 @@ def reporting(csv_file):
|
||||
str(template),
|
||||
str(dest / f"{assessment}.ipynb"),
|
||||
parameters=dict(
|
||||
tribe=tribe, assessment=assessment, date=f"{date:%d/%m/%y}", csv_file=str(csv_file.absolute())
|
||||
tribe=tribe,
|
||||
assessment=assessment,
|
||||
date=f"{date:%d/%m/%y}",
|
||||
csv_file=str(csv_file.absolute()),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument("target", required=False)
|
||||
def report(target=""):
|
||||
@ -72,9 +74,9 @@ def report(target=""):
|
||||
sys.exit(1)
|
||||
csvs = [csv]
|
||||
else:
|
||||
csvs = list(Path(target).glob('**/*.csv'))
|
||||
csvs = list(Path(target).glob("**/*.csv"))
|
||||
except AttributeError:
|
||||
csvs = list(Path(config["source"]).glob('**/*.csv'))
|
||||
csvs = list(Path(config["source"]).glob("**/*.csv"))
|
||||
|
||||
for csv in csvs:
|
||||
click.echo(f"Processing {csv}")
|
||||
@ -83,3 +85,18 @@ def report(target=""):
|
||||
except pm.exceptions.PapermillExecutionError as e:
|
||||
click.echo(f"Error with {csv}: {e}")
|
||||
|
||||
|
||||
@cli.command()
|
||||
def prepare():
|
||||
""" Prepare csv file """
|
||||
|
||||
items = prepare_csv()
|
||||
|
||||
click.echo(items)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument("tribe")
|
||||
def random_pick(tribe):
|
||||
""" Randomly pick a student """
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user