Exemple #1
0
    def test_qqtag_backlinks(self):
        q = QqTag('a', [
            QqTag('b', 'hello'),
            QqTag('c', 'world'),
            QqTag('b', 'this'),
            QqTag('--+-', [
                QqTag('b', 'way'),
                "this"
            ])])
        self.assertTrue(q._is_consistent())
        new_tag = QqTag({'qqq' : 'bbb'})
        q.append_child(new_tag)
        self.assertEqual(new_tag.my_index, 4)
        del q[0]
        self.assertEqual(new_tag.my_index, 3)
        self.assertTrue(q._is_consistent())

        other_tag = QqTag({'other': ['some', 'values']})
        q.insert(2, other_tag)
        self.assertEqual(other_tag.my_index, 2)
        self.assertEqual(new_tag.my_index, 4)

        third_tag = QqTag({'this': 'hi'})
        q[3] = third_tag
        self.assertEqual(third_tag.my_index, 3)
        self.assertTrue(q._is_consistent())
Exemple #2
0
    def handle_quiz(self, tag: QqTag):
        """
        Uses tags: choice, correct, comment

        Example:

        \question
        Do you like qqmbr?
        \quiz
            \choice
                No.
                \comment You didn't even try!
            \choice \correct
                Yes, i like it very much!
                \comment And so do I!

        :param tag:
        :return:
        """
        if not tag.exists('md5id'):
            tag.append_child(QqTag('md5id', [self.tag_hash_id(tag)]))
        template = Template(filename="templates/quiz.html")
        return template.render(formatter=self, tag=tag)
Exemple #3
0
    def handle_quiz(self, tag: QqTag):
        """
        Uses tags: choice, correct, comment

        Example:

        \question
        Do you like qqmbr?
        \quiz
            \choice
                No.
                \comment You didn't even try!
            \choice \correct
                Yes, i like it very much!
                \comment And so do I!

        :param tag:
        :return:
        """
        if not tag.exists('md5id'):
            tag.append_child(QqTag('md5id', [self.tag_hash_id(tag)]))
        template = Template(filename="templates/quiz.html")
        return template.render(formatter=self, tag=tag)
Exemple #4
0
    def test_qqtag_backlinks(self):
        q = QqTag('a', [
            QqTag('b', 'hello'),
            QqTag('c', 'world'),
            QqTag('b', 'this'),
            QqTag('--+-', [QqTag('b', 'way'), "this"])
        ])
        self.assertTrue(q._is_consistent())
        new_tag = QqTag({'qqq': 'bbb'})
        q.append_child(new_tag)
        self.assertEqual(new_tag.my_index, 4)
        del q[0]
        self.assertEqual(new_tag.my_index, 3)
        self.assertTrue(q._is_consistent())

        other_tag = QqTag({'other': ['some', 'values']})
        q.insert(2, other_tag)
        self.assertEqual(other_tag.my_index, 2)
        self.assertEqual(new_tag.my_index, 4)

        third_tag = QqTag({'this': 'hi'})
        q[3] = third_tag
        self.assertEqual(third_tag.my_index, 3)
        self.assertTrue(q._is_consistent())