From 2d08671247011947195ed2874b400d450285c691 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Thu, 22 Apr 2021 08:00:25 +0200 Subject: [PATCH] Feat: add "." in csv example and fix issues --- example/Tribe1/210112_DS.csv | 8 ++++---- .../dashboard/pages/exams_scores/models.py | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/example/Tribe1/210112_DS.csv b/example/Tribe1/210112_DS.csv index d518d37..3b6c818 100644 --- a/example/Tribe1/210112_DS.csv +++ b/example/Tribe1/210112_DS.csv @@ -1,5 +1,5 @@ Trimestre,Nom,Date,Exercice,Question,Competence,Domaine,Commentaire,Bareme,Est_nivele,Star Tice,Umberto Dingate,Starlin Crangle,Humbert Bourcq,Gabriella Handyside,Stewart Eaves,Erick Going,Ase Praton,Rollins Planks,Dunstan Sarjant,Stacy Guiton,Ange Stanes,Amabelle Elleton,Darn Broomhall,Dyan Chatto,Keane Rennebach,Nari Paulton,Brandy Wase,Jaclyn Firidolfi,Violette Lockney -1,DS,12/01/2021,Exercice 1,1,Calculer,Plop,Coucou,1,1,,,1.0,0,1.0,2.0,3.0,0.0,3.0,3.0,2.0,,1.0,,,,,,, -1,DS,12/01/2021,Exercice 1,2,Calculer,C'est trop chouette!,Coucou,1,1,,,1.0,2,,,3.0,3.0,,,,,2.0,,,,,,, -1,DS,12/01/2021,Exercice 1,3,Calculer,Null,Coucou,1,1,,,,3,2.0,,,,,,,,3.0,,,,,,, -1,DS,12/01/2021,Exercice 1,3,Calculer,Nié,DChic,1,1,,,,2,,,,,,,,,,,,,,,, +1,DS,12/01/2021,Exercice 1,1,Calculer,Plop,Coucou,1,1,,,1,0,1,2,3,0,3,3,2,,1,,,,,,, +1,DS,12/01/2021,Exercice 1,2,Calculer,C'est trop chouette!,Coucou,1,1,,,1,2,,,3,3,,,,,2,,,,,,, +1,DS,12/01/2021,Exercice 1,3,Calculer,Null,Coucou,1,1,,,,3,2,,,,,,,,3,,,,,,, +1,DS,12/01/2021,Exercice 1,3,Calculer,Nié,DChic,1,1,,,,2,.,,,,,,,,,,,,,,, diff --git a/recopytex/dashboard/pages/exams_scores/models.py b/recopytex/dashboard/pages/exams_scores/models.py index bd02816..46d901e 100644 --- a/recopytex/dashboard/pages/exams_scores/models.py +++ b/recopytex/dashboard/pages/exams_scores/models.py @@ -72,22 +72,31 @@ def get_score_colors(): def get_level_color_bar(): return [ - {"score": s["value"], "name": s["comment"], "color": s["color"]} + {"score": str(s["value"]), "name": s["comment"], "color": s["color"]} for s in SCORES_CONFIG.values() ] is_none_score = lambda x: on_column.is_none_score(x, SCORES_CONFIG) +format_score = lambda x: on_column.format_score(x, SCORES_CONFIG) score_to_numeric_score = lambda x: on_column.score_to_numeric_score(x, SCORES_CONFIG) score_to_mark = lambda x: on_column.score_to_mark( x, max([v["value"] for v in SCORES_CONFIG.values() if isinstance(v["value"], int)]) ) +def filter_clean_score(scores): + filtered_scores = scores[~scores.apply(is_none_score, axis=1)] + filtered_scores = filtered_scores.assign( + score=filtered_scores.apply(format_score, axis=1) + ) + return filtered_scores + + def score_to_final_mark(scores): """ Compute marks then reduce to final mark per student """ - filtered_scores = scores[~scores.apply(is_none_score, axis=1)] + filtered_scores = filter_clean_score(scores) filtered_scores = filtered_scores.assign( score=filtered_scores.apply(score_to_numeric_score, axis=1) ) @@ -106,9 +115,10 @@ def pivot_score_on(scores, index, columns, aggfunc="size"): It assumes thant scores are levels """ - filtered_scores = scores[~scores.apply(is_none_score, axis=1)] + filtered_scores = filter_clean_score(scores) + filtered_scores["score"] = filtered_scores["score"].astype(str) pt = pd.pivot_table( - scores, + filtered_scores, index=index, columns=columns, aggfunc=aggfunc,