Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ans = {
- 'Q01': 'C',
- 'Q02': 'B',
- 'Q03': 'A',
- 'Q04': 'A',
- 'Q05': 'B',
- 'Q06': 'A',
- 'Q07': 'A',
- 'Q08': 'A',
- 'Q09': 'C',
- 'Q10': 'A',
- 'Q11': 'B',
- 'Q12': 'A',
- 'Q13': 'A',
- 'Q14': 'D',
- 'Q15': 'A',
- 'Q16': 'B',
- 'Q17': 'C',
- 'Q18': 'A',
- 'Q19': 'C',
- 'Q20': 'A',
- 'Q21': 'B',
- 'Q22': 'B',
- 'Q23': 'A',
- 'Q24': 'B',
- 'Q25': 'C'
- }
- start = 53279
- options = ['A', 'B', 'C', 'D']
- with open("questions_ENDSEM_JAN_APR25.xml", "w", encoding="utf-8") as f:
- for i in range(1, 26):
- qid = f"Q{i:02}"
- correct = ans.get(qid, None) # None if not specified
- question_block = f"""<!-- question: {start} -->
- <question type="multichoice">
- <name>
- <text>{qid}</text>
- </name>
- <questiontext format="html">
- <text><![CDATA[<p> </p>]]></text>
- </questiontext>
- <generalfeedback format="html">
- <text></text>
- </generalfeedback>
- <defaultgrade>1.0000000</defaultgrade>
- <penalty>0</penalty>
- <hidden>0</hidden>
- <idnumber></idnumber>
- <single>true</single>
- <shuffleanswers>false</shuffleanswers>
- <answernumbering>abc</answernumbering>
- <showstandardinstruction>0</showstandardinstruction>
- <correctfeedback format="html">
- <text></text>
- </correctfeedback>
- <partiallycorrectfeedback format="html">
- <text></text>
- </partiallycorrectfeedback>
- <incorrectfeedback format="html">
- <text></text>
- </incorrectfeedback>"""
- for opt in options:
- fraction = "100" if correct == opt else "0"
- question_block += f"""
- <answer fraction="{fraction}" format="html">
- <text><![CDATA[<p>Option {opt}</p>]]></text>
- <feedback format="html">
- <text></text>
- </feedback>
- </answer>"""
- question_block += """
- </question>\n"""
- f.write(question_block)
- start += 1
- print("XML file 'questions.xml' generated successfully.")
- #preview link is without the option marked.
- #Mcq testing
- #start=53304
- #for i in range(25):
- # print(f"""https://cetpgex.iitp.ac.in/moodle/question/bank/previewquestion/preview.php?id={start}&restartversion=0&courseid=314&returnurl=%2Fquestion%2Fedit.php%3Fcourseid%3D314%26cat%3D4836%252C36016%26deleteall%3D1""")
- # start+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement