Changeset 007d57c in flexograder


Ignore:
Timestamp:
10/27/25 08:16:20 (3 months ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
master
Children:
e3e2cae
Parents:
de90836
Message:

changes related to ExamLayout

Location:
generator
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • generator/exam_generator.py

    rde90836 r007d57c  
    2525
    2626    def render_exam(self, exam: Exam) -> str:
     27        print(exam)
    2728        template = self.env.get_template("exam_template.jinja2")
    2829        return template.render(exam=exam)
     
    3435        exam = Exam.from_json_file(json_file)
    3536        exam.shuffle_options()
     37       
    3638        html = self.render_exam(exam)
    3739        return self.write_exam(exam, html)
  • generator/exam_template.jinja2

    rde90836 r007d57c  
    33<head>
    44  <meta charset="UTF-8">
    5   <title>{{ exam.meta.title }}</title>
     5  <title>{{ exam.title }}</title>
    66  <link rel="stylesheet" href="static/exam.css">
    77</head>
    88<body>
    9   <h1>{{ exam.meta.title }} – <span id="studentNameDisplay">(unbekannt)</span></h1>
    10   <h2 class="exam-headline">{{ exam.meta.headline }}</h2>
    11   <p><strong>Dauer:</strong> {{ exam.meta.duration }}</p>
    12   <p><strong>Erlaubte Hilfsmittel:</strong> {{ exam.meta.allowed_aids }}</p>
    13   <p>{{ exam.meta.intro_note }}</p>
     9  <h1>{{ exam.title }} – <span id="studentNameDisplay">(unbekannt)</span></h1>
     10  <h2 class="exam-headline">{{ exam.headline }}</h2>
     11  <p><strong>Dauer:</strong> {{ exam.duration }}</p>
     12  <p><strong>Erlaubte Hilfsmittel:</strong> {{ exam.allowed_aids }}</p>
     13  <p>{{ exam.intro_note }}</p>
    1414
    1515  <nav class="page-nav">
    1616    <h2>Seiten</h2>
    1717    <ul>
    18       {% for page in exam.pages %}
     18      {% for page in exam.layout.pages %}
    1919      <li><a href="#" class="nav-link" data-index="{{ loop.index0 }}">{{ loop.index }}. {{ page.title }}</a></li>
    2020      {% endfor %}
     
    2626    {% for page in exam.pages %}
    2727    <div class="page{% if loop.first %} active{% endif %}" data-index="{{ loop.index0 }}">
    28       {% for q in page.questions %}
     28      {% for qid in page.question_ids %}
    2929        {{ q.to_html() | safe }}
    3030      {% endfor %}
     
    9696      const result = {
    9797        meta: {
    98           test_id: "{{ exam.meta.exam_id | default('Unknown') }}",
    99           test_name: "{{ exam.meta.test_name | default(exam.meta.title) }}",
    100           created_on: "{{ exam.meta.created_on | default('Unknown') }}",
     98          test_id: "{{ exam.exam_id | default('Unknown') }}",
     99          test_name: "{{ exam.test_name | default(exam.title) }}",
     100          created_on: "{{ exam.created_on | default('Unknown') }}",
    101101          candidate_name: (document.querySelector('input[name="first_name"]')?.value || "Unknown") + " " + (document.querySelector('input[name="last_name"]')?.value || "Unknown"),
    102102          candidate_id: document.querySelector('input[name="personal_id"]')?.value || "Unknown",
     
    140140
    141141      const timestamp = new Date().toISOString().replaceAll(':', '-');
    142       const filename = `{{ exam.meta.exam_id }}-` + (document.querySelector('input[name="personal_id"]')?.value || "Unknown") + `-${timestamp}.json`;
     142      const filename = `{{ exam.exam_id }}-` + (document.querySelector('input[name="personal_id"]')?.value || "Unknown") + `-${timestamp}.json`;
    143143      const blob = new Blob([JSON.stringify(result, null, 2)], { type: "application/json" });
    144144      const url = URL.createObjectURL(blob);
Note: See TracChangeset for help on using the changeset viewer.