{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "25b1d95f", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:43.166855Z", "iopub.status.busy": "2023-01-25T10:10:43.166337Z", "iopub.status.idle": "2023-01-25T10:10:43.914296Z", "shell.execute_reply": "2023-01-25T10:10:43.913776Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.806039, "end_time": "2023-01-25T10:10:43.914380", "exception": false, "start_time": "2023-01-25T10:10:43.108341", "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-01-25T10:10:44.072723Z", "iopub.status.busy": "2023-01-25T10:10:44.072276Z", "iopub.status.idle": "2023-01-25T10:10:44.073598Z", "shell.execute_reply": "2023-01-25T10:10:44.073954Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.083378, "end_time": "2023-01-25T10:10:44.074048", "exception": false, "start_time": "2023-01-25T10:10:43.990670", "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": "df6b05cb", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:44.238434Z", "iopub.status.busy": "2023-01-25T10:10:44.238016Z", "iopub.status.idle": "2023-01-25T10:10:44.239909Z", "shell.execute_reply": "2023-01-25T10:10:44.239554Z" }, "papermill": { "duration": 0.089533, "end_time": "2023-01-25T10:10:44.239989", "exception": false, "start_time": "2023-01-25T10:10:44.150456", "status": "completed" }, "tags": [ "injected-parameters" ] }, "outputs": [], "source": [ "# Parameters\n", "tribe = \"2gt1\"\n", "assessment = \"Ds3\"\n", "date = \"18/01/23\"\n", "csv_file = \"/home/lafrite/Cours/2022-2023/Notes/2gt1/230118_DS3.csv\"\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "63832c37", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:44.399057Z", "iopub.status.busy": "2023-01-25T10:10:44.398594Z", "iopub.status.idle": "2023-01-25T10:10:44.400487Z", "shell.execute_reply": "2023-01-25T10:10:44.400821Z" }, "papermill": { "duration": 0.084739, "end_time": "2023-01-25T10:10:44.400914", "exception": false, "start_time": "2023-01-25T10:10:44.316175", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/lafrite/Cours/2022-2023/Notes/2gt1/230118_DS3\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-01-25T10:10:44.565678Z", "iopub.status.busy": "2023-01-25T10:10:44.560664Z", "iopub.status.idle": "2023-01-25T10:10:44.568174Z", "shell.execute_reply": "2023-01-25T10:10:44.567733Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": false } } } }, "papermill": { "duration": 0.090088, "end_time": "2023-01-25T10:10:44.568263", "exception": false, "start_time": "2023-01-25T10:10:44.478175", "status": "completed" }, "slideshow": { "slide_type": "slide" }, "tags": [] }, "outputs": [ { "data": { "text/markdown": [ "# Ds3 (23/01/18) 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-01-25T10:10:44.730685Z", "iopub.status.busy": "2023-01-25T10:10:44.724580Z", "iopub.status.idle": "2023-01-25T10:10:44.905557Z", "shell.execute_reply": "2023-01-25T10:10:44.905222Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.26116, "end_time": "2023-01-25T10:10:44.905637", "exception": false, "start_time": "2023-01-25T10:10:44.644477", "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-01-25T10:10:45.073424Z", "iopub.status.busy": "2023-01-25T10:10:45.073004Z", "iopub.status.idle": "2023-01-25T10:10:45.076760Z", "shell.execute_reply": "2023-01-25T10:10:45.076333Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.086783, "end_time": "2023-01-25T10:10:45.076833", "exception": false, "start_time": "2023-01-25T10:10:44.990050", "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-01-25T10:10:45.237796Z", "iopub.status.busy": "2023-01-25T10:10:45.237370Z", "iopub.status.idle": "2023-01-25T10:10:45.243720Z", "shell.execute_reply": "2023-01-25T10:10:45.243311Z" }, "papermill": { "duration": 0.088772, "end_time": "2023-01-25T10:10:45.243816", "exception": false, "start_time": "2023-01-25T10:10:45.155044", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NoteBareme
ExerciceEleve
Exercice 1ACHOUR Ilyes4.507.0
BELARBI Islem2.837.0
BEN ELALLID Hajar1.677.0
BISWAS Lina3.847.0
BOULAABA Rayan5.017.0
\n", "
" ], "text/plain": [ " Note Bareme\n", "Exercice Eleve \n", "Exercice 1 ACHOUR Ilyes 4.50 7.0\n", " BELARBI Islem 2.83 7.0\n", " BEN ELALLID Hajar 1.67 7.0\n", " BISWAS Lina 3.84 7.0\n", " BOULAABA Rayan 5.01 7.0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "exercises_scores.head()" ] }, { "cell_type": "code", "execution_count": 9, "id": "71c672c0", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:45.403674Z", "iopub.status.busy": "2023-01-25T10:10:45.402142Z", "iopub.status.idle": "2023-01-25T10:10:45.405758Z", "shell.execute_reply": "2023-01-25T10:10:45.405360Z" }, "papermill": { "duration": 0.084961, "end_time": "2023-01-25T10:10:45.405836", "exception": false, "start_time": "2023-01-25T10:10:45.320875", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "assessment_scores = scores.groupby([\"Eleve\"]).agg({\"Note\": \"sum\", \"Bareme\": \"sum\"})" ] }, { "cell_type": "code", "execution_count": 10, "id": "d8a02878", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:45.565177Z", "iopub.status.busy": "2023-01-25T10:10:45.564747Z", "iopub.status.idle": "2023-01-25T10:10:45.566680Z", "shell.execute_reply": "2023-01-25T10:10:45.567031Z" }, "papermill": { "duration": 0.084145, "end_time": "2023-01-25T10:10:45.567131", "exception": false, "start_time": "2023-01-25T10:10:45.482986", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Index(['Nom', 'Trimestre', 'Date', 'Exercice', 'Question', 'Competence',\n", " 'Domaine', 'Commentaire', 'Est_nivele', 'Bareme', 'Eleve', 'Score',\n", " 'Note', 'Niveau', 'Normalise'],\n", " dtype='object')" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scores.columns" ] }, { "cell_type": "code", "execution_count": 11, "id": "b6717594", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:45.728560Z", "iopub.status.busy": "2023-01-25T10:10:45.728135Z", "iopub.status.idle": "2023-01-25T10:10:45.731751Z", "shell.execute_reply": "2023-01-25T10:10:45.731351Z" }, "papermill": { "duration": 0.087668, "end_time": "2023-01-25T10:10:45.731831", "exception": false, "start_time": "2023-01-25T10:10:45.644163", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "domain_scores = scores.groupby([\"Eleve\", \"Domaine\"]).agg({\"Note\": \"sum\", \"Bareme\": \"sum\"})\n", "domain_scores[\"Normalized\"] = domain_scores[\"Note\"] / domain_scores[\"Bareme\"]" ] }, { "cell_type": "code", "execution_count": 12, "id": "d87553e1", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:45.897751Z", "iopub.status.busy": "2023-01-25T10:10:45.897323Z", "iopub.status.idle": "2023-01-25T10:10:45.898534Z", "shell.execute_reply": "2023-01-25T10:10:45.898874Z" }, "papermill": { "duration": 0.083626, "end_time": "2023-01-25T10:10:45.898967", "exception": false, "start_time": "2023-01-25T10:10:45.815341", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#domain_scores" ] }, { "cell_type": "code", "execution_count": 13, "id": "61a49219", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:46.062234Z", "iopub.status.busy": "2023-01-25T10:10:46.061635Z", "iopub.status.idle": "2023-01-25T10:10:46.066226Z", "shell.execute_reply": "2023-01-25T10:10:46.065794Z" }, "papermill": { "duration": 0.089244, "end_time": "2023-01-25T10:10:46.066308", "exception": false, "start_time": "2023-01-25T10:10:45.977064", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "competence_scores = scores.groupby([\"Eleve\", \"Competence\"]).agg({\"Note\": \"sum\", \"Bareme\": \"sum\"})\n", "competence_scores[\"Normalized\"] = competence_scores[\"Note\"] / competence_scores[\"Bareme\"]" ] }, { "cell_type": "code", "execution_count": 14, "id": "7c8ad2c9", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:46.230431Z", "iopub.status.busy": "2023-01-25T10:10:46.229917Z", "iopub.status.idle": "2023-01-25T10:10:46.231724Z", "shell.execute_reply": "2023-01-25T10:10:46.232032Z" }, "papermill": { "duration": 0.0881, "end_time": "2023-01-25T10:10:46.232138", "exception": false, "start_time": "2023-01-25T10:10:46.144038", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NoteBaremeNormalized
EleveCompetence
TROPHARDY ElineChercher3.674.00.92
Communiquer1.001.01.00
Modéliser1.001.01.00
Rechercher1.501.51.00
Représenter6.006.50.92
\n", "
" ], "text/plain": [ " Note Bareme Normalized\n", "Eleve Competence \n", "TROPHARDY Eline Chercher 3.67 4.0 0.92\n", " Communiquer 1.00 1.0 1.00\n", " Modéliser 1.00 1.0 1.00\n", " Rechercher 1.50 1.5 1.00\n", " Représenter 6.00 6.5 0.92" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "competence_scores.tail()" ] }, { "cell_type": "markdown", "id": "3437315d", "metadata": { "papermill": { "duration": 0.079755, "end_time": "2023-01-25T10:10:46.390215", "exception": false, "start_time": "2023-01-25T10:10:46.310460", "status": "completed" }, "tags": [] }, "source": [ "### Bilans personnalisés" ] }, { "cell_type": "code", "execution_count": 15, "id": "dd4fa512", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:46.554391Z", "iopub.status.busy": "2023-01-25T10:10:46.553948Z", "iopub.status.idle": "2023-01-25T10:10:46.573288Z", "shell.execute_reply": "2023-01-25T10:10:46.571920Z" }, "papermill": { "duration": 0.102816, "end_time": "2023-01-25T10:10:46.573542", "exception": false, "start_time": "2023-01-25T10:10:46.470726", "status": "completed" }, "scrolled": true, "tags": [] }, "outputs": [], "source": [ "import pytex\n", "#scores.head()" ] }, { "cell_type": "code", "execution_count": 16, "id": "6a667215", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:46.798157Z", "iopub.status.busy": "2023-01-25T10:10:46.763738Z", "iopub.status.idle": "2023-01-25T10:10:46.857599Z", "shell.execute_reply": "2023-01-25T10:10:46.857906Z" }, "papermill": { "duration": 0.190557, "end_time": "2023-01-25T10:10:46.858001", "exception": false, "start_time": "2023-01-25T10:10:46.667444", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "datas = {\n", " \"assessment\": {\n", " \"name\": assessment,\n", " \"date\": date\n", " },\n", " #\"exercises\": scores[\"Exercice\"].unique(),\n", " #\"questions\": scores[[\"Exercice\", 'Question', 'Competence', 'Domaine', 'Commentaire', 'Bareme', 'Est_nivele']],\n", " \"eleves\": {}\n", "}\n", "for e in scores[\"Eleve\"].unique():\n", " edatas = {\n", " \"e\": e,\n", " \"assessment\": assessment_scores.loc[e],\n", " \"exercices\": exercises_scores.xs(e, level=\"Eleve\"), \"exercices\": exercises_scores.xs(e, level=\"Eleve\"),\n", " \"domains\": domain_scores.xs(e, level=\"Eleve\"),\n", " \"competences\": competence_scores.xs(e, level=\"Eleve\"),\n", " \"exscores\": {}\n", " }\n", " for i, ex in edatas[\"exercices\"].iterrows():\n", " edatas[\"exscores\"][i] = scores.loc[(scores.Exercice==i) & (scores.Eleve==e)]\n", " datas[\"eleves\"][e] = edatas" ] }, { "cell_type": "code", "execution_count": 17, "id": "16b39fd6", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:47.030265Z", "iopub.status.busy": "2023-01-25T10:10:47.029876Z", "iopub.status.idle": "2023-01-25T10:10:47.031331Z", "shell.execute_reply": "2023-01-25T10:10:47.031657Z" }, "papermill": { "duration": 0.094801, "end_time": "2023-01-25T10:10:47.031746", "exception": false, "start_time": "2023-01-25T10:10:46.936945", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "score_template = r\"\"\"\n", "\\documentclass[a5paper,10pt]{article}\n", "\\usepackage{fullpage}\n", "\\usepackage{booktabs}\n", "\\usepackage{longtable}\n", "\\usepackage{tikz}\n", "\\usepackage{multicol}\n", "\n", "\\usepackage{geometry}\n", "\\geometry{left=10mm,right=10mm, top=10mm}\n", "\n", "\\renewcommand{\\arraystretch}{1}\n", "\\setlength{\\columnseprule}{0pt}\n", "\n", "\\pagestyle{empty}\n", "\n", "\n", "\\begin{document}\n", "\n", "\n", " \\section*{\\Var{assessment.name} \\hfill \\Var{e} \\hfill \\Var{sc.assessment.Note}/\\Var{sc.assessment.Bareme}}\n", " %- for i,ex in sc.exercices.iterrows() \n", " \\subsection*{\\Var{i}: \\hfill \\Var{ex.Note} / \\Var{ex.Bareme}}\n", " \\begin{center}\n", " \\Var{sc.exscores[i].to_latex(index=False, columns=[\"Question\", \"Domaine\", \"Commentaire\", \"Note\", \"Bareme\"])}\n", " \\end{center}\n", " %- endfor\n", " \n", " \\subsection*{Compétences}\n", " \\begin{multicols}{2}\n", " %- for i,dom in sc.competences.iterrows()\n", " \\noindent\n", " \\Var{i} \\hfill\n", " \\begin{tikzpicture}[scale=0.7]\n", " \\draw [](0,0) rectangle (3, 1);\n", " \\draw [fill=black!20] (0, 0) rectangle (\\Var{dom.Normalized*3}, 1);\n", " \\end{tikzpicture}\n", " \\hfill\n", " %\\Var{dom.Normalized}\n", " \n", " %- endfor\n", " \\end{multicols}\n", "\n", "\\end{document}\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": 18, "id": "e7d7716e", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:47.201846Z", "iopub.status.busy": "2023-01-25T10:10:47.201482Z", "iopub.status.idle": "2023-01-25T10:10:52.359079Z", "shell.execute_reply": "2023-01-25T10:10:52.358209Z" }, "papermill": { "duration": 5.248501, "end_time": "2023-01-25T10:10:52.359211", "exception": false, "start_time": "2023-01-25T10:10:47.110710", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wrote 230118_Ds3_ACHOUR Ilyes.tex\n", "Wrote 230118_Ds3_BELARBI Islem.tex\n", "Wrote 230118_Ds3_BEN ELALLID Hajar.tex\n", "Wrote 230118_Ds3_BISWAS Lina.tex\n", "Wrote 230118_Ds3_BOULAABA Rayan.tex\n", "Wrote 230118_Ds3_BREZUN Ines.tex\n", "Wrote 230118_Ds3_BUGNON Enzo.tex\n", "Wrote 230118_Ds3_CALLEWAERT Idaline.tex\n", "Wrote 230118_Ds3_CATTIN Clément.tex\n", "Wrote 230118_Ds3_CHRISTMANN Nathan.tex\n", "Wrote 230118_Ds3_DECOSTER Clément.tex\n", "Wrote 230118_Ds3_DEHIMAT Launy.tex\n", "Wrote 230118_Ds3_DUPONT Jessica.tex\n", "Wrote 230118_Ds3_GASAN Jéssica.tex\n", "Wrote 230118_Ds3_GEORGET Raphaël.tex\n", "Wrote 230118_Ds3_HABBAZ Hajar.tex\n", "Wrote 230118_Ds3_JACQUEMIER Samuel.tex\n", "Wrote 230118_Ds3_JACQUIER Juliette.tex\n", "Wrote 230118_Ds3_JOVIC Atanase.tex\n", "Wrote 230118_Ds3_KASSI Cheïma.tex\n", "Wrote 230118_Ds3_KICHENASSAMY Sanjay.tex\n", "Wrote 230118_Ds3_LE VEUZIT Adrien.tex\n", "Wrote 230118_Ds3_LETIF Ilef.tex\n", "Wrote 230118_Ds3_MANJALI Hiba.tex\n", "Wrote 230118_Ds3_NEIVA Hugo.tex\n", "Wrote 230118_Ds3_OLLIET Gioia.tex\n", "Wrote 230118_Ds3_PERNOT Gabin.tex\n", "Wrote 230118_Ds3_RIZZI Elisa.tex\n", "Wrote 230118_Ds3_ROSTANT Emma.tex\n", "Wrote 230118_Ds3_SIBABA Moaad.tex\n", "Wrote 230118_Ds3_SOUJOL Damien.tex\n", "Wrote 230118_Ds3_THORAL Fanny.tex\n", "Wrote 230118_Ds3_TOURRETTE Elise.tex\n", "Wrote 230118_Ds3_TROPHARDY Eline.tex\n" ] } ], "source": [ "tpl = pytex.texenv.from_string(score_template)\n", "\n", "for e,sc in datas['eleves'].items():\n", " reportfilename = f\"{date:%y%m%d}_{assessment}_{e}.tex\"\n", " with open(output_path / reportfilename, \"w\") as f:\n", " f.write(tpl.render(sc=sc, e=e,**datas))\n", " print(f\"Wrote {reportfilename}\")\n", " pytex.pdflatex(reportfilename)" ] }, { "cell_type": "markdown", "id": "dfaf5d3d", "metadata": { "papermill": { "duration": 0.215498, "end_time": "2023-01-25T10:10:52.736803", "exception": false, "start_time": "2023-01-25T10:10:52.521305", "status": "completed" }, "tags": [] }, "source": [ "## Envoie des bilans par mail" ] }, { "cell_type": "code", "execution_count": 19, "id": "76384db8", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:53.087736Z", "iopub.status.busy": "2023-01-25T10:10:53.087342Z", "iopub.status.idle": "2023-01-25T10:10:53.089411Z", "shell.execute_reply": "2023-01-25T10:10:53.089005Z" }, "papermill": { "duration": 0.179308, "end_time": "2023-01-25T10:10:53.089486", "exception": false, "start_time": "2023-01-25T10:10:52.910178", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Bian du devoir Ds3\n", "Bonsoir,\n", "En pièce jointe, vous trouverez un document détaillant la note du devoir.\n", "B.Bertrand\n", "\n" ] } ], "source": [ "mailfrom = \"benjamin.bertrand@ac-lyon.fr\"\n", "subject = f\"Bian du devoir {assessment}\"\n", "message = \"\"\"Bonsoir,\n", "En pièce jointe, vous trouverez un document détaillant la note du devoir.\n", "B.Bertrand\n", "\"\"\"\n", "print(subject)\n", "print(message)" ] }, { "cell_type": "code", "execution_count": 20, "id": "71eb9a2b", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:53.419106Z", "iopub.status.busy": "2023-01-25T10:10:53.418668Z", "iopub.status.idle": "2023-01-25T10:10:53.429798Z", "shell.execute_reply": "2023-01-25T10:10:53.430081Z" }, "papermill": { "duration": 0.17759, "end_time": "2023-01-25T10:10:53.430181", "exception": false, "start_time": "2023-01-25T10:10:53.252591", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "import smtplib\n", "import os\n", "import sys\n", "from email.message import EmailMessage\n", "import mimetypes\n", "import time\n", "import random" ] }, { "cell_type": "code", "execution_count": 21, "id": "f2834e6b", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:53.760095Z", "iopub.status.busy": "2023-01-25T10:10:53.759669Z", "iopub.status.idle": "2023-01-25T10:10:53.761238Z", "shell.execute_reply": "2023-01-25T10:10:53.761608Z" }, "papermill": { "duration": 0.172055, "end_time": "2023-01-25T10:10:53.761719", "exception": false, "start_time": "2023-01-25T10:10:53.589664", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "def build_msg(subj, to_addr, from_addr, body, att):\n", " msg = EmailMessage()\n", " msg[\"Subject\"] = subj\n", " msg[\"To\"] = to_addr\n", " #msg[\"To\"] = \"lafrite26@gmail.com\"\n", " msg[\"From\"] = from_addr\n", " msg.set_content(body)\n", "\n", " if att != []:\n", " ctype, encoding = mimetypes.guess_type(att)\n", " if ctype is None or encoding is not None:\n", " ctype = 'application/octet-stream'\n", " maintype, subtype = ctype.split('/', 1)\n", " with open(att, \"rb\") as f:\n", " msg.add_attachment(f.read(),\n", " maintype=maintype,\n", " subtype=subtype,\n", " filename=att.name)\n", " return msg\n" ] }, { "cell_type": "code", "execution_count": 26, "id": "30311066", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:54.092735Z", "iopub.status.busy": "2023-01-25T10:10:54.092359Z", "iopub.status.idle": "2023-01-25T10:10:54.093752Z", "shell.execute_reply": "2023-01-25T10:10:54.094067Z" }, "papermill": { "duration": 0.171075, "end_time": "2023-01-25T10:10:54.094155", "exception": false, "start_time": "2023-01-25T10:10:53.923080", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "send = 1\n", "fake = 0" ] }, { "cell_type": "code", "execution_count": 27, "id": "d31598c3", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:54.421572Z", "iopub.status.busy": "2023-01-25T10:10:54.421174Z", "iopub.status.idle": "2023-01-25T10:10:54.422388Z", "shell.execute_reply": "2023-01-25T10:10:54.422694Z" }, "papermill": { "duration": 0.169072, "end_time": "2023-01-25T10:10:54.422778", "exception": false, "start_time": "2023-01-25T10:10:54.253706", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "if send:\n", " if fake:\n", " server = smtplib.SMTP(\"localhost\", 8025)\n", " server.ehlo()\n", " else:\n", " server = smtplib.SMTP(\"smtps.ac-lyon.fr\", 587)\n", " server.ehlo()\n", " server.starttls()\n", " server.ehlo()\n", " server.login(\"bbertrand\", os.popen(\"pass Prof/Lyon/bbertrand\").read()[:-1]) " ] }, { "cell_type": "code", "execution_count": 28, "id": "ca5690d7", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:54.756285Z", "iopub.status.busy": "2023-01-25T10:10:54.755769Z", "iopub.status.idle": "2023-01-25T10:10:54.757783Z", "shell.execute_reply": "2023-01-25T10:10:54.757265Z" }, "papermill": { "duration": 0.175546, "end_time": "2023-01-25T10:10:54.757888", "exception": false, "start_time": "2023-01-25T10:10:54.582342", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "try:\n", " eleves_data = pd.read_csv(f\"../../{tribe}.csv\")\n", "except FileNotFoundError:\n", " try:\n", " eleves_data = pd.read_csv(f\"../{tribe}.csv\")\n", " except FileNotFoundError:\n", " eleves_data = pd.read_csv(f\"{tribe}.csv\")\n", "eleves_data.fillna(\"\", inplace=True)\n", "#eleves_data" ] }, { "cell_type": "code", "execution_count": 29, "id": "b676f878", "metadata": { "execution": { "iopub.execute_input": "2023-01-25T10:10:55.100648Z", "iopub.status.busy": "2023-01-25T10:10:55.099966Z", "iopub.status.idle": "2023-01-25T10:10:55.106862Z", "shell.execute_reply": "2023-01-25T10:10:55.106505Z" }, "papermill": { "duration": 0.185144, "end_time": "2023-01-25T10:10:55.106936", "exception": false, "start_time": "2023-01-25T10:10:54.921792", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\tBilan envoyé à ACHOUR Ilyes\n", "\tBilan envoyé à BELARBI Islem\n", "\tBilan envoyé à BEN ELALLID Hajar\n", "\tBilan envoyé à BISWAS Lina\n", "\tBilan envoyé à BOULAABA Rayan\n", "\tBilan envoyé à BREZUN Ines\n", "\tBilan envoyé à BUGNON Enzo\n", "\tBilan envoyé à CALLEWAERT Idaline\n", "\tBilan envoyé à CATTIN Clément\n", "\tBilan envoyé à CHRISTMANN Nathan\n", "\tBilan envoyé à DECOSTER Clément\n", "\tBilan envoyé à DEHIMAT Launy\n", "\tBilan envoyé à DUPONT Jessica\n", "\tBilan envoyé à GASAN Jéssica\n", "\tBilan envoyé à GEORGET Raphaël\n", "\tBilan envoyé à HABBAZ Hajar\n", "\tBilan envoyé à JACQUEMIER Samuel\n", "\tBilan envoyé à JACQUIER Juliette\n", "\tBilan envoyé à JOVIC Atanase\n", "\tBilan envoyé à KASSI Cheïma\n", "\tBilan envoyé à KICHENASSAMY Sanjay\n", "\tBilan envoyé à LE VEUZIT Adrien\n", "\tBilan envoyé à LETIF Ilef\n", "\tBilan envoyé à MANJALI Hiba\n", "Pas de rapport pour MUTTONI Lou\n", "\tBilan envoyé à NEIVA Hugo\n", "\tBilan envoyé à OLLIET Gioia\n", "\tBilan envoyé à PERNOT Gabin\n", "\tBilan envoyé à RIZZI Elisa\n", "\tBilan envoyé à ROSTANT Emma\n", "\tBilan envoyé à SIBABA Moaad\n", "\tBilan envoyé à SOUJOL Damien\n", "\tBilan envoyé à THORAL Fanny\n", "\tBilan envoyé à TOURRETTE Elise\n", "\tBilan envoyé à TROPHARDY Eline\n" ] } ], "source": [ "for e in eleves_data.iterrows():\n", " reportfilename = Path(f\"{date:%y%m%d}_{assessment}_{e[1]['Nom']}.pdf\")\n", " try:\n", " assert reportfilename.exists()\n", " except:\n", " print(f\"Pas de rapport pour {e[1]['Nom']}\")\n", " else:\n", " if e[1][\"mail\"] != \"\":\n", " if send:\n", " msg = build_msg(subject, e[1][\"mail\"], mailfrom, message, reportfilename)\n", " server.send_message(msg)\n", " print(f\"\\tBilan envoyé à {e[1]['Nom']}\")\n", " else:\n", " print(f\"Pas de mail pour {e[1]['Nom']}\")\n", " " ] }, { "cell_type": "code", "execution_count": null, "id": "78e914c1", "metadata": { "papermill": { "duration": 0.16472, "end_time": "2023-01-25T10:10:55.434152", "exception": false, "start_time": "2023-01-25T10:10:55.269432", "status": "completed" }, "tags": [] }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "24ff9733", "metadata": { "papermill": { "duration": 0.168541, "end_time": "2023-01-25T10:10:55.763611", "exception": false, "start_time": "2023-01-25T10:10:55.595070", "status": "completed" }, "tags": [] }, "outputs": [], "source": [] } ], "metadata": { "celltoolbar": "Diaporama", "extensions": { "jupyter_dashboards": { "activeView": "grid_default", "version": 1, "views": { "grid_default": { "cellMargin": 10, "defaultCellHeight": 20, "maxColumns": 12, "name": "grid", "type": "grid" }, "report_default": { "name": "report", "type": "report" } } } }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.9" }, "papermill": { "duration": 13.986796, "end_time": "2023-01-25T10:10:56.236269", "environment_variables": {}, "exception": null, "input_path": "templates/tpl_evaluation.ipynb", "output_path": "2gt1/230118_DS3/Ds3.ipynb", "parameters": { "assessment": "Ds3", "csv_file": "/home/lafrite/Cours/2022-2023/Notes/2gt1/230118_DS3.csv", "date": "18/01/23", "tribe": "2gt1" }, "start_time": "2023-01-25T10:10:42.249473", "version": "1.2.1" } }, "nbformat": 4, "nbformat_minor": 5 }