Skip to content
Snippets Groups Projects
Commit 709bcc58 authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Cleanup, comments, fix QCU choices template

parent 80ca03f5
Branches
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
"recommendations": [
"detachhead.basedpyright",
"ms-python.black-formatter",
"ms-python.isort"
"ms-python.isort",
"gruntfuggly.todo-tree"
]
}
\ No newline at end of file
PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/>
PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
PREFIX st: <http://ns.inria.fr/sparql-template/>
template mt:qcu_choices(?qcu) {
group {
'"' ?html '"'
; separator=mt:sep()
}
template mt:debug(?subj) {
group { ?type " " }
}
where {
?qcu :aReponse ?choice .
?choice :text ?html
?subj a ?type
FILTER(STRSTARTS(?type, :))
}
\ No newline at end of file
......@@ -2,14 +2,28 @@ PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/>
PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
PREFIX st: <http://ns.inria.fr/sparql-template/>
# The global empty template used to define functions.
template st:profile {}
where {}
# This special function is called for every node (blank, URI, literal)
# used in any template.
function st:process(?x) {
# Format literals as text without quotes
if (isLiteral(?x), st:format("%s", ?x), st:turtle(?x))
# Format literals as text without quotes, and strip Macao prefix
# from URIs
# FIXME: literals are also trimmed in length for debug readability
if (isLiteral(?x),
# st:format("%s", ?x),
substr(?x, 0 , 40),
if (isURI(?x),
replace(?x, :, ":"),
st:turtle(?x)
)
)
}
# JSON lines often end with a comma, and st:nl() is a newline
# with the current indent level (see the docs).
function mt:sep() {
st:format(",%s", st:nl())
}
\ No newline at end of file
PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/>
PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
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 .
}
}
......@@ -3,9 +3,13 @@ PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
PREFIX st: <http://ns.inria.fr/sparql-template/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
# Entry point of the template set.
# Generic Activity template that creates a Markdown page with Hugo front-matter,
# and calls other specific templates when necessary
template {
"####### "
?id
"####### " ?id
#FIXME: debug activity type
st:nl() st:call-template(mt:debug, ?subj)
format {
"""
+++
......
......@@ -2,29 +2,34 @@ PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/>
PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
PREFIX st: <http://ns.inria.fr/sparql-template/>
# Template for the JSON definition of QCU activities
template mt:qcu(?qcu) {
'"name": "' ?id '"' mt:sep()
'"type": "radiogroup"' mt:sep()
'"choices": ['
# box { st:call-template(mt:qcu_choices, ?qcu) }
box {
# The body of the group block is instantiated for each match of
# its variables (here, one match for each choice of the QCU),
# while the rest of the template is only instantiated once.
# This is similar to a SQL 'GROUP BY every variable except these'
group {
'"' ?html '"'
'"' ?choice_html '"'
; separator=mt:sep()
}
}
']' mt:sep()
'"correctAnswer": "' ?correct_choice '"'
'"correctAnswer": "' ?correct_choice_html '"'
}
where {
# ?qcu a :ExerciceQC_QCU
?qcu a :ExerciceQC_QCU
?qcu :id ?id .
optional {
?qcu :aReponse ?cchoice .
?cchoice :correct true
?cchoice :text ?correct_choice .
?qcu :aReponse ?choice .
?choice :text ?html
?choice :html ?choice_html
}
optional {
?qcu :aReponse ?correct_choice .
?correct_choice :correct true .
?correct_choice :html ?correct_choice_html .
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment