'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/"))
|
environment = Environment(loader=FileSystemLoader("templates/"))
|
||||||
template = environment.get_template("message.txt")
|
template = environment.get_template("message.txt")
|
||||||
|
|
||||||
for student in students:
|
|
||||||
filename = f"message_{student['name'].lower()}.txt"
|
results_filename = "students_results.html"
|
||||||
content = template.render(
|
results_template = environment.get_template("results.html")
|
||||||
student,
|
context = {
|
||||||
max_score=max_score,
|
"students": students,
|
||||||
test_name=test_name
|
"test_name": test_name,
|
||||||
)
|
"max_score": max_score,
|
||||||
with open(filename, mode="w", encoding="utf-8") as message:
|
}
|
||||||
message.write(content)
|
with open(results_filename, mode="w", encoding="utf-8") as results:
|
||||||
print(f"... wrote {filename}")
|
results.write(results_template.render(context))
|
||||||
|
print(f"... wrote {results_filename}")
|
||||||
|
|
Loading…
Reference in New Issue