コード例 #1
0
ファイル: tests.py プロジェクト: saadmahboob/coursys
    def test_jsonfield(self):
        from grades.models import CalNumericActivity
        s, c = create_offering()
        a = CalNumericActivity(offering=c, name="Test", short_name="Test", max_grade=10, position=1)
        a.config = {'showstats': True}
        a.save()

        # https://github.com/bradjasper/django-jsonfield/issues/106
        a = CalNumericActivity.objects.get(slug='test')
        self.assertIsInstance(a.config, dict)
コード例 #2
0
ファイル: tests.py プロジェクト: sfu-fas/coursys
    def test_jsonfield(self):
        from grades.models import CalNumericActivity
        s, c = create_offering()
        a = CalNumericActivity(offering=c, name="Test", short_name="Test", max_grade=10, position=1)
        a.config = {'showstats': True}
        a.save()

        # https://github.com/bradjasper/django-jsonfield/issues/106
        a = CalNumericActivity.objects.get(slug='test')
        self.assertIsInstance(a.config, dict)
コード例 #3
0
ファイル: tests.py プロジェクト: tedkirkpatrick/coursys
    def test_formulas(self):
        """
        Test the formula parsing & evaluation.
        """
        # set up course and related data
        s, c = create_offering()
        p = Person.objects.get(userid="0aaa0")
        m = Member(person=p, offering=c, role="STUD", credits=3, added_reason="UNK")
        m.save()
       
        a = NumericActivity(name="Paragraph", short_name=u"\u00b6", status="RLS", offering=c, position=3, max_grade=40, percent=5)
        a.save()
        g = NumericGrade(activity=a, member=m, value="4.5", flag="CALC")
        g.save(entered_by='ggbaker')
        a1 = NumericActivity(name="Assignment #1", short_name="A1", status="RLS", offering=c, position=1, max_grade=15, percent=10)
        a1.save()
        g = NumericGrade(activity=a1, member=m, value=10, flag="GRAD")
        g.save(entered_by='ggbaker')
        a2 = NumericActivity(name="Assignment #2", short_name="A2", status="URLS", offering=c, position=2, max_grade=40, percent=20)
        a2.save(entered_by='ggbaker')
        g = NumericGrade(activity=a2, member=m, value=30, flag="GRAD")
        g.save(entered_by='ggbaker')
        
        ca = CalNumericActivity(name="Final Grade", short_name=u"FG", status="RLS", offering=c, position=4, max_grade=1)
        ca.save()
        
        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)
        
        # make sure a formula can be pickled and unpickled safely (i.e. can be cached)
        tree = parse("sum([Assignment #1], [A1], [A2])/20*-3", c, ca)
        p = pickle.dumps(tree)
        tree2 = pickle.loads(p)
        self.assertEqual(tree, tree2)
        # check that it found the right list of columns used
        self.assertEqual(cols_used(tree), set(['A1', 'A2', 'Assignment #1']))
        
        # test parsing and evaluation to make sure we get the right values out
        for expr, correct in test_formulas:
            tree = parse(expr, c, ca)
            res = eval_parse(tree, ca, act_dict, m, False)
            self.assertAlmostEqual(correct, res, msg=u"Incorrect result for %s"%(expr,))

        # test some badly-formed stuff for appropriate exceptions
        tree = parse("1 + BEST(3, [A1], [A2])", c, ca)
        self.assertRaises(EvalException, eval_parse, tree, ca, act_dict, m, True)
        tree = parse("1 + BEST(0, [A1], [A2])", c, ca)
        self.assertRaises(EvalException, eval_parse, tree, ca, act_dict, m, True)
        tree = parse("[Foo] /2", c, ca)
        self.assertRaises(KeyError, eval_parse, tree, ca, act_dict, m, True)
        tree = parse("[a1] /2", c, ca)
        self.assertRaises(KeyError, eval_parse, tree, ca, act_dict, m, True)
        
        self.assertRaises(ParseException, parse, "AVG()", c, ca)
        self.assertRaises(ParseException, parse, "(2+3*84", c, ca)
        self.assertRaises(ParseException, parse, "2+3**84", c, ca)
        self.assertRaises(ParseException, parse, "AVG(2,3,4", c, ca)
        self.assertRaises(ParseException, parse, "{something}", c, ca)
        
        # test visible/invisible switching
        tree = parse("[Assignment #2]", c, ca)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)
        res = eval_parse(tree, ca, act_dict, m, False)
        self.assertAlmostEqual(res, 30.0)

        # test unreleased/missing grade conditions
        expr = "[Assignment #2]"
        tree = parse(expr, c, ca)
        
        # unreleased assignment (with grade)
        a2.status='URLS'
        a2.save()
        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)
        
        # explicit no grade (released assignment)
        g.flag="NOGR"
        g.save(entered_by='ggbaker')
        a2.status='RLS'
        a2.save(entered_by='ggbaker')
        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)

        # no grade in database (released assignment)
        g.delete()
        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)
        
        # test [[activitytotal]]
        expr = "[[activitytotal]]"
        tree = parse(expr, c, ca)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 7.229166666)
