'pintamos' HTML+CSS las puntuaciones !
This commit is contained in:
parent
032c06061b
commit
d6d3a3feb2
|
@ -0,0 +1,20 @@
|
|||
{# templates/results.html #}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Results</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>{{ test_name }} ResultadOS: </h1>
|
||||
<ul>
|
||||
{% for student in students %}
|
||||
<li>
|
||||
<em>{{ student.name }}:</em> {{ student.score }}/{{ max_score }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -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}")
|
||||
|
|
Loading…
Reference in New Issue