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

Use URIRefs instead of Bnodes for Reponses to have deterministic exports

parent e7af1b77
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -101,11 +101,14 @@ class ExerciceQC(Activity): ...@@ -101,11 +101,14 @@ class ExerciceQC(Activity):
def save(self, graph: Graph): def save(self, graph: Graph):
super().save(graph) super().save(graph)
for choice in self.choices: for choice in self.choices:
choice_node = BNode() choice_node = NS[f"{self.id}q{choice.index}"] # ex: pg157q2
graph.add((choice_node, RDF.type, NS["Reponse"]))
graph.add((choice_node, NS["index"], Literal(choice.index))) graph.add((choice_node, NS["index"], Literal(choice.index)))
graph.add((choice_node, NS["correct"], Literal(choice.is_correct))) graph.add((choice_node, NS["correct"], Literal(choice.is_correct)))
graph.add((choice_node, NS["html"], Literal(choice.html))) graph.add((choice_node, NS["html"], Literal(choice.html)))
graph.add((NS[self.id], NS["aReponse"], choice_node)) graph.add((NS[self.id], NS["aReponse"], choice_node))
# Our fake "class hierarchy" just for easier visualization
graph.add((choice_node, RDFS.subClassOf, NS[self.id]))
def set_correct(self, choice_index: int, correct: bool): def set_correct(self, choice_index: int, correct: bool):
"""Set the choice at `choice_index` as correct or not, creating it if needed.""" """Set the choice at `choice_index` as correct or not, creating it if needed."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment