Ejemplo n.º 1
0
def create_discussion():
    """
    Test data for discussion
    """
    from discuss.models import DiscussionTopic, DiscussionMessage
    offering = CourseOffering.objects.get(slug=TEST_COURSE_SLUG)
    members = list(Member.objects.filter(offering=offering, role='STUD'))
    random.shuffle(members)

    m = members.pop()
    t1 = DiscussionTopic(offering=offering, title='Discussion One', author=m,
                         content='//Hello classmates//.\n\nWe have **many** things to discuss.')
    t1.set_markup('creole')
    t1.save()

    m = members.pop()
    t2 = DiscussionTopic(offering=offering, title='Discussion Two', author=m,
                         content="I *really* can't figure out if \\\\(x+1=y\\\\).")
    t2.set_markup('markdown')
    t2.set_math(True)
    t2.save()

    m = members.pop()
    m1 = DiscussionMessage(topic=t1, content='Hello, friend.', author=m)
    m1.save()

    m = members.pop()
    m2 = DiscussionMessage(topic=t1, author=m, content='''Run this program:\n```python\nfor i in range(2):\n    print(i)\n````''')
    m2.set_markup('markdown')
    m2.save()

    return itertools.chain(
        DiscussionTopic.objects.all(),
        DiscussionMessage.objects.all()
    )
Ejemplo n.º 2
0
    def setUp(self):
        self.offering = CourseOffering.objects.get(slug=TEST_COURSE_SLUG)
        self.offering.set_discussion(True)
        self.offering.save()
        members = Member.objects.filter(offering=self.offering).exclude(
            role='DROP').exclude(person__userid__isnull=True)
        members = list(members)

        # create a bunch of discussion
        for i in range(25):
            t = DiscussionTopic(offering=self.offering,
                                title='Topic ' + str(i),
                                content='Content ' + str(i),
                                author=random.choice(members))
            t.save()
            m = DiscussionMessage(topic=t,
                                  content='**Content** A' + str(i),
                                  author=random.choice(members))
            m.save()
            m = DiscussionMessage(topic=t,
                                  content='//Content// B' + str(i),
                                  author=random.choice(members))
            m.save()

        self.topic = t
        self.message = m
Ejemplo n.º 3
0
 def setUp(self):
     self.offering = CourseOffering.objects.get(slug=TEST_COURSE_SLUG)
     self.offering.set_discussion(True)
     self.offering.save()
     members = Member.objects.filter(offering=self.offering).exclude(role='DROP').exclude(person__userid__isnull=True)
     members = list(members)
     
     # create a bunch of discussion
     for i in range(25):
         t = DiscussionTopic(offering=self.offering, title='Topic '+str(i), content='Content '+str(i),
                             author=random.choice(members))
         t.save()
         m = DiscussionMessage(topic=t, content='**Content** A'+str(i), author=random.choice(members))
         m.save()
         m = DiscussionMessage(topic=t, content='//Content// B'+str(i), author=random.choice(members))
         m.save()
     
     self.topic = t
     self.message = m