Feat: Student report build

This commit is contained in:
Bertrand Benjamin 2019-08-04 16:54:12 +02:00
parent 18696a805c
commit d4a08f0142
2 changed files with 28 additions and 9 deletions

View File

@ -33,23 +33,41 @@ def report(csv_file):
sys.exit(1) sys.exit(1)
csv_file = Path(csv_file) csv_file = Path(csv_file)
tribe_dir = csv_file.parent
csv_filename = csv_file.name.split(".")[0] csv_filename = csv_file.name.split(".")[0]
assessment = str(csv_filename).split("_")[-1].capitalize() assessment = str(csv_filename).split("_")[-1].capitalize()
tribe = str(csv_file.parent).split("/")[-1] tribe = str(tribe_dir).split("/")[-1]
template = Path(config["templates"]) / "tpl_evaluation.ipynb" template = Path(config["templates"]) / "tpl_evaluation.ipynb"
dest = Path(config["output"]) / tribe / csv_filename / f"{assessment}.ipynb" dest = Path(config["output"]) / tribe / csv_filename
dest.parent.mkdir(parents=True, exist_ok=True) dest.mkdir(parents=True, exist_ok=True)
click.echo(f"Building {assessment} report")
pm.execute_notebook( pm.execute_notebook(
str(template), str(template),
str(dest), str(dest / f"{assessment}.ipynb"),
parameters=dict( parameters=dict(
tribe=tribe, assessment=assessment, csv_file=str(csv_file.absolute()) tribe=tribe, assessment=assessment, csv_file=str(csv_file.absolute())
), ),
) )
with open(csv_file.parent / "description.yml") as f:
tribe_desc = yaml.load(f, Loader=yaml.FullLoader)
template = Path(config["templates"]) / "tpl_student.ipynb"
dest = Path(config["output"]) / tribe / csv_filename / "students"
dest.mkdir(parents=True, exist_ok=True)
for st in tribe_desc["students"]:
click.echo(f"Building {st} report on {assessment}")
pm.execute_notebook(
str(template),
str(dest / f"{st}.ipynb"),
parameters=dict(tribe=tribe, student=st, source=str(tribe_dir.absolute())),
)
if __name__ == "__main__": if __name__ == "__main__":
cli() cli()

View File

@ -13,7 +13,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 10,
"metadata": { "metadata": {
"tags": [ "tags": [
"parameters" "parameters"
@ -22,24 +22,25 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"tribe = 30\n", "tribe = 30\n",
"student = \"ABDOU Asmahane\"" "student = \"ABDOU Asmahane\"\n",
"source = Path(f\"./sheets/{tribe}/\")"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/markdown": [ "text/markdown": [
"# ABDOU Asmahane en 308" "# ABDOU Asmahane en 30"
], ],
"text/plain": [ "text/plain": [
"<IPython.core.display.Markdown object>" "<IPython.core.display.Markdown object>"
] ]
}, },
"execution_count": 9, "execution_count": 11,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }