<commit_before>import os

generated_quiz_path = os.getcwd() + "/generated_quizzes/"


# TODO: Evaluate generation of an xml title
class QuizBuilder(object):
    def __init__(self, xml_title):
        self.xml_title = xml_title.lower().replace(" ", "_")

    def setup(self):
        if not os.path.exists(generated_quiz_path):
            os.makedirs(generated_quiz_path)

        result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        result += "<quiz>\n" \
                  "<!-- question: 0  -->\n" \
                  "\t<question type=\"category\">\n" \
                  "\t\t<category>\n" \
                  "\t\t\t<text>Generated by QGen</text>\n" \
                  "\t\t</category>\n" \
                  "\t</question>\n"
        output_file = open(generated_quiz_path + self.xml_title + ".xml", "w")
        output_file.write(result)
        output_file.close()

    def build_question_for_xml(self, title=None, text=None, type=None):
        result = "\n\t<question type=\"" + type + "\">"
        result += "<name>\n" + "\t\t<text>" + title + "</text>\n" + "\t\t</name>"
        result += "<questiontext format=\"html\">\n" + "\t\t<text>" + text + "</text>\n" + "\t\t</questiontext>"
        result += "<generalfeedback format=\"html\">\n" \
                  "\t\t<text></text>\n" \
                  "\t\t</generalfeedback>\n" \
                  "\t\t<defaultgrade>1.0000000</defaultgrade>\n" \
                  "\t\t<penalty>0.1000000</penalty>\n" \
                  "\t\t<hidden>0</hidden>\n" \
                  "\t\t<single>true</single>\n" \
                  "\t\t<shuffleanswers>true</shuffleanswers>\n" \
                  "\t\t<answernumbering>abc</answernumbering>\n" \
                  "\t\t<correctfeedback format=\"html\">\n" \
                  "\t\t\t<text></text>\n" \
                  "\t\t</correctfeedback>\n" \
                  "\t\t<partiallycorrectfeedback format=\"html\">\n" \
                  "\t\t\t<text></text>\n" \
                  "\t\t</partiallycorrectfeedback>\n" \
                  "\t\t<incorrectfeedback format=\"html\">\n" \
                  "\t\t\t<text></text>\n" \
                  "\t\t</incorrectfeedback>\n"
        output_file = open(generated_quiz_path + self.xml_title + ".xml", "a+")
        output_file.write(result)
        output_file.close()

    def build_answer_for_xml(self, text, correct_feedback=None, fractionAmount="100"):
        if correct_feedback is None:
            correct_feedback = ''
        if fractionAmount == '':
            fractionAmount = "100"
        result = "\n\t\t<answer fraction=\"" + fractionAmount + "\" format=\"moodle_auto_format\">\n" + "\t\t\t<text>" + text + \
                 "</text>\n" \
                 "\t\t\t<feedback format=\"html\">\n" \
                 "\t\t\t\t<text>" + correct_feedback + "</text>\n" \
                                                       "\t\t\t</feedback>\n" \
                                                       "\t\t</answer>\n"
        output_file = open(generated_quiz_path + self.xml_title + ".xml", "a+")
        output_file.write(result)
        output_file.close()

    def build_distractor_for_xml(self, text, incorrect_feedback=None, fractionAmount="0"):
        if incorrect_feedback is None:
            incorrect_feedback = ''
            if fractionAmount == '':
                fractionAmount = "0"
        result = "\n\t\t<answer fraction=\"" + fractionAmount + "\" format=\"moodle_auto_format\">\n" + "\t\t\t<text>" + text + \
                 "</text>\n" \
                 "\t\t\t<feedback format=\"html\">\n" \
                 "\t\t\t\t<text>" + incorrect_feedback + "</text>\n" \
                                                         "\t\t\t</feedback>\n" \
                                                         "\t\t</answer>\n"
        output_file = open(generated_quiz_path + self.xml_title + ".xml", "a+")
        output_file.write(result)
        output_file.close()

    def build_question_end_tag(self):
        result = "\t</question>\n\n"
        output_file = open(generated_quiz_path + self.xml_title + ".xml", "a+")
        output_file.write(result)
        output_file.close()

    def build_quiz_end_tag(self):
        result = "</quiz>"
        output_file = open(generated_quiz_path + self.xml_title + ".xml", "a+")
        output_file.write(result)<commit_msg>different moodle xmls being created for each yml question file (merge)<commit_after>import os

generated_quiz_path = os.getcwd() + "/generated_quizzes/"


