Changeset b0deaac in flexograder


Ignore:
Timestamp:
01/20/26 11:03:27 (6 weeks ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
main, master
Children:
f0501da
Parents:
a8a8ecd
Message:

prevent removing IDForm once added and fixing missing dialog result

Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • flexograder/core_entities/exam.py

    ra8a8ecd rb0deaac  
    197197            if isinstance(each_question, ChoiceQuestion):
    198198                each_question.shuffle_answers()
     199
     200    def has_id_form(self) -> bool:
     201        """Return True if the exam contains an IDForm element."""
     202        return any(isinstance(e, IDForm) for e in self.elements.values())
    199203
    200204    @property
  • flexograder/gui/create_exam_dialog.py

    ra8a8ecd rb0deaac  
    77    def __init__(self, parent, title=None, exam=None):
    88        self.exam = exam  # may be None
     9        self.result = None
    910        super().__init__(parent, title)
    1011
     
    5152        # Structural defaults
    5253        # ─────────────────────────────
    53         self.var_id_form = tk.BooleanVar(value=True)
     54        has_id_form = self.exam.has_id_form() if self.exam is not None else True
     55        self.var_id_form = tk.BooleanVar(value=has_id_form)
    5456        self.var_instruction_block = tk.BooleanVar(value=True)
    5557
  • flexograder/gui/exam_layout_editor.py

    ra8a8ecd rb0deaac  
    120120        ttk.Button(footer, text="Cancel", command=self.destroy).pack(side="right", padx=5)
    121121
    122 
    123122    def edit_metadata(self):
    124123        dialog = ExamDialog(parent=self, title="Edit Metadata", exam=self.exam)
     124        if dialog.result is None:
     125            return
    125126        self.exam.title=dialog.result["title"]
    126127        self.exam.author=dialog.result["author"]
     
    129130        self.exam.allowed_aids=dialog.result["allowed_aids"]
    130131        self.exam.duration=dialog.result["duration"]
     132        print(dialog.result["include_id_form"])
    131133        if dialog.result["include_id_form"]:
    132134            self.exam.add_default_id_form()
     135        else:
     136            messagebox.showinfo("Deletion impossible", "Once added IDForm can not be removed.")
    133137        self.exam._update_fingerprint()
    134138
     
    184188            return
    185189        page = self.layout.pages[idx[0]]
    186         new_name = simpledialog.askstring("Rename Page", "New title:", initialvalue=page.title, parent=self)
     190        new_name = simpledialog.askstring("Rename Page", "New title:",
     191                                          initialvalue=page.title, parent=self)
    187192        if new_name:
    188193            page.title = new_name
Note: See TracChangeset for help on using the changeset viewer.