Ok, the video is in italian, but I think it is easy to understand. This code makes you able to create different test for every student. The different tests can be created with random data and then sent to every student in one run of the script. The script also get the solution saved in a file, so that your work to correct the tests is really easy.
Vediamo come si possono creare test con dati diversi, creati in automatico da Python, inviarli in una sola volta a tutti gli studenti e avere anche la correzione dei compiti salvata su file di testo.
import smtplib from random import choice import os # change the password as you see in the last post password = "xxxxxxxxxxxxxxxxxxxx" pss = { "dDApofsfdsflito": "010", "wGdiordsdfsasaano": "001", "fGuaafrisdfglia": "100", } destinatari = [ "[email protected]", "[email protected]","[email protected]", ] schema = """ Your code is {} Write what is {} x {} The exercise is here https://formazione.github.io/Programmi20192020/text_5bs/quiz/risposta_email_02.html """ numeri = [1, 3, 5, 7] messaggi = [] soluzioni = [] for s in pss: num1, num2 = choice(numeri), choice(numeri) traccia = schema.format(pss[s], num1, num2) messaggi.append(traccia) soluzioni.append(s + "\n" + traccia + "[S: " + str(num1 * num2) + "]\n\n") with open("soluzioni.txt", "w") as file: file.write("".join(soluzioni)) print(*soluzioni) os.startfile("soluzioni.txt") def manda_email(): for n, mess in enumerate(messaggi): server = smtplib.SMTP("smtp.gmail.com", 587) server.ehlo() server.starttls() server.ehlo() server.login("[email protected]", password) server.sendmail( "[email protected]", destinatari[n], messaggi[n]) server.quit() manda_email()
Subscribe to the newsletter for updates
Tkinter templates
My youtube channel
Twitter: @pythonprogrammi - python_pygame