コード例 #4
0
def create_test_offering():
    """
    main test course: interesting data for grades, marking, submission, groups
    """
    from grades.models import Activity, LetterActivity, CalNumericActivity, CalLetterActivity
    from submission.models import SubmissionComponent
    from submission.models.code import CodeComponent
    from submission.models.pdf import PDFComponent
    from groups.models import Group, GroupMember
    from marking.models import ActivityComponent

    crs = CourseOffering.objects.get(slug=TEST_COURSE_SLUG)

    crs.set_labtut(True)
    crs.set_url("http://www.cs.sfu.ca/CC/165/common/")
    crs.set_taemail("*****@*****.**")
    crs.save()

    # create example activities
    a1 = NumericActivity.objects.get(offering=crs, slug='a1')
    a2 = NumericActivity(offering=crs,
                         name="Assignment 2",
                         short_name="A2",
                         status="URLS",
                         due_date=crs.semester.start +
                         datetime.timedelta(days=70),
                         percent=10,
                         group=True,
                         max_grade=20,
                         position=2)
    a2.set_url("http://www.cs.sfu.ca/CC/165/common/a2")
    a2.save()
    pr = LetterActivity(offering=crs,
                        name="Project",
                        short_name="Proj",
                        status="URLS",
                        due_date=crs.semester.start +
                        datetime.timedelta(days=80),
                        percent=40,
                        group=True,
                        position=3)
    pr.save()
    re = LetterActivity(offering=crs,
                        name="Report",
                        short_name="Rep",
                        status="URLS",
                        due_date=crs.semester.start +
                        datetime.timedelta(days=81),
                        percent=10,
                        group=False,
                        position=4)
    re.save()
    ex = NumericActivity(offering=crs,
                         name="Final Exam",
                         short_name="Exam",
                         status="URLS",
                         due_date=None,
                         percent=30,
                         group=False,
                         max_grade=90,
                         position=5)
    ex.save()
    to = CalNumericActivity(offering=crs,
                            name="Final Percent",
                            short_name="Perc",
                            status="INVI",
                            due_date=None,
                            percent=0,
                            group=False,
                            max_grade=100,
                            formula="[[activitytotal]]",
                            position=6)
    to.save()
    to = CalLetterActivity(offering=crs,
                           name="Letter Grade",
                           short_name="Letter",
                           status="INVI",
                           due_date=None,
                           percent=0,
                           group=False,
                           numeric_activity=to,
                           position=6)
    to.save()

    # make A1 submittable and markable
    s = CodeComponent(activity=a1,
                      title=u"Cöde File",
                      description="The code you're submitting.",
                      allowed=".py,.java")
    s.save()
    s = PDFComponent(activity=a1,
                     title="Report",
                     description="Report on what you did.",
                     specified_filename="report.pdf")
    s.save()

    m = ActivityComponent(
        numeric_activity=a1,
        max_mark=5,
        title=u"Part ➀",
        description="Part ➀ was done well and seems to work.",
        position=1,
        slug='part-1')
    m.save()
    m = ActivityComponent(
        numeric_activity=a1,
        max_mark=5,
        title="Part 2",
        description="Part 2 was done well and seems to work.",
        position=2)
    m.save()

    # create some groups
    members = list(Member.objects.filter(offering=crs, role='STUD'))
    random.shuffle(members)
    m = members.pop()
    g = Group(name="SomeGroup", courseoffering=crs, manager=m)
    g.save()
    for m in [m, members.pop()]:
        gm = GroupMember(group=g, student=m, confirmed=True, activity=a2)
        gm.save()

    m = members.pop()
    g = Group(name="AnotherGroup", courseoffering=crs, manager=m)
    g.save()
    for m in [m, members.pop(), members.pop()]:
        gm = GroupMember(group=g, student=m, confirmed=True, activity=a2)
        gm.save()
        gm = GroupMember(group=g, student=m, confirmed=True, activity=pr)
        gm.save()

    return itertools.chain(
        Activity.objects.all(),
        NumericActivity.objects.all(),
        LetterActivity.objects.all(),
        CalNumericActivity.objects.all(),
        CalLetterActivity.objects.all(),
        SubmissionComponent.objects.all(),
        CodeComponent.objects.all(),
        PDFComponent.objects.all(),
        Group.objects.all(),
        GroupMember.objects.all(),
        ActivityComponent.objects.all(),
    )
コード例 #5
0
def create_test_offering():
    """
    main test course: interesting data for grades, marking, submission, groups
    """
    from grades.models import Activity, LetterActivity, CalNumericActivity, CalLetterActivity
    from submission.models import SubmissionComponent
    from submission.models.code import CodeComponent
    from submission.models.pdf import PDFComponent
    from groups.models import Group, GroupMember
    from marking.models import ActivityComponent

    crs = CourseOffering.objects.get(slug=TEST_COURSE_SLUG)

    crs.set_labtut(True)
    crs.set_url("http://www.cs.sfu.ca/CC/165/common/")
    crs.set_taemail("*****@*****.**")
    crs.save()

    # create example activities
    a1 = NumericActivity.objects.get(offering=crs, slug='a1')
    a2 = NumericActivity(offering=crs, name="Assignment 2", short_name="A2", status="URLS",
        due_date=crs.semester.start + datetime.timedelta(days=70), percent=10, group=True,
        max_grade=20, position=2)
    a2.set_url("http://www.cs.sfu.ca/CC/165/common/a2")
    a2.save()
    pr = LetterActivity(offering=crs, name="Project", short_name="Proj", status="URLS",
        due_date=crs.semester.start + datetime.timedelta(days=80), percent=40, group=True, position=3)
    pr.save()
    re = LetterActivity(offering=crs, name="Report", short_name="Rep", status="URLS",
        due_date=crs.semester.start + datetime.timedelta(days=81), percent=10, group=False, position=4)
    re.save()
    ex = NumericActivity(offering=crs, name="Final Exam", short_name="Exam", status="URLS",
        due_date=None, percent=30, group=False, max_grade=90, position=5)
    ex.save()
    to = CalNumericActivity(offering=crs, name="Final Percent", short_name="Perc", status="INVI",
        due_date=None, percent=0, group=False, max_grade=100, formula="[[activitytotal]]", position=6)
    to.save()
    to = CalLetterActivity(offering=crs, name="Letter Grade", short_name="Letter", status="INVI",
        due_date=None, percent=0, group=False, numeric_activity=to, position=6)
    to.save()

    # make A1 submittable and markable
    s = CodeComponent(activity=a1, title="Code File", description="The code you're submitting.",
        allowed=".py,.java")
    s.save()
    s = PDFComponent(activity=a1, title="Report", description="Report on what you did.",
        specified_filename="report.pdf")
    s.save()

    m = ActivityComponent(numeric_activity=a1, max_mark=5, title="Part 1", description="Part 1 was done well and seems to work.", position=1)
    m.save()
    m = ActivityComponent(numeric_activity=a1, max_mark=5, title="Part 2", description="Part 2 was done well and seems to work.", position=2)
    m.save()

    # create some groups
    members = list(Member.objects.filter(offering=crs, role='STUD'))
    random.shuffle(members)
    m = members.pop()
    g = Group(name="SomeGroup", courseoffering=crs, manager=m)
    g.save()
    for m in [m, members.pop()]:
        gm = GroupMember(group=g, student=m, confirmed=True, activity=a2)
        gm.save()

    m = members.pop()
    g = Group(name="AnotherGroup", courseoffering=crs, manager=m)
    g.save()
    for m in [m, members.pop(), members.pop()]:
        gm = GroupMember(group=g, student=m, confirmed=True, activity=a2)
        gm.save()
        gm = GroupMember(group=g, student=m, confirmed=True, activity=pr)
        gm.save()

    return itertools.chain(
        Activity.objects.all(),
        NumericActivity.objects.all(),
        LetterActivity.objects.all(),
        CalNumericActivity.objects.all(),
        CalLetterActivity.objects.all(),
        SubmissionComponent.objects.all(),
        CodeComponent.objects.all(),
        PDFComponent.objects.all(),
        Group.objects.all(),
        GroupMember.objects.all(),
        ActivityComponent.objects.all(),
    )
コード例 #6
0
ファイル: devdata_importer.py プロジェクト: avacariu/coursys
def test_class_1(slug):
    """
    main test course: 20 students, TA, some assignments
    """
    crs = CourseOffering.objects.get(slug=slug)
    
    crs.set_labtut(True)
    crs.set_url("http://www.cs.sfu.ca/CC/165/common/")
    crs.set_taemail("*****@*****.**")
    crs.save()
    for i in range(10):
        lab = "D1%02i" % (random.randint(1,4))
        p = Person.objects.get(userid="0aaa%i"%(i))
        if Member.objects.filter(person=p, offering=crs, role="STUD"):
            # randomly added by other student-adder: skip
            continue

        m = Member(person=p, offering=crs, role="STUD", credits=3, career="UGRD", added_reason="AUTO",
                labtut_section=lab)
        m.save()
    
    if not Member.objects.filter(person__userid='ggbaker', offering=crs, role='INST'):
        Member(person=Person.objects.get(userid='ggbaker'), offering=crs, role='INST').save()
    
    # create a TA
    p = Person(emplid=fake_emplid(), userid="0grad1", last_name="Gradstudent", first_name="Douglas", middle_name="", pref_first_name="Doug")
    p.save()
    m = Member(person=p, offering=crs, role="TA", credits=0, career="NONS", added_reason="AUTO",
            labtut_section=None)
    m.save()
    
    
    # create example activities
    crs.activity_set.all().update(deleted=True)
    a1 = NumericActivity(offering=crs, name="Assignment 1", short_name="A1", status="RLS",
        due_date=crs.semester.start + datetime.timedelta(days=60), percent=10, group=False,
        max_grade=10, position=1)
    a1.set_url("http://www.cs.sfu.ca/CC/165/common/a1")
    a1.save()
    a2 = NumericActivity(offering=crs, name="Assignment 2", short_name="A2", status="URLS",
        due_date=crs.semester.start + datetime.timedelta(days=70), percent=10, group=True,
        max_grade=20, position=2)
    a2.save()
    pr = LetterActivity(offering=crs, name="Project", short_name="Proj", status="URLS",
        due_date=crs.semester.start + datetime.timedelta(days=80), percent=40, group=True, position=3)
    pr.save()
    re = LetterActivity(offering=crs, name="Report", short_name="Rep", status="URLS",
        due_date=crs.semester.start + datetime.timedelta(days=81), percent=10, group=False, position=4)
    re.save()
    ex = NumericActivity(offering=crs, name="Final Exam", short_name="Exam", status="URLS",
        due_date=None, percent=30, group=False, max_grade=90, position=5)
    ex.save()
    to = CalNumericActivity(offering=crs, name="Final Percent", short_name="Perc", status="INVI",
        due_date=None, percent=0, group=False, max_grade=100, formula="[[activitytotal]]", position=6)
    to.save()
    to = CalLetterActivity(offering=crs, name="Letter Grade", short_name="Letter", status="INVI",
        due_date=None, percent=0, group=False, numeric_activity=to, position=6)
    to.save()
    
    # make A1 submittable and markable
    s = CodeComponent(activity=a1, title="Code File", description="The code you're submitting.",
        allowed=".py,.java")
    s.save()
    s = PDFComponent(activity=a1, title="Report", description="Report on what you did.",
        specified_filename="report.pdf")
    s.save()
    
    m = ActivityComponent(numeric_activity=a1, max_mark=5, title="Part 1", description="Part 1 was done well and seems to work.", position=1)
    m.save()
    m = ActivityComponent(numeric_activity=a1, max_mark=5, title="Part 2", description="Part 2 was done well and seems to work.", position=2)
    m.save()
    
    # create some groups
    g = Group(name="SomeGroup", courseoffering=crs, manager=Member.objects.get(offering=crs, person__userid="0aaa0", role='STUD'))
    g.save()
    for userid in ['0aaa0', '0aaa1', '0aaa5', '0aaa8']:
        gm = GroupMember(group=g, student=Member.objects.get(offering=crs, person__userid=userid), confirmed=True, activity=a2)
        gm.save()
    
    g = Group(name="AnotherGroup", courseoffering=crs, manager=Member.objects.get(offering=crs, person__userid="0aaa4"))
    g.save()
    for userid in ['0aaa4', '0aaa6', '0aaa7', '0aaa2']:
        gm = GroupMember(group=g, student=Member.objects.get(offering=crs, person__userid=userid), confirmed=True, activity=a2)
        gm.save()
        gm = GroupMember(group=g, student=Member.objects.get(offering=crs, person__userid=userid), confirmed=True, activity=pr)
        gm.save()
