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(), )
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()