{ "cells": [ { "cell_type": "code", "execution_count": 5, "id": "25b1d95f", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:07.404860Z", "iopub.status.busy": "2022-09-27T11:48:07.404445Z", "iopub.status.idle": "2022-09-27T11:48:07.901434Z", "shell.execute_reply": "2022-09-27T11:48:07.901038Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": true } } } }, "papermill": { "duration": 0.551055, "end_time": "2022-09-27T11:48:07.901510", "exception": false, "start_time": "2022-09-27T11:48:07.350455", "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": 6, "id": "05307eef", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:08.209887Z", "iopub.status.busy": "2022-09-27T11:48:08.209511Z", "iopub.status.idle": "2022-09-27T11:48:08.210992Z", "shell.execute_reply": "2022-09-27T11:48:08.211278Z" }, "papermill": { "duration": 0.081194, "end_time": "2022-09-27T11:48:08.211363", "exception": false, "start_time": "2022-09-27T11:48:08.130169", "status": "completed" }, "tags": [ "injected-parameters" ] }, "outputs": [], "source": [ "# Parameters\n", "tribe = \"2gt1\"\n", "assessment = \"Ds2 - QCM\"\n", "date = \"14/12/22\"\n" ] }, { "cell_type": "code", "execution_count": 9, "id": "2a41f502", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:08.528130Z", "iopub.status.busy": "2022-09-27T11:48:08.527692Z", "iopub.status.idle": "2022-09-27T11:48:08.530503Z", "shell.execute_reply": "2022-09-27T11:48:08.530107Z" }, "extensions": { "jupyter_dashboards": { "version": 1, "views": { "grid_default": {}, "report_default": { "hidden": false } } } }, "papermill": { "duration": 0.086523, "end_time": "2022-09-27T11:48:08.530574", "exception": false, "start_time": "2022-09-27T11:48:08.444051", "status": "completed" }, "slideshow": { "slide_type": "slide" }, "tags": [] }, "outputs": [ { "data": { "text/markdown": [ "# Ds2 - QCM (22/12/14) 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": "markdown", "id": "dfaf5d3d", "metadata": { "papermill": { "duration": 0.211414, "end_time": "2022-09-27T11:48:16.462524", "exception": false, "start_time": "2022-09-27T11:48:16.251110", "status": "completed" }, "tags": [] }, "source": [ "## Envoie des bilans par mail" ] }, { "cell_type": "code", "execution_count": 10, "id": "76384db8", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:16.782829Z", "iopub.status.busy": "2022-09-27T11:48:16.781664Z", "iopub.status.idle": "2022-09-27T11:48:16.784344Z", "shell.execute_reply": "2022-09-27T11:48:16.784663Z" }, "papermill": { "duration": 0.164784, "end_time": "2022-09-27T11:48:16.784751", "exception": false, "start_time": "2022-09-27T11:48:16.619967", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Correction du Ds2 - QCM\n", "Bonjour,\n", " \n", "\n", "En pièce jointe, vous trouverez un document détaillant la note du devoir.\n", "\n", "B.Bertrand\n", "\n" ] } ], "source": [ "mailfrom = \"benjamin.bertrand@ac-lyon.fr\"\n", "subject = f\"Correction du {assessment}\"\n", "message = \"\"\"Bonjour,\n", " \n", "\n", "En pièce jointe, vous trouverez un document détaillant la note du devoir.\n", "\n", "B.Bertrand\n", "\"\"\"\n", "print(subject)\n", "print(message)" ] }, { "cell_type": "code", "execution_count": 11, "id": "71eb9a2b", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:17.100522Z", "iopub.status.busy": "2022-09-27T11:48:17.100107Z", "iopub.status.idle": "2022-09-27T11:48:17.102673Z", "shell.execute_reply": "2022-09-27T11:48:17.103005Z" }, "papermill": { "duration": 0.163488, "end_time": "2022-09-27T11:48:17.103104", "exception": false, "start_time": "2022-09-27T11:48:16.939616", "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": 12, "id": "f2834e6b", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:17.420901Z", "iopub.status.busy": "2022-09-27T11:48:17.420509Z", "iopub.status.idle": "2022-09-27T11:48:17.421953Z", "shell.execute_reply": "2022-09-27T11:48:17.422265Z" }, "papermill": { "duration": 0.164253, "end_time": "2022-09-27T11:48:17.422351", "exception": false, "start_time": "2022-09-27T11:48:17.258098", "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": 29, "id": "30311066", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:17.745613Z", "iopub.status.busy": "2022-09-27T11:48:17.745207Z", "iopub.status.idle": "2022-09-27T11:48:17.747015Z", "shell.execute_reply": "2022-09-27T11:48:17.746650Z" }, "papermill": { "duration": 0.16894, "end_time": "2022-09-27T11:48:17.747088", "exception": false, "start_time": "2022-09-27T11:48:17.578148", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "send = 1\n", "fake = 0" ] }, { "cell_type": "code", "execution_count": 30, "id": "d31598c3", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:18.064312Z", "iopub.status.busy": "2022-09-27T11:48:18.063922Z", "iopub.status.idle": "2022-09-27T11:48:18.066069Z", "shell.execute_reply": "2022-09-27T11:48:18.065585Z" }, "papermill": { "duration": 0.1633, "end_time": "2022-09-27T11:48:18.066161", "exception": false, "start_time": "2022-09-27T11:48:17.902861", "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": 31, "id": "ca5690d7", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:18.388603Z", "iopub.status.busy": "2022-09-27T11:48:18.388156Z", "iopub.status.idle": "2022-09-27T11:48:18.389976Z", "shell.execute_reply": "2022-09-27T11:48:18.389545Z" }, "papermill": { "duration": 0.168321, "end_time": "2022-09-27T11:48:18.390057", "exception": false, "start_time": "2022-09-27T11:48:18.221736", "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": 32, "id": "b676f878", "metadata": { "execution": { "iopub.execute_input": "2022-09-27T11:48:18.712395Z", "iopub.status.busy": "2022-09-27T11:48:18.711804Z", "iopub.status.idle": "2022-09-27T11:48:18.718564Z", "shell.execute_reply": "2022-09-27T11:48:18.718888Z" }, "papermill": { "duration": 0.170407, "end_time": "2022-09-27T11:48:18.718993", "exception": false, "start_time": "2022-09-27T11:48:18.548586", "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", "Pas de rapport pour 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", "\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", "\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": [ "\n", "from unidecode import unidecode\n", "for e in eleves_data.iterrows():\n", " formated_name = unidecode(e[1]['Nom'].replace(' ', '_'))\n", " reportfilename = Path(f\"correction/{formated_name}.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.158787, "end_time": "2022-09-27T11:48:19.033692", "exception": false, "start_time": "2022-09-27T11:48:18.874905", "status": "completed" }, "tags": [] }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "24ff9733", "metadata": { "papermill": { "duration": 0.166951, "end_time": "2022-09-27T11:48:19.360034", "exception": false, "start_time": "2022-09-27T11:48:19.193083", "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.8" }, "papermill": { "duration": 13.463594, "end_time": "2022-09-27T11:48:19.827083", "environment_variables": {}, "exception": null, "input_path": "templates/tpl_evaluation.ipynb", "output_path": "2gt1/220922_DS1/Ds1.ipynb", "parameters": { "assessment": "Ds1", "csv_file": "/home/lafrite/Cours/2022-2023/Notes/2gt1/220922_DS1.csv", "date": "22/09/22", "tribe": "2gt1" }, "start_time": "2022-09-27T11:48:06.363489", "version": "1.2.1" } }, "nbformat": 4, "nbformat_minor": 5 }