コード例 #7
0
    def test_formulas(self):
        """
        Test the formula parsing & evaluation.
        """
        # set up course and related data
        s, c = create_offering()
        p = Person.objects.get(userid="0aaa0")
        m = Member(person=p,
                   offering=c,
                   role="STUD",
                   credits=3,
                   added_reason="UNK")
        m.save()

        a = NumericActivity(name="Paragraph",
                            short_name="\u00b6",
                            status="RLS",
                            offering=c,
                            position=3,
                            max_grade=40,
                            percent=5)
        a.save()
        g = NumericGrade(activity=a, member=m, value="4.5", flag="CALC")
        g.save(entered_by='ggbaker')
        a1 = NumericActivity(name="Assignment #1",
                             short_name="A1",
                             status="RLS",
                             offering=c,
                             position=1,
                             max_grade=15,
                             percent=10)
        a1.save()
        g = NumericGrade(activity=a1, member=m, value=10, flag="GRAD")
        g.save(entered_by='ggbaker')
        a2 = NumericActivity(name="Assignment #2",
                             short_name="A2",
                             status="URLS",
                             offering=c,
                             position=2,
                             max_grade=40,
                             percent=20)
        a2.save(entered_by='ggbaker')
        g = NumericGrade(activity=a2, member=m, value=30, flag="GRAD")
        g.save(entered_by='ggbaker')

        ca = CalNumericActivity(name="Final Grade",
                                short_name="FG",
                                status="RLS",
                                offering=c,
                                position=4,
                                max_grade=1)
        ca.save()

        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)

        # make sure a formula can be pickled and unpickled safely (i.e. can be cached)
        tree = parse("sum([Assignment #1], [A1], [A2])/20*-3", c, ca)
        p = pickle.dumps(tree)
        tree2 = pickle.loads(p)
        self.assertEqual(tree, tree2)
        # check that it found the right list of columns used
        self.assertEqual(cols_used(tree), set(['A1', 'A2', 'Assignment #1']))

        # test parsing and evaluation to make sure we get the right values out
        for expr, correct in test_formulas:
            tree = parse(expr, c, ca)
            res = eval_parse(tree, ca, act_dict, m, False)
            self.assertAlmostEqual(correct,
                                   res,
                                   msg="Incorrect result for %s" % (expr, ))

        # test some badly-formed stuff for appropriate exceptions
        tree = parse("1 + BEST(3, [A1], [A2])", c, ca)
        self.assertRaises(EvalException, eval_parse, tree, ca, act_dict, m,
                          True)
        tree = parse("1 + BEST(0, [A1], [A2])", c, ca)
        self.assertRaises(EvalException, eval_parse, tree, ca, act_dict, m,
                          True)
        tree = parse("[Foo] /2", c, ca)
        self.assertRaises(KeyError, eval_parse, tree, ca, act_dict, m, True)
        tree = parse("[a1] /2", c, ca)
        self.assertRaises(KeyError, eval_parse, tree, ca, act_dict, m, True)

        self.assertRaises(ParseException, parse, "AVG()", c, ca)
        self.assertRaises(ParseException, parse, "(2+3*84", c, ca)
        self.assertRaises(ParseException, parse, "2+3**84", c, ca)
        self.assertRaises(ParseException, parse, "AVG(2,3,4", c, ca)
        self.assertRaises(ParseException, parse, "{something}", c, ca)

        # test visible/invisible switching
        tree = parse("[Assignment #2]", c, ca)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)
        res = eval_parse(tree, ca, act_dict, m, False)
        self.assertAlmostEqual(res, 30.0)

        # test unreleased/missing grade conditions
        expr = "[Assignment #2]"
        tree = parse(expr, c, ca)

        # unreleased assignment (with grade) should not be included in the calculation
        a2.status = 'URLS'
        a2.save()
        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)
        # ... unless the instructor said to do so.
        ca.set_calculation_leak(True)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 30.0)

        # explicit no grade (released assignment)
        g.flag = "NOGR"
        g.save(entered_by='ggbaker')
        a2.status = 'RLS'
        a2.save(entered_by='ggbaker')
        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)

        # no grade in database (released assignment)
        g.delete()
        activities = NumericActivity.objects.filter(offering=c)
        act_dict = activities_dictionary(activities)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 0.0)

        # test [[activitytotal]]
        expr = "[[activitytotal]]"
        tree = parse(expr, c, ca)
        res = eval_parse(tree, ca, act_dict, m, True)
        self.assertAlmostEqual(res, 7.229166666)
