From ca84cb1aa2d7f1353a764ca34ab7ea91d30a03a9 Mon Sep 17 00:00:00 2001 From: daxid <david.rouquet@tetras-libre.fr> Date: Sat, 11 Jan 2025 16:55:47 +0100 Subject: [PATCH] Changes to order choices --- tetras_extraction/script/src/extract_page.py | 2 +- tetras_extraction/script/templates/qcu.rq | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tetras_extraction/script/src/extract_page.py b/tetras_extraction/script/src/extract_page.py index 685fcac..88bd027 100644 --- a/tetras_extraction/script/src/extract_page.py +++ b/tetras_extraction/script/src/extract_page.py @@ -227,7 +227,7 @@ class ExerciceQC(Exercice): def save(self, graph: Graph): super().save(graph) for choice in self.choices.values(): - rdf_name = f"{self.id}_{choice.id}" # ex: pg157_2, pg173_rep21 + rdf_name = f"{self.id}_{choice.index}_{choice.id}" # ex: pg157_2, pg173_rep21 display_name = rdf_name + " | " + ("V" if choice.is_correct else "F") choice_node = NS[rdf_name] graph.add((choice_node, RDF.type, NS["Reponse"])) diff --git a/tetras_extraction/script/templates/qcu.rq b/tetras_extraction/script/templates/qcu.rq index c6fa414..cdc12e7 100644 --- a/tetras_extraction/script/templates/qcu.rq +++ b/tetras_extraction/script/templates/qcu.rq @@ -26,16 +26,18 @@ template mt:qcu(?qcu) { '"correctAnswer": ' coalesce(?correct_choice_index, "-1") } where { - ?qcu a :ExerciceQC_QCU + ?qcu a :ExerciceQC_QCU . ?qcu :id ?id . - optional { + #optional { ?qcu :aReponse ?choice . ?choice :index ?choice_index . - ?choice :html_md ?choice_html - } - optional { + ?choice :html_md ?choice_html . + #} + #optional { ?qcu :aReponse ?correct_choice . ?correct_choice :correct true . ?correct_choice :index ?correct_choice_index . - } + #} } +ORDER BY ?choice_index + -- GitLab