#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2017 lafrite # # Distributed under terms of the MIT license. """ POV tools on term """ from notes_tools.tools.marks_plottings import (pie_pivot_table, parallel_on, radar_on, ) __all__ = ["Student", "Classe"] class Student(object): """ Informations on a student which can be use inside template. Those informations should not be modify or use for compute analysis otherwise they won't be spread over other POV. """ def __init__(self, quest_df, exo_df, eval_df): """ Description of a student from quest, exo and eval """ if len(quest_df["Eleve"].unique()) != 1: raise ValueError("Can't initiate Student: quest_df contains different student names") elif len(exo_df["Eleve"].unique()) != 1: raise ValueError("Can't initiate Student: exo_df contains different student names") elif len(eval_df["Eleve"].unique()) != 1: raise ValueError("Can't initiate Student: eval_df contains different student names") elif quest_df["Eleve"].iloc[0] != exo_df["Eleve"].iloc[0] or \ quest_df["Eleve"].iloc[0] != eval_df["Eleve"].iloc[0]: raise ValueError("Can't initiate Student: dfs contains different student names") self.name = quest_df["Eleve"].iloc[0] self.quest_df = quest_df self.exo_df = exo_df self.eval_df = eval_df @property def marks_tabular(self): """ Latex tabular with all of his marks of the term """ try: self._marks_tabular except AttributeError: self._marks_tabular = self.eval_df[["Nom", "Mark", "Bareme"]].to_latex() return self._marks_tabular @property def pies_on_competence(self): """ Pies chart on competences """ try: self._pies_on_competence except AttributeError: self._pies_on_competence = pie_pivot_table(self.quest_df, index = "Level", columns = "Competence", values = "Eleve", aggfunc = len, fill_value = 0, ) return self._pies_on_competence @property def pies_on_domaine(self): """ Pies chart on domaines """ try: self._pies_on_domaine except AttributeError: self._pies_on_domaine = pie_pivot_table(self.quest_df, index = "Level", columns = "Domaine", values = "Eleve", aggfunc = len, fill_value = 0, ) return self._pies_on_domaine @property def radar_on_competence(self): """ Radar plot on competence """ try: self._radar_on_competence except AttributeError: self._radar_on_competence = radar_on(self.quest_df, "Competence") return self._radar_on_competence @property def radar_on_domaine(self): """ Radar plot on domaine """ try: self._radar_on_domaine except AttributeError: self._radar_on_domaine = radar_on(self.quest_df, "Domaine") return self._radar_on_domaine def parallel_on_evals(self, classe_evals): """ Parallel coordinate plot of the class with student line highlight """ return parallel_on(classe_evals, "Nom", self.name) class Classe(object): """Docstring for Classe. """ def __init__(self): """TODO: to be defined1. """ pass # ----------------------------- # Reglages pour 'vim' # vim:set autoindent expandtab tabstop=4 shiftwidth=4: # cursor: 16 del