From 6d50750d0047762a706819d47f07980b34646cb8 Mon Sep 17 00:00:00 2001 From: eliott <eliott.sammier@tetras-libre.fr> Date: Mon, 24 Jun 2024 17:02:31 +0200 Subject: [PATCH] Add STTL templates from prototype --- .../macao_12/script/templates/array.rq | 11 +++++++ .../macao_12/script/templates/functions.rq | 15 ++++++++++ .../macao_12/script/templates/main.rq | 16 ++++++++++ .../macao_12/script/templates/page.rq | 29 ++++++++++++++++++ .../macao_12/script/templates/qcu.rq | 30 +++++++++++++++++++ .../macao_12/script/templates/qcu_choices.rq | 14 +++++++++ .../macao_12/script/templates/quiz.rq | 30 +++++++++++++++++++ 7 files changed, 145 insertions(+) create mode 100644 tetras_extraction/macao_12/script/templates/array.rq create mode 100644 tetras_extraction/macao_12/script/templates/functions.rq create mode 100644 tetras_extraction/macao_12/script/templates/main.rq create mode 100644 tetras_extraction/macao_12/script/templates/page.rq create mode 100644 tetras_extraction/macao_12/script/templates/qcu.rq create mode 100644 tetras_extraction/macao_12/script/templates/qcu_choices.rq create mode 100644 tetras_extraction/macao_12/script/templates/quiz.rq diff --git a/tetras_extraction/macao_12/script/templates/array.rq b/tetras_extraction/macao_12/script/templates/array.rq new file mode 100644 index 00000000..9bc0ddd9 --- /dev/null +++ b/tetras_extraction/macao_12/script/templates/array.rq @@ -0,0 +1,11 @@ +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/macao_12/script/templates/functions.rq b/tetras_extraction/macao_12/script/templates/functions.rq new file mode 100644 index 00000000..65b0dffc --- /dev/null +++ b/tetras_extraction/macao_12/script/templates/functions.rq @@ -0,0 +1,15 @@ +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 st:profile {} +where {} + +function st:process(?x) { + # Format literals as text without quotes + if (isLiteral(?x), st:format("%s", ?x), st:turtle(?x)) +} + +function testtl:sep() { + st:format(",%s", st:nl()) +} \ No newline at end of file diff --git a/tetras_extraction/macao_12/script/templates/main.rq b/tetras_extraction/macao_12/script/templates/main.rq new file mode 100644 index 00000000..c7ce4860 --- /dev/null +++ b/tetras_extraction/macao_12/script/templates/main.rq @@ -0,0 +1,16 @@ +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/> +PREFIX owl: <http://www.w3.org/2002/07/owl#> + +template { + ?id " -> " ?title +} +where { + ?subj a :ExerciceQC_QCU . + ?subj :id ?id + optional { + ?subj :titre ?title . + } +} + diff --git a/tetras_extraction/macao_12/script/templates/page.rq b/tetras_extraction/macao_12/script/templates/page.rq new file mode 100644 index 00000000..109fc6c3 --- /dev/null +++ b/tetras_extraction/macao_12/script/templates/page.rq @@ -0,0 +1,29 @@ +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/> +PREFIX owl: <http://www.w3.org/2002/07/owl#> + +template { + "####### " + ?id + format { + """ ++++ +title = "%s" ++++ + +%s +""" + ?title + ?desc + } + "-------------------------------------------------------------------------" + st:call-template(testtl:quiz, ?subj) +} +where { + ?subj a :Page . + ?subj :id ?id . + ?subj :titre ?title . + ?subj :description ?desc +} + diff --git a/tetras_extraction/macao_12/script/templates/qcu.rq b/tetras_extraction/macao_12/script/templates/qcu.rq new file mode 100644 index 00000000..5047c4a2 --- /dev/null +++ b/tetras_extraction/macao_12/script/templates/qcu.rq @@ -0,0 +1,30 @@ +PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/> +PREFIX mt: <http://www.semanticweb.org/eliott/test/> +PREFIX st: <http://ns.inria.fr/sparql-template/> + +template mt:qcu(?qcu) { + '"name": "' ?id '"' mt:sep() + '"type": "radiogroup"' mt:sep() + '"choices": [' + # box { st:call-template(mt:qcu_choices, ?qcu) } + box { + group { + '"' ?html '"' + ; separator=mt:sep() + } + } + ']' mt:sep() + '"correctAnswer": "' ?correct_choice '"' +} +where { + # ?qcu a :ExerciceQC_QCU + ?qcu :id ?id . + optional { + ?qcu :aReponse ?cchoice . + ?cchoice :correct true + ?cchoice :text ?correct_choice . + + ?qcu :aReponse ?choice . + ?choice :text ?html + } +} diff --git a/tetras_extraction/macao_12/script/templates/qcu_choices.rq b/tetras_extraction/macao_12/script/templates/qcu_choices.rq new file mode 100644 index 00000000..988ed9dd --- /dev/null +++ b/tetras_extraction/macao_12/script/templates/qcu_choices.rq @@ -0,0 +1,14 @@ +PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/> +PREFIX mt: <http://www.semanticweb.org/eliott/test/> +PREFIX st: <http://ns.inria.fr/sparql-template/> + +template mt:qcu_choices(?qcu) { + group { + '"' ?html '"' + ; separator=mt:sep() + } +} +where { + ?qcu :aReponse ?choice . + ?choice :text ?html +} diff --git a/tetras_extraction/macao_12/script/templates/quiz.rq b/tetras_extraction/macao_12/script/templates/quiz.rq new file mode 100644 index 00000000..26dd97f1 --- /dev/null +++ b/tetras_extraction/macao_12/script/templates/quiz.rq @@ -0,0 +1,30 @@ +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:quiz(?quiz) { + st:nl() + '{' + box { + '"elements": [' + box { + st:call-template(testtl:qcu, ?quiz) + } + ']' + } + '}' +# format { +# """ +# { +# "elements": [ +# %s +# ] +# } +# """ +# box { st:call-template(testtl:qcu, ?quiz) } +# } +} +where { + ?quiz :id ?id . +} + -- GitLab