diff --git a/tetras_extraction/script/templates/activite.rq b/tetras_extraction/script/templates/activite.rq index 243f45e8461c4a59c831fe528283f9e8732e2339..485db41652eb5985bd95dbb0004709a7d753bc3b 100644 --- a/tetras_extraction/script/templates/activite.rq +++ b/tetras_extraction/script/templates/activite.rq @@ -6,19 +6,15 @@ PREFIX owl: <http://www.w3.org/2002/07/owl#> # Generic Activity template that creates a Markdown page with Hugo front-matter, # and calls other specific templates when necessary template mt:activite(?act) { - mt:start_marker(?act) "/index.md" st:nl() - format { - """+++ -title = "%s" -weight = %s0 -+++ + mt:start_marker(?act) "/index.md" st:nl() + '+++' st:nl() + 'title = "' ?title '"' st:nl() + # This is how optional variables (may be unbound) are handled + coalesce(st:format('weight = %s\n', ?weight * 10), "") + '+++' st:nl() st:nl() -%s -""" - ?title - ?weight - ?desc - } + ?desc st:nl() + # Insert a Hugo shortcode to load the quiz if this is a quiz activity if (exists { ?act a :Exercice }, "\n{{< quiz >}}", "") st:call-template(mt:quiz, ?act) diff --git a/tetras_extraction/script/templates/array.rq b/tetras_extraction/script/templates/array.rq deleted file mode 100644 index 9bc0ddd92cb0e45d9325357876ffa2d8cbd3a17b..0000000000000000000000000000000000000000 --- a/tetras_extraction/script/templates/array.rq +++ /dev/null @@ -1,11 +0,0 @@ -PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/> -PREFIX testtl: <http://www.semanticweb.org/eliott/test/> -PREFIX st: <http://ns.inria.fr/sparql-template/> - -template testtl:array(?qcu) { - format { '"%s"' ?html } -} -where { - ?qcu :aReponse ?choice . - ?choice :html ?html -} diff --git a/tetras_extraction/script/templates/qcu.rq b/tetras_extraction/script/templates/qcu.rq index 63cf76e1b84b8a658c79eb485865e345fa00e444..e55e895f2481983d6fe845bbb667420ac8b1155c 100644 --- a/tetras_extraction/script/templates/qcu.rq +++ b/tetras_extraction/script/templates/qcu.rq @@ -23,7 +23,7 @@ template mt:qcu(?qcu) { } } ']' mt:sep() - '"correctAnswer": ' if(bound(?correct_choice_index), ?correct_choice_index, "-1") + '"correctAnswer": ' coalesce(?correct_choice_index, "-1") } where { ?qcu a :ExerciceQC_QCU diff --git a/tetras_extraction/script/templates/quiz.rq b/tetras_extraction/script/templates/quiz.rq index 4d3f573b8f7bd3899bdf66b17e0cdafbace87311..95f4af238877b0c023aa8e5bd47b2825db4aa965 100644 --- a/tetras_extraction/script/templates/quiz.rq +++ b/tetras_extraction/script/templates/quiz.rq @@ -17,12 +17,12 @@ template mt:quiz(?quiz) { # Unfortunately, STTL doesn't have a concise syntax for blocks # that depend on a variable being bound, we have to use # SPARQL functions and st:format - if (bound(?correct_comment), st:format( + coalesce(st:format( '%s"correctComment": "%s"', mt:sep(), mt:json_escape(?correct_comment) ), "") - if (bound(?incorrect_comment), st:format( + coalesce(st:format( '%s"incorrectComment": "%s"', mt:sep(), mt:json_escape(?incorrect_comment)