Select Git revision
setupJest.js
quiz.rq 1.61 KiB
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:quiz(?quiz) {
st:nl()
mt:start_marker(?quiz) "/quiz.json" st:nl()
'{'
box {
'"elements": ['
box {
"{"
box {
st:call-template(mt:qcu, ?quiz)
st:call-template(mt:qcm, ?quiz)
#st:call-template(mt:json_in_ttl, ?quiz)
}
"}"
}
']'
}
# Optional correct/incorrect comments for the 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
coalesce(st:format(
'%s"correctComment": "%s"',
mt:sep(),
mt:json_escape(?correct_comment)
), "")
coalesce(st:format(
'%s"incorrectComment": "%s"',
mt:sep(),
mt:json_escape(?incorrect_comment)
), "")
'}'
st:nl()
}
where {
?quiz a :Exercice .
?quiz :id ?id .
optional {
?quiz :commentaireSucces_md ?correct_comment .
}
optional {
?quiz :commentaireSugg_md ?incorrect_comment .
}
FILTER(NOT EXISTS{?quiz :surveyjs_json ?json})
}
# FIXME: some exercises have multiple incorrect comments, almost identical,
# which creates multiple matches for the WHERE clause and thus duplicate files.
# We'll have to deal with them at some point, but for now just filter the first
# one arbitrarily to avoid messing with the output.
LIMIT 1