# TODO: Evaluate generation of an xml title
class QuizBuilder(object):
    def __init__(self, xml_title):
        self.xml_title = xml_title.lower().replace(" ", "_")

    def setup(self):
        if not os.path.exists(generated_quiz_path):
            os.makedirs(generated_quiz_path)

        result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        result += "<quiz>\n" \
                  "<!-- question: 0  -->\n" \
                  "\t<question type=\"category\">\n" \
                  "\t\t<category>\n" \
                  "\t\t\t<text>Generated by QGen</text>\n" \
                  "\t\t</category>\n" \
                  "\t</question>\n"
        with open (generated_quiz_path + self.xml_title + ".xml", "w") as output_file:
            output_file.write(result)
        output_file.close()

    def build_question_for_xml(self, title=None, text=None, type=None):
        result = "\n\t<question type=\"" + type + "\">"
        result += "<name>\n" + "\t\t<text>" + title + "</text>\n" + "\t\t</name>"
        result += "<questiontext format=\"html\">\n" + "\t\t<text>" + text + "</text>\n" + "\t\t</questiontext>"
        result += "<generalfeedback format=\"html\">\n" \
                  "\t\t<text></text>\n" \
                  "\t\t</generalfeedback>\n" \
                  "\t\t<defaultgrade>1.0000000</defaultgrade>\n" \
                  "\t\t<penalty>0.1000000</penalty>\n" \
                  "\t\t<hidden>0</hidden>\n" \
                  "\t\t<single>true</single>\n" \
                  "\t\t<shuffleanswers>true</shuffleanswers>\n" \
                  "\t\t<answernumbering>abc</answernumbering>\n" \
                  "\t\t<correctfeedback format=\"html\">\n" \
                  "\t\t\t<text></text>\n" \
                  "\t\t</correctfeedback>\n" \
                  "\t\t<partiallycorrectfeedback format=\"html\">\n" \
                  "\t\t\t<text></text>\n" \
                  "\t\t</partiallycorrectfeedback>\n" \
                  "\t\t<incorrectfeedback format=\"html\">\n" \
                  "\t\t\t<text></text>\n" \
                  "\t\t</incorrectfeedback>\n"
        with open (generated_quiz_path + self.xml_title + ".xml", "a+") as output_file:
            output_file.write(result)
        output_file.close()

    def build_answer_for_xml(self, text, correct_feedback=None, fractionAmount="100"):
        if correct_feedback is None:
            correct_feedback = ''
        if fractionAmount == '':
            fractionAmount = "100"
        result = "\n\t\t<answer fraction=\"" + fractionAmount + "\" format=\"moodle_auto_format\">\n" + "\t\t\t<text>" + text + \
                 "</text>\n" \
                 "\t\t\t<feedback format=\"html\">\n" \
                 "\t\t\t\t<text>" + correct_feedback + "</text>\n" \
                                                       "\t\t\t</feedback>\n" \
                                                       "\t\t</answer>\n"
        with open(generated_quiz_path + self.xml_title + ".xml", "a+") as output_file:
            output_file.write(result)
        output_file.close()

    def build_distractor_for_xml(self, text, incorrect_feedback=None, fractionAmount="0"):
        if incorrect_feedback is None:
            incorrect_feedback = ''
            if fractionAmount == '':
                fractionAmount = "0"
        result = "\n\t\t<answer fraction=\"" + fractionAmount + "\" format=\"moodle_auto_format\">\n" + "\t\t\t<text>" + text + \
                 "</text>\n" \
                 "\t\t\t<feedback format=\"html\">\n" \
                 "\t\t\t\t<text>" + incorrect_feedback + "</text>\n" \
                                                         "\t\t\t</feedback>\n" \
                                                         "\t\t</answer>\n"
        with open(generated_quiz_path + self.xml_title + ".xml", "a+") as output_file:
            output_file.write(result)
        output_file.close()

    def build_question_end_tag(self):
        result = "\t</question>\n\n"
        with open(generated_quiz_path + self.xml_title + ".xml", "a+") as output_file:
            output_file.write(result)
        output_file.close()

    def build_quiz_end_tag(self):
        result = "</quiz>"
        with open(generated_quiz_path + self.xml_title + ".xml", "a+") as output_file:
            output_file.write(result)
{'fraction_non_alphanumeric': 0.17601263680469367, 'fraction_numerical': 0.0065440595735078416, 'mean_word_length': 1.6062922669803, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 2, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 41}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '959132', 'n_tokens_mistral': 2839, 'n_tokens_neox': 2715, 'n_words': 411}