コード例 #8
0
ファイル: devdata_importer.py プロジェクト: csvenja/coursys
def test_class_1(slug):
    """
    main test course: 20 students, TA, some assignments
    """
    crs = CourseOffering.objects.get(slug=slug)

    crs.set_labtut(True)
    crs.set_url("http://www.cs.sfu.ca/CC/165/common/")
    crs.set_taemail("*****@*****.**")
    crs.save()
    for i in range(10):
        lab = "D1%02i" % (random.randint(1, 4))
        p = Person.objects.get(userid="0aaa%i" % (i))
        if Member.objects.filter(person=p, offering=crs, role="STUD"):
            # randomly added by other student-adder: skip
            continue

        m = Member(person=p,
                   offering=crs,
                   role="STUD",
                   credits=3,
                   career="UGRD",
                   added_reason="AUTO",
                   labtut_section=lab)
        m.save()

    if not Member.objects.filter(
            person__userid='ggbaker', offering=crs, role='INST'):
        Member(person=Person.objects.get(userid='ggbaker'),
               offering=crs,
               role='INST').save()

    # create a TA
    p = Person(emplid=fake_emplid(),
               userid="0grad1",
               last_name="Gradstudent",
               first_name="Douglas",
               middle_name="",
               pref_first_name="Doug")
    p.save()
    m = Member(person=p,
               offering=crs,
               role="TA",
               credits=0,
               career="NONS",
               added_reason="AUTO",
               labtut_section=None)
    m.save()

    # create example activities
    crs.activity_set.all().update(deleted=True)
    a1 = NumericActivity(offering=crs,
                         name="Assignment 1",
                         short_name="A1",
                         status="RLS",
                         due_date=crs.semester.start +
                         datetime.timedelta(days=60),
                         percent=10,
                         group=False,
                         max_grade=10,
                         position=1)
    a1.set_url("http://www.cs.sfu.ca/CC/165/common/a1")
    a1.save()
    a2 = NumericActivity(offering=crs,
                         name="Assignment 2",
                         short_name="A2",
                         status="URLS",
                         due_date=crs.semester.start +
                         datetime.timedelta(days=70),
                         percent=10,
                         group=True,
                         max_grade=20,
                         position=2)
    a2.save()
    pr = LetterActivity(offering=crs,
                        name="Project",
                        short_name="Proj",
                        status="URLS",
                        due_date=crs.semester.start +
                        datetime.timedelta(days=80),
                        percent=40,
                        group=True,
                        position=3)
    pr.save()
    re = LetterActivity(offering=crs,
                        name="Report",
                        short_name="Rep",
                        status="URLS",
                        due_date=crs.semester.start +
                        datetime.timedelta(days=81),
                        percent=10,
                        group=False,
                        position=4)
    re.save()
    ex = NumericActivity(offering=crs,
                         name="Final Exam",
                         short_name="Exam",
                         status="URLS",
                         due_date=None,
                         percent=30,
                         group=False,
                         max_grade=90,
                         position=5)
    ex.save()
    to = CalNumericActivity(offering=crs,
                            name="Final Percent",
                            short_name="Perc",
                            status="INVI",
                            due_date=None,
                            percent=0,
                            group=False,
                            max_grade=100,
                            formula="[[activitytotal]]",
                            position=6)
    to.save()
    to = CalLetterActivity(offering=crs,
                           name="Letter Grade",
                           short_name="Letter",
                           status="INVI",
                           due_date=None,
                           percent=0,
                           group=False,
                           numeric_activity=to,
                           position=6)
    to.save()

    # make A1 submittable and markable
    s = CodeComponent(activity=a1,
                      title="Code File",
                      description="The code you're submitting.",
                      allowed=".py,.java")
    s.save()
    s = PDFComponent(activity=a1,
                     title="Report",
                     description="Report on what you did.",
                     specified_filename="report.pdf")
    s.save()

    m = ActivityComponent(
        numeric_activity=a1,
        max_mark=5,
        title="Part 1",
        description="Part 1 was done well and seems to work.",
        position=1)
    m.save()
    m = ActivityComponent(
        numeric_activity=a1,
        max_mark=5,
        title="Part 2",
        description="Part 2 was done well and seems to work.",
        position=2)
    m.save()

    # create some groups
    g = Group(name="SomeGroup",
              courseoffering=crs,
              manager=Member.objects.get(offering=crs,
                                         person__userid="0aaa0",
                                         role='STUD'))
    g.save()
    for userid in ['0aaa0', '0aaa1', '0aaa5', '0aaa8']:
        gm = GroupMember(group=g,
                         student=Member.objects.get(offering=crs,
                                                    person__userid=userid),
                         confirmed=True,
                         activity=a2)
        gm.save()

    g = Group(name="AnotherGroup",
              courseoffering=crs,
              manager=Member.objects.get(offering=crs, person__userid="0aaa4"))
    g.save()
    for userid in ['0aaa4', '0aaa6', '0aaa7', '0aaa2']:
        gm = GroupMember(group=g,
                         student=Member.objects.get(offering=crs,
                                                    person__userid=userid),
                         confirmed=True,
                         activity=a2)
        gm.save()
        gm = GroupMember(group=g,
                         student=Member.objects.get(offering=crs,
                                                    person__userid=userid),
                         confirmed=True,
                         activity=pr)
        gm.save()