From 3005d49a1d9cf24b7ddbb885fc8b404532abd84f Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Tue, 6 Apr 2021 19:51:15 +0200 Subject: [PATCH] Feat: wrote get_students --- recopytex/store/filesystem/loader.py | 29 +++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/recopytex/store/filesystem/loader.py b/recopytex/store/filesystem/loader.py index b86fff7..312ac93 100644 --- a/recopytex/store/filesystem/loader.py +++ b/recopytex/store/filesystem/loader.py @@ -96,13 +96,6 @@ class CSVLoader(Loader): exams.append(exam) return pd.concat(exams) - def get_students(self, tribes=[]): - """Get student list - - :param tribes: concerned tribes - """ - return "" - def get_exam_questions(self, exams=[]): """Get questions for exams stored in score_files @@ -195,6 +188,28 @@ class CSVLoader(Loader): return pd.concat(scores) + def get_students(self, tribes=[]): + """Get student list + + :param tribes: concerned tribes + + :example: + >>> loader = CSVLoader("./test_config.yml") + >>> tribes = loader.get_tribes() + >>> students = loader.get_students([tribes["Tribe1"]]) + >>> students.columns + Index(['Nom', 'email', 'origin', 'tribe'], dtype='object') + """ + students = [] + for tribe in tribes: + students_csv = Path(self._config["source"]) / tribe["students"] + students_df = pd.read_csv(students_csv) + students_df["origin"] = students_csv + students_df["tribe"] = tribe["name"] + students.append(students_df) + + return pd.concat(students) + def get_student_scores(self, student): """Get scores of the student