Skip to content
Snippets Groups Projects
Commit 54eef09c authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

better id

parent beac46bf
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ class Question:
self.folder = f
self.q = strip_tags(mlang_2_multiling(xmlQ.find("questiontext/text").text), self.folder)
self.category = c
self.id = f"{c[c.rfind(':')+1:]}_{n}"
self.id = mlang_2_multiling(xmlQ.find("name/text").text,"en")+f":{n}"
self.env = "todo:"+xmlQ.attrib["type"]
self.max = float(xmlQ.find("defaultgrade").text)
self.parseImages(xmlQ.findall(".//file"))
......@@ -178,7 +178,7 @@ class ShortAnswer(TF):
return res
if __name__ == "__main__":
quizz = Quizz("data/quiz-GI-4-SID-S1-top-20201204-1620.xml", "data")
quizz = Quizz("data/quiz-GI-4-SID-S1-top-20201204-1620_corrigé.xml", "data")
#quizz = Quizz("data/quiz-GI-4.xml" , "data")
#print(quizz)
quizz.save()
......@@ -34,8 +34,14 @@ def remove_moodle_cdata(txt, folder):
def strip_tags(txt, folder):
return html_2_tex(sub(compile('<.*?>'), '',remove_moodle_cdata(unquote(txt), folder)))
def mlang_2_multiling(txt):
return sub(r"\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}", r"\\multiling{\6}{\1}",txt)
def mlang_2_multiling(txt, which = "both"):
if which == "fr":
res = sub(r"\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}", r"\6",txt)
elif which == "en":
res = sub(r"\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}",r"\1", txt)
else:
res = sub(r"\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}", r"\\multiling{\6}{\1}",txt)
return res
def score_2_str(v):
if int(v)==float(v):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment