{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "25b1d95f", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:45.133979Z", "iopub.status.busy": "2023-03-22T18:59:45.133486Z", "iopub.status.idle": "2023-03-22T18:59:46.332784Z", "shell.execute_reply": "2023-03-22T18:59:46.333110Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 1.249939, "end_time": "2023-03-22T18:59:46.333237", "exception": false, "start_time": "2023-03-22T18:59:45.083298", "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": 3, "id": "3a865047", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:46.513154Z", "iopub.status.busy": "2023-03-22T18:59:46.512290Z", "iopub.status.idle": "2023-03-22T18:59:46.514896Z", "shell.execute_reply": "2023-03-22T18:59:46.514434Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.095549, "end_time": "2023-03-22T18:59:46.514994", "exception": false, "start_time": "2023-03-22T18:59:46.419445", "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": 4, "id": "ddc737ef", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:46.709939Z", "iopub.status.busy": "2023-03-22T18:59:46.709242Z", "iopub.status.idle": "2023-03-22T18:59:46.711120Z", "shell.execute_reply": "2023-03-22T18:59:46.711908Z" }, "papermill": { "duration": 0.106971, "end_time": "2023-03-22T18:59:46.712102", "exception": false, "start_time": "2023-03-22T18:59:46.605131", "status": "completed" }, "tags": [ "injected-parameters" ] }, "outputs": [], "source": [ "# Parameters\n", "tribe = \"2gt1\"\n", "assessment = \"Ds5\"\n", "date = \"17/03/23\"\n", "csv_file = \"/home/lafrite/Cours/2022-2023/Notes/2gt1/230317_DS5.csv\"\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "63832c37", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:46.930493Z", "iopub.status.busy": "2023-03-22T18:59:46.929507Z", "iopub.status.idle": "2023-03-22T18:59:46.932854Z", "shell.execute_reply": "2023-03-22T18:59:46.932323Z" }, "papermill": { "duration": 0.114284, "end_time": "2023-03-22T18:59:46.932955", "exception": false, "start_time": "2023-03-22T18:59:46.818671", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/lafrite/Cours/2022-2023/Notes/2gt1/230317_DS5\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": 6, "id": "2a41f502", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:47.162888Z", "iopub.status.busy": "2023-03-22T18:59:47.162159Z", "iopub.status.idle": "2023-03-22T18:59:47.165267Z", "shell.execute_reply": "2023-03-22T18:59:47.165694Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": false } } } }, "papermill": { "duration": 0.115595, "end_time": "2023-03-22T18:59:47.165806", "exception": false, "start_time": "2023-03-22T18:59:47.050211", "status": "completed" }, "slideshow": { "slide_type": "slide" }, "tags": [] }, "outputs": [ { "data": { "text/markdown": [ "# Ds5 (23/03/17) 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": 7, "id": "3149dc30", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:47.354570Z", "iopub.status.busy": "2023-03-22T18:59:47.354125Z", "iopub.status.idle": "2023-03-22T18:59:47.573248Z", "shell.execute_reply": "2023-03-22T18:59:47.572897Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.318356, "end_time": "2023-03-22T18:59:47.573331", "exception": false, "start_time": "2023-03-22T18:59:47.254975", "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": 8, "id": "48cb4a36", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:47.776015Z", "iopub.status.busy": "2023-03-22T18:59:47.775321Z", "iopub.status.idle": "2023-03-22T18:59:47.781287Z", "shell.execute_reply": "2023-03-22T18:59:47.780465Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.110983, "end_time": "2023-03-22T18:59:47.781469", "exception": false, "start_time": "2023-03-22T18:59:47.670486", "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": 9, "id": "15025186", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:47.975480Z", "iopub.status.busy": "2023-03-22T18:59:47.974932Z", "iopub.status.idle": "2023-03-22T18:59:47.983403Z", "shell.execute_reply": "2023-03-22T18:59:47.983835Z" }, "papermill": { "duration": 0.110396, "end_time": "2023-03-22T18:59:47.983967", "exception": false, "start_time": "2023-03-22T18:59:47.873571", "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 Ilyes1.6711
BELARBI Islem1.0011
BEN ELALLID Hajar4.6711
BISWAS Lina5.6611
BREZUN Ines6.3411
\n", "
" ], "text/plain": [ " Note Bareme\n", "Exercice Eleve \n", "Exercice 1 ACHOUR Ilyes 1.67 11\n", " BELARBI Islem 1.00 11\n", " BEN ELALLID Hajar 4.67 11\n", " BISWAS Lina 5.66 11\n", " BREZUN Ines 6.34 11" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "exercises_scores.head()" ] }, { "cell_type": "code", "execution_count": 10, "id": "71c672c0", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:48.200370Z", "iopub.status.busy": "2023-03-22T18:59:48.199918Z", "iopub.status.idle": "2023-03-22T18:59:48.201456Z", "shell.execute_reply": "2023-03-22T18:59:48.201937Z" }, "papermill": { "duration": 0.119507, "end_time": "2023-03-22T18:59:48.202067", "exception": false, "start_time": "2023-03-22T18:59:48.082560", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "assessment_scores = scores.groupby([\"Eleve\"]).agg({\"Note\": \"sum\", \"Bareme\": \"sum\"})" ] }, { "cell_type": "code", "execution_count": 11, "id": "d8a02878", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:48.415819Z", "iopub.status.busy": "2023-03-22T18:59:48.415089Z", "iopub.status.idle": "2023-03-22T18:59:48.417676Z", "shell.execute_reply": "2023-03-22T18:59:48.417275Z" }, "papermill": { "duration": 0.110912, "end_time": "2023-03-22T18:59:48.417760", "exception": false, "start_time": "2023-03-22T18:59:48.306848", "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": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scores.columns" ] }, { "cell_type": "code", "execution_count": 12, "id": "b6717594", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:48.626765Z", "iopub.status.busy": "2023-03-22T18:59:48.626237Z", "iopub.status.idle": "2023-03-22T18:59:48.632127Z", "shell.execute_reply": "2023-03-22T18:59:48.631628Z" }, "papermill": { "duration": 0.118852, "end_time": "2023-03-22T18:59:48.632229", "exception": false, "start_time": "2023-03-22T18:59:48.513377", "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": 13, "id": "d87553e1", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:48.837996Z", "iopub.status.busy": "2023-03-22T18:59:48.837574Z", "iopub.status.idle": "2023-03-22T18:59:48.838761Z", "shell.execute_reply": "2023-03-22T18:59:48.839111Z" }, "papermill": { "duration": 0.101612, "end_time": "2023-03-22T18:59:48.839203", "exception": false, "start_time": "2023-03-22T18:59:48.737591", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#domain_scores" ] }, { "cell_type": "code", "execution_count": 14, "id": "61a49219", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:49.026023Z", "iopub.status.busy": "2023-03-22T18:59:49.025388Z", "iopub.status.idle": "2023-03-22T18:59:49.030561Z", "shell.execute_reply": "2023-03-22T18:59:49.029921Z" }, "papermill": { "duration": 0.102316, "end_time": "2023-03-22T18:59:49.030697", "exception": false, "start_time": "2023-03-22T18:59:48.928381", "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": 15, "id": "7c8ad2c9", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:49.218219Z", "iopub.status.busy": "2023-03-22T18:59:49.211839Z", "iopub.status.idle": "2023-03-22T18:59:49.219990Z", "shell.execute_reply": "2023-03-22T18:59:49.220337Z" }, "papermill": { "duration": 0.100729, "end_time": "2023-03-22T18:59:49.220435", "exception": false, "start_time": "2023-03-22T18:59:49.119706", "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", " \n", "
NoteBaremeNormalized
EleveCompetence
TOURRETTE EliseReprésenter3.6750.73
TROPHARDY ElineCalculer12.00121.00
Communiquer2.0021.00
Raisonner6.3390.70
Représenter5.0051.00
\n", "
" ], "text/plain": [ " Note Bareme Normalized\n", "Eleve Competence \n", "TOURRETTE Elise Représenter 3.67 5 0.73\n", "TROPHARDY Eline Calculer 12.00 12 1.00\n", " Communiquer 2.00 2 1.00\n", " Raisonner 6.33 9 0.70\n", " Représenter 5.00 5 1.00" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "competence_scores.tail()" ] }, { "cell_type": "markdown", "id": "3437315d", "metadata": { "papermill": { "duration": 0.093844, "end_time": "2023-03-22T18:59:49.401472", "exception": false, "start_time": "2023-03-22T18:59:49.307628", "status": "completed" }, "tags": [] }, "source": [ "### Bilans personnalisés" ] }, { "cell_type": "code", "execution_count": 16, "id": "dd4fa512", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:49.599976Z", "iopub.status.busy": "2023-03-22T18:59:49.599355Z", "iopub.status.idle": "2023-03-22T18:59:49.616564Z", "shell.execute_reply": "2023-03-22T18:59:49.616051Z" }, "papermill": { "duration": 0.124578, "end_time": "2023-03-22T18:59:49.616658", "exception": false, "start_time": "2023-03-22T18:59:49.492080", "status": "completed" }, "scrolled": true, "tags": [] }, "outputs": [], "source": [ "import pytex\n", "#scores.head()" ] }, { "cell_type": "code", "execution_count": 17, "id": "6a667215", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:49.898247Z", "iopub.status.busy": "2023-03-22T18:59:49.828108Z", "iopub.status.idle": "2023-03-22T18:59:49.919789Z", "shell.execute_reply": "2023-03-22T18:59:49.920086Z" }, "papermill": { "duration": 0.199814, "end_time": "2023-03-22T18:59:49.920179", "exception": false, "start_time": "2023-03-22T18:59:49.720365", "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": 18, "id": "16b39fd6", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:50.107601Z", "iopub.status.busy": "2023-03-22T18:59:50.107117Z", "iopub.status.idle": "2023-03-22T18:59:50.108982Z", "shell.execute_reply": "2023-03-22T18:59:50.108593Z" }, "papermill": { "duration": 0.100234, "end_time": "2023-03-22T18:59:50.109057", "exception": false, "start_time": "2023-03-22T18:59:50.008823", "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": 19, "id": "e7d7716e", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:50.299385Z", "iopub.status.busy": "2023-03-22T18:59:50.298586Z", "iopub.status.idle": "2023-03-22T18:59:55.909497Z", "shell.execute_reply": "2023-03-22T18:59:55.907941Z" }, "papermill": { "duration": 5.708111, "end_time": "2023-03-22T18:59:55.909605", "exception": false, "start_time": "2023-03-22T18:59:50.201494", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wrote 230317_Ds5_ACHOUR Ilyes.tex\n", "Wrote 230317_Ds5_BELARBI Islem.tex\n", "Wrote 230317_Ds5_BEN ELALLID Hajar.tex\n", "Wrote 230317_Ds5_BISWAS Lina.tex\n", "Wrote 230317_Ds5_BREZUN Ines.tex\n", "Wrote 230317_Ds5_BUGNON Enzo.tex\n", "Wrote 230317_Ds5_CALLEWAERT Idaline.tex\n", "Wrote 230317_Ds5_CATTIN Clément.tex\n", "Wrote 230317_Ds5_DECOSTER Clément.tex\n", "Wrote 230317_Ds5_DEHIMAT Launy.tex\n", "Wrote 230317_Ds5_DUPONT Jessica.tex\n", "Wrote 230317_Ds5_GASAN Jéssica.tex\n", "Wrote 230317_Ds5_GEORGET Raphaël.tex\n", "Wrote 230317_Ds5_HABBAZ Hajar.tex\n", "Wrote 230317_Ds5_JACQUEMIER Samuel.tex\n", "Wrote 230317_Ds5_JACQUIER Juliette.tex\n", "Wrote 230317_Ds5_KASSI Cheïma.tex\n", "Wrote 230317_Ds5_KICHENASSAMY Sanjay.tex\n", "Wrote 230317_Ds5_LE VEUZIT Adrien.tex\n", "Wrote 230317_Ds5_LETIF Ilef.tex\n", "Wrote 230317_Ds5_MANJALI Hiba.tex\n", "Wrote 230317_Ds5_MUTTONI Lou.tex\n", "Wrote 230317_Ds5_NEIVA Hugo.tex\n", "Wrote 230317_Ds5_OLLIET Gioia.tex\n", "Wrote 230317_Ds5_PERNOT Gabin.tex\n", "Wrote 230317_Ds5_RIZZI Elisa.tex\n", "Wrote 230317_Ds5_SIBABA Moaad.tex\n", "Wrote 230317_Ds5_SOUJOL Damien.tex\n", "Wrote 230317_Ds5_THORAL Fanny.tex\n", "Wrote 230317_Ds5_TOURRETTE Elise.tex\n", "Wrote 230317_Ds5_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.232984, "end_time": "2023-03-22T18:59:56.336836", "exception": false, "start_time": "2023-03-22T18:59:56.103852", "status": "completed" }, "tags": [] }, "source": [ "## Envoie des bilans par mail" ] }, { "cell_type": "code", "execution_count": 22, "id": "76384db8", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:56.718566Z", "iopub.status.busy": "2023-03-22T18:59:56.717880Z", "iopub.status.idle": "2023-03-22T18:59:56.720732Z", "shell.execute_reply": "2023-03-22T18:59:56.721253Z" }, "papermill": { "duration": 0.201346, "end_time": "2023-03-22T18:59:56.721395", "exception": false, "start_time": "2023-03-22T18:59:56.520049", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Bilan du devoir Ds5\n", "Bonsoir,\n", "\n", "En pièce jointe, vous trouverez un document détaillant la note du devoir. La note est indiquée sur 28 mais sur Pronote le devoir est sur 25 et votre note est concervée.\n", "\n", "Bonne soirée\n", "B.Bertrand\n", "\n" ] } ], "source": [ "mailfrom = \"benjamin.bertrand@ac-lyon.fr\"\n", "subject = f\"Bilan du devoir {assessment}\"\n", "message = \"\"\"Bonsoir,\n", "\n", "En pièce jointe, vous trouverez un document détaillant la note du devoir. La note est indiquée sur 28 mais sur Pronote le devoir est sur 25 et votre note est concervée.\n", "\n", "Bonne soirée\n", "B.Bertrand\n", "\"\"\"\n", "print(subject)\n", "print(message)" ] }, { "cell_type": "code", "execution_count": 23, "id": "71eb9a2b", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:57.114556Z", "iopub.status.busy": "2023-03-22T18:59:57.114169Z", "iopub.status.idle": "2023-03-22T18:59:57.124564Z", "shell.execute_reply": "2023-03-22T18:59:57.124222Z" }, "papermill": { "duration": 0.203179, "end_time": "2023-03-22T18:59:57.124643", "exception": false, "start_time": "2023-03-22T18:59:56.921464", "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": 24, "id": "f2834e6b", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:57.524663Z", "iopub.status.busy": "2023-03-22T18:59:57.524105Z", "iopub.status.idle": "2023-03-22T18:59:57.526004Z", "shell.execute_reply": "2023-03-22T18:59:57.525550Z" }, "papermill": { "duration": 0.203135, "end_time": "2023-03-22T18:59:57.526094", "exception": false, "start_time": "2023-03-22T18:59:57.322959", "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": 25, "id": "30311066", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:57.979139Z", "iopub.status.busy": "2023-03-22T18:59:57.978242Z", "iopub.status.idle": "2023-03-22T18:59:57.981041Z", "shell.execute_reply": "2023-03-22T18:59:57.980647Z" }, "papermill": { "duration": 0.208705, "end_time": "2023-03-22T18:59:57.981120", "exception": false, "start_time": "2023-03-22T18:59:57.772415", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "send = 1\n", "fake = 0" ] }, { "cell_type": "code", "execution_count": 26, "id": "d31598c3", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:58.382621Z", "iopub.status.busy": "2023-03-22T18:59:58.380767Z", "iopub.status.idle": "2023-03-22T18:59:58.384733Z", "shell.execute_reply": "2023-03-22T18:59:58.384266Z" }, "papermill": { "duration": 0.207253, "end_time": "2023-03-22T18:59:58.384833", "exception": false, "start_time": "2023-03-22T18:59:58.177580", "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": 27, "id": "ca5690d7", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:58.779459Z", "iopub.status.busy": "2023-03-22T18:59:58.779046Z", "iopub.status.idle": "2023-03-22T18:59:58.782692Z", "shell.execute_reply": "2023-03-22T18:59:58.783047Z" }, "papermill": { "duration": 0.210198, "end_time": "2023-03-22T18:59:58.783147", "exception": false, "start_time": "2023-03-22T18:59:58.572949", "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": 28, "id": "b676f878", "metadata": { "execution": { "iopub.execute_input": "2023-03-22T18:59:59.174832Z", "iopub.status.busy": "2023-03-22T18:59:59.171162Z", "iopub.status.idle": "2023-03-22T18:59:59.182796Z", "shell.execute_reply": "2023-03-22T18:59:59.183134Z" }, "papermill": { "duration": 0.208888, "end_time": "2023-03-22T18:59:59.183238", "exception": false, "start_time": "2023-03-22T18:59:58.974350", "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", "Pas de rapport pour BOULAABA Rayan\n", "\tBilan envoyé à BREZUN Ines\n", "\tBilan envoyé à BUGNON Enzo\n", "\tBilan envoyé à CALLEWAERT Idaline\n", "\tBilan envoyé à CATTIN Clément\n", "Pas de rapport pour 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", "Pas de rapport pour 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", "\tBilan envoyé à MUTTONI Lou\n", "\tBilan envoyé à NEIVA Hugo\n", "\tBilan envoyé à OLLIET Gioia\n", "\tBilan envoyé à PERNOT Gabin\n", "\tBilan envoyé à RIZZI Elisa\n", "Pas de rapport pour 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.292551, "end_time": "2023-03-22T18:59:59.649462", "exception": false, "start_time": "2023-03-22T18:59:59.356911", "status": "completed" }, "tags": [] }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "24ff9733", "metadata": { "papermill": { "duration": 0.185829, "end_time": "2023-03-22T19:00:00.061972", "exception": false, "start_time": "2023-03-22T18:59:59.876143", "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.10" }, "papermill": { "duration": 16.839607, "end_time": "2023-03-22T19:00:00.732140", "environment_variables": {}, "exception": null, "input_path": "templates/tpl_evaluation.ipynb", "output_path": "2gt1/230317_DS5/Ds5.ipynb", "parameters": { "assessment": "Ds5", "csv_file": "/home/lafrite/Cours/2022-2023/Notes/2gt1/230317_DS5.csv", "date": "17/03/23", "tribe": "2gt1" }, "start_time": "2023-03-22T18:59:43.892533", "version": "1.2.1" } }, "nbformat": 4, "nbformat_minor": 5 }