Skip to content
Snippets Groups Projects
Select Git revision
  • 489175eda5c1470530b0419a791053799f3bd2b1
  • main default protected
  • export
  • 28-conversion-tests
  • extraction
  • exploration
  • exploration-old
  • 2-encoding-fix
  • main-old
9 results

quiz.rq

Blame
  • quiz.rq 1.56 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 .
        }
    }
    # 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