From 29f67cfa0c928203a250ae625a88b2ef38319054 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Mon, 10 May 2021 12:21:42 +0200 Subject: [PATCH] Fix: can't save in create exam --- recopytex/scripts/exam.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/recopytex/scripts/exam.py b/recopytex/scripts/exam.py index 3593538..4afcaf7 100644 --- a/recopytex/scripts/exam.py +++ b/recopytex/scripts/exam.py @@ -3,7 +3,8 @@ from datetime import datetime from pathlib import Path -from prompt_toolkit import HTML + +# from prompt_toolkit import HTML from ..config import NO_ST_COLUMNS import pandas as pd import yaml @@ -57,11 +58,13 @@ class Exam: return self._term def add_exercise(self, name, questions): - """ Add key with questions in ._exercises """ + """Add key with questions in ._exercises""" try: self._exercises[name] except KeyError: - self._exercises[name] = format_question(questions) + self._exercises[name] = [ + format_question(question) for question in questions + ] else: raise KeyError("The exercise already exsists. Use modify_exercise") @@ -100,7 +103,7 @@ class Exam: @property def long_name(self): - """ Get exam name with date inside """ + """Get exam name with date inside""" return f"{self.date.strftime('%y%m%d')}_{self.name}" def path(self, extention=""): @@ -153,6 +156,7 @@ class Exam: def write_csv(self): rows = self.to_row() + print(rows) base_df = pd.DataFrame.from_dict(rows)[NO_ST_COLUMNS.keys()] base_df.rename(columns=NO_ST_COLUMNS, inplace=True) @@ -173,7 +177,7 @@ class Exam: @property def competences_rate(self): - """ Dictionnary with competences as key and total rate as value""" + """Dictionnary with competences as key and total rate as value""" rates = {} for ex, questions in self._exercises.items(): for q in questions: @@ -190,7 +194,7 @@ class Exam: @property def themes_rate(self): - """ Dictionnary with themes as key and total rate as value""" + """Dictionnary with themes as key and total rate as value""" rates = {} for ex, questions in self._exercises.items(): for q in questions: