From d6d3a3feb2bd2e33a393ec1e71a93d1b819faac2 Mon Sep 17 00:00:00 2001 From: fenix Date: Mon, 12 Feb 2024 17:39:27 +0100 Subject: [PATCH] 'pintamos' HTML+CSS las puntuaciones ! --- templates/results.html | 20 ++++++++++++++++++++ write_messages.py | 21 +++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 templates/results.html diff --git a/templates/results.html b/templates/results.html new file mode 100644 index 0000000..e465a51 --- /dev/null +++ b/templates/results.html @@ -0,0 +1,20 @@ +{# templates/results.html #} + + + + + + Results + + + +

{{ test_name }} ResultadOS:

+ + + diff --git a/write_messages.py b/write_messages.py index 02f65d9..5f789ef 100644 --- a/write_messages.py +++ b/write_messages.py @@ -15,13 +15,14 @@ students = [ environment = Environment(loader=FileSystemLoader("templates/")) template = environment.get_template("message.txt") -for student in students: - filename = f"message_{student['name'].lower()}.txt" - content = template.render( - student, - max_score=max_score, - test_name=test_name - ) - with open(filename, mode="w", encoding="utf-8") as message: - message.write(content) - print(f"... wrote {filename}") + +results_filename = "students_results.html" +results_template = environment.get_template("results.html") +context = { + "students": students, + "test_name": test_name, + "max_score": max_score, +} +with open(results_filename, mode="w", encoding="utf-8") as results: + results.write(results_template.render(context)) + print(f"... wrote {results_filename}")