Feat: Save to csv works
This commit is contained in:
parent
33117cde71
commit
7e026bedb2
@ -2,16 +2,16 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
NO_ST_COLUMNS = {
|
NO_ST_COLUMNS = {
|
||||||
"term": "Trimestre",
|
|
||||||
"assessment": "Nom",
|
"assessment": "Nom",
|
||||||
|
"term": "Trimestre",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
"exercise": "Exercice",
|
"exercise": "Exercice",
|
||||||
"question": "Question",
|
"question": "Question",
|
||||||
"competence": "Competence",
|
"competence": "Competence",
|
||||||
"theme": "Domaine",
|
"theme": "Domaine",
|
||||||
"comment": "Commentaire",
|
"comment": "Commentaire",
|
||||||
"score_rate": "Bareme",
|
|
||||||
"is_leveled": "Est_nivele",
|
"is_leveled": "Est_nivele",
|
||||||
|
"score_rate": "Bareme",
|
||||||
}
|
}
|
||||||
|
|
||||||
COLUMNS = {
|
COLUMNS = {
|
||||||
|
@ -5,8 +5,11 @@ import click
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from PyInquirer import prompt, print_json
|
from PyInquirer import prompt, print_json
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
from .config import config
|
from .config import config
|
||||||
|
from ..config import NO_ST_COLUMNS
|
||||||
|
|
||||||
|
|
||||||
class PromptAbortException(EOFError):
|
class PromptAbortException(EOFError):
|
||||||
@ -26,12 +29,32 @@ def get_tribes(answers):
|
|||||||
def prepare_csv():
|
def prepare_csv():
|
||||||
items = new_eval()
|
items = new_eval()
|
||||||
|
|
||||||
|
item = items[0]
|
||||||
|
# item = {"tribe": "308", "date": datetime.today(), "assessment": "plop"}
|
||||||
|
csv_output = (
|
||||||
|
Path(config["source"])
|
||||||
|
/ item["tribe"]
|
||||||
|
/ f"{item['date']:%y%m%d}_{item['assessment']}.csv"
|
||||||
|
)
|
||||||
|
|
||||||
|
students = pd.read_csv(Path(config["source"]) / item["tribe"] / "eleves.csv")["Nom"]
|
||||||
|
|
||||||
|
columns = list(NO_ST_COLUMNS.keys())
|
||||||
|
items = [[it[c] for c in columns] for it in items]
|
||||||
|
columns = list(NO_ST_COLUMNS.values())
|
||||||
|
items_df = pd.DataFrame.from_records(items, columns=columns)
|
||||||
|
for s in students:
|
||||||
|
items_df[s] = np.nan
|
||||||
|
|
||||||
|
items_df.to_csv(csv_output, index=False, date_format="%d/%m/%Y")
|
||||||
|
click.echo(f"Saving csv file to {csv_output}")
|
||||||
|
|
||||||
|
|
||||||
def new_eval(answers={}):
|
def new_eval(answers={}):
|
||||||
click.echo(f"Préparation d'un nouveau devoir")
|
click.echo(f"Préparation d'un nouveau devoir")
|
||||||
|
|
||||||
eval_questions = [
|
eval_questions = [
|
||||||
{"type": "input", "name": "evalname", "message": "Nom de l'évaluation",},
|
{"type": "input", "name": "assessment", "message": "Nom de l'évaluation",},
|
||||||
{
|
{
|
||||||
"type": "list",
|
"type": "list",
|
||||||
"name": "tribe",
|
"name": "tribe",
|
||||||
@ -75,7 +98,7 @@ def new_eval(answers={}):
|
|||||||
|
|
||||||
def new_exercice(answers={}):
|
def new_exercice(answers={}):
|
||||||
exercise_questions = [
|
exercise_questions = [
|
||||||
{"type": "input", "name": "exercisename", "message": "Nom de l'exercice"},
|
{"type": "input", "name": "exercise", "message": "Nom de l'exercice"},
|
||||||
]
|
]
|
||||||
|
|
||||||
click.echo(f"Nouvel exercice")
|
click.echo(f"Nouvel exercice")
|
||||||
@ -96,7 +119,7 @@ def new_exercice(answers={}):
|
|||||||
{
|
{
|
||||||
"type": "confirm",
|
"type": "confirm",
|
||||||
"name": "add_item",
|
"name": "add_item",
|
||||||
"message": f"Ajouter un autre item pour l'exercice {exercise_ans['exercisename']}",
|
"message": f"Ajouter un autre item pour l'exercice {exercise_ans['exercise']}",
|
||||||
"default": True,
|
"default": True,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -107,22 +130,22 @@ def new_exercice(answers={}):
|
|||||||
|
|
||||||
def new_item(answers={}):
|
def new_item(answers={}):
|
||||||
item_questions = [
|
item_questions = [
|
||||||
{"type": "input", "name": "itemname", "message": "Nom de l'item",},
|
{"type": "input", "name": "question", "message": "Nom de l'item",},
|
||||||
{"type": "input", "name": "comment", "message": "Description",},
|
{"type": "input", "name": "comment", "message": "Commentaire",},
|
||||||
{
|
{
|
||||||
"type": "list",
|
"type": "list",
|
||||||
"name": "competence",
|
"name": "competence",
|
||||||
"message": "Competence",
|
"message": "Competence",
|
||||||
"choices": ["Cher", "Rep", "Mod", "Rai", "Cal", "Com"],
|
"choices": ["Cher", "Rep", "Mod", "Rai", "Cal", "Com"],
|
||||||
},
|
},
|
||||||
{"type": "input", "name": "domain", "message": "Domaine",},
|
{"type": "input", "name": "theme", "message": "Domaine",},
|
||||||
{
|
{
|
||||||
"type": "confirm",
|
"type": "confirm",
|
||||||
"name": "is_leveled",
|
"name": "is_leveled",
|
||||||
"message": "Évaluation par niveau",
|
"message": "Évaluation par niveau",
|
||||||
"default": True,
|
"default": True,
|
||||||
},
|
},
|
||||||
{"type": "input", "name": "scorerate", "message": "Bareme"},
|
{"type": "input", "name": "score_rate", "message": "Bareme"},
|
||||||
{
|
{
|
||||||
"type": "confirm",
|
"type": "confirm",
|
||||||
"name": "correct",
|
"name": "correct",
|
||||||
@ -130,7 +153,7 @@ def new_item(answers={}):
|
|||||||
"default": True,
|
"default": True,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
click.echo(f"Nouvelle question pour l'exercice {answers['exercisename']}")
|
click.echo(f"Nouvelle question pour l'exercice {answers['exercise']}")
|
||||||
item_ans = prompt(item_questions, answers=answers)
|
item_ans = prompt(item_questions, answers=answers)
|
||||||
if item_ans["correct"]:
|
if item_ans["correct"]:
|
||||||
return item_ans
|
return item_ans
|
||||||
|
Loading…
Reference in New Issue
Block a user