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

A bit of cleaning on the STTL templates

parent 5d76f51a
Branches
No related tags found
1 merge request!1Main
......@@ -7,18 +7,14 @@ PREFIX owl: <http://www.w3.org/2002/07/owl#>
# and calls other specific templates when necessary
template mt:activite(?act) {
mt:start_marker(?act) "/index.md" st:nl()
format {
"""+++
title = "%s"
weight = %s0
+++
'+++' 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()
?desc st:nl()
%s
"""
?title
?weight
?desc
}
# 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)
......
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
}
......@@ -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
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment