{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "25b1d95f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:26.060875Z",
     "iopub.status.busy": "2023-02-28T14:59:26.060368Z",
     "iopub.status.idle": "2023-02-28T14:59:26.763612Z",
     "shell.execute_reply": "2023-02-28T14:59:26.763926Z"
    },
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {},
       "report_default": {
        "hidden": true
       }
      }
     }
    },
    "papermill": {
     "duration": 0.756539,
     "end_time": "2023-02-28T14:59:26.764050",
     "exception": false,
     "start_time": "2023-02-28T14:59:26.007511",
     "status": "completed"
    },
    "slideshow": {
     "slide_type": "skip"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "        \n",
       "        "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.display import Markdown as md\n",
    "from IPython.display import display, HTML\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import ipywidgets as widgets\n",
    "from pathlib import Path\n",
    "from datetime import datetime\n",
    "from recopytex import flat_df_students, pp_q_scores\n",
    "from datetime import datetime\n",
    "\n",
    "\n",
    "import chart_studio.plotly as py\n",
    "import plotly.graph_objects as go\n",
    "import plotly.figure_factory as ff\n",
    "\n",
    "from plotly.offline import iplot, init_notebook_mode\n",
    "init_notebook_mode()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3a865047",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:26.912665Z",
     "iopub.status.busy": "2023-02-28T14:59:26.912247Z",
     "iopub.status.idle": "2023-02-28T14:59:26.913413Z",
     "shell.execute_reply": "2023-02-28T14:59:26.913699Z"
    },
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {},
       "report_default": {
        "hidden": true
       }
      }
     }
    },
    "papermill": {
     "duration": 0.076668,
     "end_time": "2023-02-28T14:59:26.913778",
     "exception": false,
     "start_time": "2023-02-28T14:59:26.837110",
     "status": "completed"
    },
    "slideshow": {
     "slide_type": "skip"
    },
    "tags": [
     "parameters"
    ]
   },
   "outputs": [],
   "source": [
    "tribe = \"ES\"\n",
    "assessment = \"ds2\"\n",
    "date = \"14/10/19\"\n",
    "csv_file = Path(f\"../{tribe}/191014_{assessment}.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "76f73c11",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:27.062644Z",
     "iopub.status.busy": "2023-02-28T14:59:27.062296Z",
     "iopub.status.idle": "2023-02-28T14:59:27.063603Z",
     "shell.execute_reply": "2023-02-28T14:59:27.063875Z"
    },
    "papermill": {
     "duration": 0.077335,
     "end_time": "2023-02-28T14:59:27.063957",
     "exception": false,
     "start_time": "2023-02-28T14:59:26.986622",
     "status": "completed"
    },
    "tags": [
     "injected-parameters"
    ]
   },
   "outputs": [],
   "source": [
    "# Parameters\n",
    "tribe = \"2gt1\"\n",
    "assessment = \"Ds4\"\n",
    "date = \"24/02/23\"\n",
    "csv_file = \"/home/lafrite/Cours/2022-2023/Notes/2gt1/230224_DS4.csv\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "63832c37",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:27.213463Z",
     "iopub.status.busy": "2023-02-28T14:59:27.213110Z",
     "iopub.status.idle": "2023-02-28T14:59:27.214461Z",
     "shell.execute_reply": "2023-02-28T14:59:27.214733Z"
    },
    "papermill": {
     "duration": 0.077937,
     "end_time": "2023-02-28T14:59:27.214814",
     "exception": false,
     "start_time": "2023-02-28T14:59:27.136877",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/lafrite/Cours/2022-2023/Notes/2gt1/230224_DS4\n"
     ]
    }
   ],
   "source": [
    "date = datetime.strptime(date, \"%d/%m/%y\")\n",
    "output_path = Path(csv_file[:-4])\n",
    "print(output_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2a41f502",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:27.367480Z",
     "iopub.status.busy": "2023-02-28T14:59:27.367125Z",
     "iopub.status.idle": "2023-02-28T14:59:27.368635Z",
     "shell.execute_reply": "2023-02-28T14:59:27.368919Z"
    },
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {},
       "report_default": {
        "hidden": false
       }
      }
     }
    },
    "papermill": {
     "duration": 0.081224,
     "end_time": "2023-02-28T14:59:27.368999",
     "exception": false,
     "start_time": "2023-02-28T14:59:27.287775",
     "status": "completed"
    },
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "# Ds4 (23/02/24) pour 2gt1"
      ],
      "text/plain": [
       ""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "if date is None:\n",
    "    display(md(f\"# {assessment} pour {tribe}\"))\n",
    "else:\n",
    "    display(md(f\"# {assessment} ({date:%y/%m/%d}) pour {tribe}\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "3149dc30",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:27.556422Z",
     "iopub.status.busy": "2023-02-28T14:59:27.529858Z",
     "iopub.status.idle": "2023-02-28T14:59:27.672229Z",
     "shell.execute_reply": "2023-02-28T14:59:27.671858Z"
    },
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {},
       "report_default": {
        "hidden": true
       }
      }
     }
    },
    "papermill": {
     "duration": 0.229877,
     "end_time": "2023-02-28T14:59:27.672303",
     "exception": false,
     "start_time": "2023-02-28T14:59:27.442426",
     "status": "completed"
    },
    "slideshow": {
     "slide_type": "skip"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "stack_scores = pd.read_csv(csv_file, encoding=\"UTF8\")\n",
    "#comments = stack_scores.iloc[0]\n",
    "#stack_scores.drop([0], inplace=True)\n",
    "scores = flat_df_students(stack_scores).dropna(subset=[\"Score\"])\n",
    "scores = pp_q_scores(scores)\n",
    "#scores.head()\n",
    "#comments.drop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "48cb4a36",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:27.824571Z",
     "iopub.status.busy": "2023-02-28T14:59:27.822678Z",
     "iopub.status.idle": "2023-02-28T14:59:27.827184Z",
     "shell.execute_reply": "2023-02-28T14:59:27.826836Z"
    },
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {},
       "report_default": {
        "hidden": true
       }
      }
     }
    },
    "papermill": {
     "duration": 0.081613,
     "end_time": "2023-02-28T14:59:27.827255",
     "exception": false,
     "start_time": "2023-02-28T14:59:27.745642",
     "status": "completed"
    },
    "slideshow": {
     "slide_type": "skip"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "exercises_scores = scores.groupby([\"Exercice\", \"Eleve\"]).agg({\"Note\": \"sum\", \"Bareme\": \"sum\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "15025186",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-02-28T14:59:27.977591Z",
     "iopub.status.busy": "2023-02-28T14:59:27.977238Z",
     "iopub.status.idle": "2023-02-28T14:59:27.982314Z",
     "shell.execute_reply": "2023-02-28T14:59:27.982023Z"
    },
    "papermill": {
     "duration": 0.081389,
     "end_time": "2023-02-28T14:59:27.982386",
     "exception": false,
     "start_time": "2023-02-28T14:59:27.900997",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "
\n",
       "  \n",
       "    \n",
       "      | \n",
       " | \n",
       " | Note\n",
       " | Bareme\n",
       " | 
\n",
       "    \n",
       "      | Exercice\n",
       " | Eleve\n",
       " | \n",
       " | \n",
       " | 
\n",
       "  \n",
       "  \n",
       "    \n",
       "      | Exercice 1\n",
       " | ACHOUR Ilyes\n",
       " | 3.00\n",
       " | 7\n",
       " | 
\n",
       "    \n",
       "      | BELARBI Islem\n",
       " | 0.00\n",
       " | 7\n",
       " | 
\n",
       "    \n",
       "      | BEN ELALLID Hajar\n",
       " | 3.00\n",
       " | 7\n",
       " | 
\n",
       "    \n",
       "      | BISWAS Lina\n",
       " | 2.67\n",
       " | 7\n",
       " | 
\n",
       "    \n",
       "      | BOULAABA Rayan\n",
       " | 5.00\n",
       " | 7\n",
       " | 
\n",
       "  \n",
       "
\n",
       "
\n",
       "\n",
       "
\n",
       "  \n",
       "    \n",
       "      | \n",
       " | \n",
       " | Note\n",
       " | Bareme\n",
       " | Normalized\n",
       " | 
\n",
       "    \n",
       "      | Eleve\n",
       " | Competence\n",
       " | \n",
       " | \n",
       " | \n",
       " | 
\n",
       "  \n",
       "  \n",
       "    \n",
       "      | TOURRETTE Elise\n",
       " | Raisonner\n",
       " | 3.33\n",
       " | 8\n",
       " | 0.42\n",
       " | 
\n",
       "    \n",
       "      | Représenter\n",
       " | 3.67\n",
       " | 5\n",
       " | 0.73\n",
       " | 
\n",
       "    \n",
       "      | TROPHARDY Eline\n",
       " | Calculer\n",
       " | 6.33\n",
       " | 7\n",
       " | 0.90\n",
       " | 
\n",
       "    \n",
       "      | Raisonner\n",
       " | 7.00\n",
       " | 8\n",
       " | 0.88\n",
       " | 
\n",
       "    \n",
       "      | Représenter\n",
       " | 4.67\n",
       " | 5\n",
       " | 0.93\n",
       " | 
\n",
       "  \n",
       "
\n",
       "