64 lines
1.5 KiB
Python
64 lines
1.5 KiB
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
questions = open("questions.txt", "r")
|
||
|
lines = questions.readlines()
|
||
|
questions.close()
|
||
|
|
||
|
start = """
|
||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<quiz>
|
||
|
<!-- question: 0 -->
|
||
|
<question type="category">
|
||
|
<category>
|
||
|
<text>$course$/top/Standard für LAPVB</text>
|
||
|
</category>
|
||
|
<info format="moodle_auto_format">
|
||
|
<text>Standardkategorie für Fragen, die im Kontext 'LAPVB' freigegeben sind.</text>
|
||
|
</info>
|
||
|
<idnumber></idnumber>
|
||
|
</question>
|
||
|
"""
|
||
|
|
||
|
question = """
|
||
|
<!-- question: {} -->
|
||
|
<question type="essay">
|
||
|
<name>
|
||
|
<text>{}</text>
|
||
|
</name>
|
||
|
<questiontext format="html">
|
||
|
<text><![CDATA[<p dir="ltr" style="text-align: left;">{}<br></p>]]></text>
|
||
|
</questiontext>
|
||
|
<generalfeedback format="html">
|
||
|
<text></text>
|
||
|
</generalfeedback>
|
||
|
<defaultgrade>1.0000000</defaultgrade>
|
||
|
<penalty>0.0000000</penalty>
|
||
|
<hidden>0</hidden>
|
||
|
<idnumber></idnumber>
|
||
|
<responseformat>plain</responseformat>
|
||
|
<responserequired>1</responserequired>
|
||
|
<responsefieldlines>15</responsefieldlines>
|
||
|
<attachments>0</attachments>
|
||
|
<attachmentsrequired>0</attachmentsrequired>
|
||
|
<graderinfo format="html">
|
||
|
<text></text>
|
||
|
</graderinfo>
|
||
|
<responsetemplate format="html">
|
||
|
<text></text>
|
||
|
</responsetemplate>
|
||
|
</question>
|
||
|
"""
|
||
|
|
||
|
end = "</quiz>"
|
||
|
|
||
|
output = ""
|
||
|
output += start
|
||
|
qid = 0
|
||
|
for line in lines:
|
||
|
output += question.format(qid, line, line)
|
||
|
qid += 1
|
||
|
output += end
|
||
|
outputfile = open("questions.xml", "w")
|
||
|
outputfile.write(output)
|
||
|
outputfile.close()
|