From 37c95d75de4f7748988e51c464f8dd4ad2b088d1 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Tue, 6 Apr 2021 18:18:25 +0200 Subject: [PATCH] Feat: write get_exam_questions --- recopytex/store/filesystem/loader.py | 36 ++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/recopytex/store/filesystem/loader.py b/recopytex/store/filesystem/loader.py index 234faf7..b6b791e 100644 --- a/recopytex/store/filesystem/loader.py +++ b/recopytex/store/filesystem/loader.py @@ -87,16 +87,44 @@ class CSVLoader(Loader): def get_students(self, tribes=[]): """Get student list - :param filters: list of filters + :param tribes: concerned tribes """ return "" - def get_exam_questions(self, exams=[]): - """Get questions for the exam + def get_exam_questions(self, score_files=[]): + """Get questions for exams stored in score_files :param exams: questions for those exams only + + :example: + >>> loader = CSVLoader() + >>> loader.get_exam_questions(["example/Tribe1/210112_DS.csv"]) + Exercice Question Competence ... Commentaire Bareme Est_nivele + 0 Exercice 1 1 Calculer ... Coucou 1 1 + 1 Exercice 1 2 Calculer ... Coucou 1 1 + 2 Exercice 1 3 Calculer ... Coucou 1 1 + 3 Exercice 1 3 Calculer ... DChic 1 1 + + [4 rows x 7 columns] """ - return "" + questions = [] + for score_file in score_files: + fields = self.reverse_csv_field( + [ + "exercise", + "question", + "competence", + "theme", + "comment", + "score_rate", + "is_leveled", + ] + ) + question = extract_fields(score_file, fields) + question = self.rename_columns(question) + questions.append(question) + + return pd.concat(questions) def get_questions_scores(self, questions=[]): """Get scores of those questions