本文整理汇总了Python中grades.models.NumericActivity.save方法的典型用法代码示例。如果您正苦于以下问题:Python NumericActivity.save方法的具体用法?Python NumericActivity.save怎么用?Python NumericActivity.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grades.models.NumericActivity
的用法示例。
在下文中一共展示了NumericActivity.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_select_components
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_select_components(self):
"""
Test submission component classes: subclasses, selection, sorting.
"""
_, course = create_offering()
a1 = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=course, position=2, max_grade=15, due_date="2010-04-01")
a1.save()
a2 = NumericActivity(name="Assignment 2", short_name="A2", status="RLS", offering=course, position=1, max_grade=15, due_date="2010-03-01")
a2.save()
p = Person.objects.get(userid="ggbaker")
member = Member(person=p, offering=course, role="INST", career="NONS", added_reason="UNK")
member.save()
c1 = URL.Component(activity=a1, title="URL Link", position=8)
c1.save()
c2 = Archive.Component(activity=a1, title="Archive File", position=1, max_size=100000)
c2.save()
c3 = Code.Component(activity=a1, title="Code File", position=3, max_size=2000, allowed=".py")
c3.save()
comps = select_all_components(a1)
self.assertEqual(len(comps), 3)
self.assertEqual(comps[0].title, 'Archive File') # make sure position=1 is first
self.assertEqual(str(comps[1].Type), "submission.models.code.Code")
self.assertEqual(str(comps[2].Type), "submission.models.url.URL")
示例2: test_add_activity_components
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_add_activity_components(self):
c = CourseOffering.objects.get(slug = self.c_slug)
#add a numeric activity and its components
a = NumericActivity(offering = c, name = 'test_assignment_1', \
short_name = 'ta1', status = 'RLS', \
due_date = datetime.now(), max_grade = 100, position = 0)
a.save()
co1 = ActivityComponent(numeric_activity = a, title = 'part1', max_mark = 20, position = 1)
co2 = ActivityComponent(numeric_activity = a, title = 'part2', max_mark = 30, position = 2)
co3 = ActivityComponent(numeric_activity = a, title = 'part3', max_mark = 50, position = 3)
co1.save()
co2.save()
co3.save()
self.client.login_user('ggbaker')
response = basic_page_tests(self, self.client, reverse('offering:marking:manage_activity_components', args=(self.c_slug,a.slug)))
forms = response.context['formset'].forms
self.assertEqual(forms[0].instance.title, 'part1')
self.assertEqual(forms[1].instance.title, 'part2')
self.assertEqual(forms[2].instance.title, 'part3')
示例3: test_group_setMark
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_group_setMark(self):
c = CourseOffering.objects.get(slug = self.c_slug)
#add a numeric activity
a = NumericActivity(offering = c, name = 'test_assignment_1', \
short_name = 'ta1', status = 'RLS', \
due_date = datetime.now(), max_grade = 100, position = 0)
a.save()
#take 2 students to make a group
stud1 = Member.objects.get(person = Person.objects.get(userid = '0aaa0'), offering = c)
stud2 = Member.objects.get(person = Person.objects.get(userid = '0aaa1'), offering = c)
group = Group.objects.create(courseoffering = c, name = 'hello', manager = stud1)
member1 = GroupMember.objects.create(group = group, student = stud1, confirmed = True, activity=a)
member2 = GroupMember.objects.create(group = group, student = stud2, confirmed = True, activity=a)
MARK = 30
group_mark = GroupActivityMark(group = group, numeric_activity = a)
group_mark.setMark(MARK, entered_by='ggbaker')
group_mark.save()
num_grades = NumericGrade.objects.filter(activity = a).order_by('member__person__userid')
self.assertEqual(len(num_grades), 2)
self.assertEqual(num_grades[0].member, stud1)
self.assertEqual(num_grades[0].value, MARK)
self.assertEqual(num_grades[0].flag, 'GRAD')
self.assertEqual(num_grades[1].member, stud2)
self.assertEqual(num_grades[1].value, MARK)
self.assertEqual(num_grades[1].flag, 'GRAD')
示例4: test_out_of_zero
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_out_of_zero(self):
"""
Test activities out of zero
"""
c = CourseOffering.objects.get(slug=self.course_slug)
a = NumericActivity(offering=c, name="AZero", short_name="AZ", status="RLS", group=False, deleted=False, max_grade=0, position=1)
a.save()
stud = c.member_set.filter(role="STUD")[0]
# test as instructor
client = Client()
client.login_user("ggbaker")
url = reverse('marking.views.change_grade_status', kwargs={'course_slug': c.slug, 'activity_slug': a.slug, 'userid': stud.person.userid})
response = basic_page_tests(self, client, url)
self.assertContains(response, "out of 0")
response = client.post(url, {'grade-status-value': 3, 'grade-status-flag': 'GRAD', 'grade-status-comment': ''})
self.assertEquals(response.status_code, 302)
g = NumericGrade.objects.get(activity=a, member=stud)
self.assertEquals(g.value, 3)
url = reverse('grades.views.activity_info', kwargs={'course_slug': c.slug, 'activity_slug': a.slug})
response = basic_page_tests(self, client, url)
url = reverse('grades.views.student_info', kwargs={'course_slug': c.slug, 'userid': stud.person.userid})
response = basic_page_tests(self, client, url)
# test as student
client.login_user(stud.person.userid)
url = reverse('grades.views.course_info', kwargs={'course_slug': c.slug})
response = basic_page_tests(self, client, url)
url = reverse('grades.views.activity_info', kwargs={'course_slug': c.slug, 'activity_slug': a.slug})
response = basic_page_tests(self, client, url)
示例5: test_group_submission_view
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_group_submission_view(self):
"""
test if group submission can be viewed by group member and non group member
"""
now = datetime.datetime.now()
_, course = create_offering()
a1 = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=course, position=2, max_grade=15, due_date=now, group=True)
a1.save()
a2 = NumericActivity(name="Assignment 2", short_name="A2", status="RLS", offering=course, position=1, max_grade=15, due_date=now, group=True)
a2.save()
p = Person.objects.get(userid="ggbaker")
member = Member(person=p, offering=course, role="INST", career="NONS", added_reason="UNK")
member.save()
c1 = URL.Component(activity=a1, title="URL Link", position=8)
c1.save()
c2 = Archive.Component(activity=a1, title="Archive File", position=1, max_size=100000)
c2.save()
c3 = Code.Component(activity=a1, title="Code File", position=3, max_size=2000, allowed=".py")
c3.save()
userid1 = "0aaa0"
userid2 = "0aaa1"
userid3 = "0aaa2"
for u in [userid1, userid2,userid3]:
p = Person.objects.get(userid=u)
m = Member(person=p, offering=course, role="STUD", credits=3, career="UGRD", added_reason="UNK")
m.save()
m = Member.objects.get(person__userid=userid1, offering=course)
g = Group(name="Test Group", manager=m, courseoffering=course)
g.save()
gm = GroupMember(group=g, student=m, confirmed=True, activity=a1)
gm.save()
gm = GroupMember(group=g, student=m, confirmed=True, activity=a2)
gm.save()
m = Member.objects.get(person__userid=userid2, offering=course)
gm = GroupMember(group=g, student=m, confirmed=True, activity=a1)
gm.save()
gm = GroupMember(group=g, student=m, confirmed=True, activity=a2)
gm.save()
m = Member.objects.get(person__userid=userid3, offering=course)
gm = GroupMember(group=g, student=m, confirmed=True, activity=a2)
gm.save()
client = Client()
# login as "0aaa0", member of group : test_group for assignment1 and assgnment2
client.login_user("0aaa0")
#submission page for assignment 1
url = reverse('submission.views.show_components', kwargs={'course_slug': course.slug,'activity_slug':a1.slug})
response = basic_page_tests(self, client, url)
self.assertContains(response, "This is a group submission. You will submit on behalf of the group Test Group.")
self.assertContains(response, "You haven't made a submission for this component.")
示例6: test_upload
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_upload(self):
_, course = create_offering()
a1 = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=course, position=2, max_grade=15, due_date=datetime.datetime.now() + datetime.timedelta(hours=1), group=False)
a1.save()
p = Person.objects.get(userid="ggbaker")
member = Member(person=p, offering=course, role="INST", career="NONS", added_reason="UNK")
member.save()
c = Code.Component(activity=a1, title="Code File", position=3, max_size=2000, allowed=".py")
c.save()
userid1 = "0aaa0"
userid2 = "0aaa1"
userid3 = "0aaa2"
for u in [userid1, userid2,userid3]:
p = Person.objects.get(userid=u)
m = Member(person=p, offering=course, role="STUD", credits=3, career="UGRD", added_reason="UNK")
m.save()
# submit as student
client = Client()
client.login_user("0aaa0")
url = reverse('submission.views.show_components', kwargs={'course_slug': course.slug,'activity_slug':a1.slug})
response = basic_page_tests(self, client, url)
# submit a file
tmpf = tempfile.NamedTemporaryFile(suffix=".py", delete=False)
codecontents = 'print "Hello World!"\n'
tmpf.write(codecontents)
tmpf.close()
try:
fh = open(tmpf.name, "r")
data = {"%i-code" % (c.id): fh}
response = client.post(url, data)
self.assertEquals(response.status_code, 302)
finally:
os.unlink(tmpf.name)
# make sure it's there and correct
subs = StudentSubmission.objects.all()
self.assertEquals(len(subs), 1)
sub = subs[0]
self.assertEquals(sub.member.person.userid, '0aaa0')
codes = SubmittedCode.objects.all()
self.assertEquals(len(codes), 1)
code = codes[0]
code.code.open()
self.assertEquals(code.code.read(), codecontents)
示例7: test_add_common_problems
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_add_common_problems(self):
c = CourseOffering.objects.get(slug = self.c_slug)
a = NumericActivity(offering = c, name = 'test_assignment_1', \
short_name = 'ta1', status = 'RLS', \
due_date = datetime.now(), max_grade = 100, position = 1)
a.save()
co1 = ActivityComponent(numeric_activity = a, title = 'part1', max_mark = 50, position = 1)
co2 = ActivityComponent(numeric_activity = a, title = 'part2', max_mark = 50, position = 2)
co1.save()
co2.save()
#add some common problems
cp1 = CommonProblem(activity_component = co1, title = 'cp1', penalty="0")
cp2 = CommonProblem(activity_component = co1, title = 'cp2', penalty="1.12")
cp3 = CommonProblem(activity_component = co2, title = 'cp3', penalty="-2.3")
cp1.save()
cp2.save()
cp3.save()
self.client.login_user('ggbaker')
response = basic_page_tests(self, self.client, reverse('offering:marking:manage_common_problems', args=(self.c_slug,a.slug)))
forms = response.context['formset'].forms
ins0 = forms[0].instance
ins1 = forms[1].instance
ins2 = forms[2].instance
self.assertEqual(ins0.title, 'cp1')
self.assertEqual(ins0.activity_component, co1)
self.assertEqual(ins1.title, 'cp2')
self.assertEqual(ins1.activity_component, co1)
self.assertEqual(ins2.title, 'cp3')
self.assertEqual(ins2.activity_component, co2)
#test the marking page as well
url = reverse('offering:marking:marking_student', args=(self.c_slug, a.slug, '0aaa0'))
response = basic_page_tests(self, self.client, url)
mark_components = response.context['component_data']
com1 = mark_components[0]
com2 = mark_components[1]
self.assertEqual(com1['component'], co1)
self.assertEqual(len(com1['common_problems']), 2)
self.assertEqual(com2['component'], co2)
self.assertEqual(len(com2['common_problems']), 1)
示例8: test_post_activity_components
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_post_activity_components(self):
c = CourseOffering.objects.get(slug = self.c_slug)
#add a numeric activity and its components
a = NumericActivity(offering = c, name = 'test_assignment_1', \
short_name = 'ta1', status = 'RLS', \
due_date = datetime.now(), max_grade = 100, position = 0)
a.save()
self.client.login_user('ggbaker')
url = reverse('offering:marking:manage_activity_components', args=(self.c_slug, a.slug))
# 2 forms for the first 2 components to add
post_data = {'form-0-id' : ['', ''], 'form-1-id' : ['', ''],
'form-0-title': ['part1'], 'form-1-title': ['part2'],
'form-0-max_mark' : ['20'], 'form-1-max_mark': ['20'],
'form-0-description' : ['basic1'], 'form-1-description': ['basic2'],
'form-TOTAL_FORMS' : ['3'], 'form-INITIAL_FORMS':['0']}
response = self.client.post(url, post_data, follow = True)
self.assertEqual(response.status_code, 200)
cps = ActivityComponent.objects.filter(numeric_activity = a, deleted = False)
self.assertEqual(len(cps), 2)
self.assertEqual(cps[0].title, 'part1')
self.assertEqual(cps[1].title, 'part2')
# keep the first 2 components, and add 2 more new components
post_data2 = {'form-2-id' : ['', ''], 'form-3-id' : ['', ''],
'form-2-title': ['part3'], 'form-3-title': ['part4'],
'form-2-max_mark' : ['30'], 'form-3-max_mark': ['30'],
'form-2-description' : ['advanced1'], 'form-3-description': ['advanced2'],
}
post_data.update(post_data2)
post_data['form-0-id'] = [str(cps[0].id), str(cps[0].id)]
post_data['form-1-id'] = [str(cps[1].id), str(cps[1].id)]
post_data['form-INITIAL_FORMS'] = ['2']
post_data['form-TOTAL_FORMS'] = ['5']
response = self.client.post(url, post_data, follow = True)
self.assertEqual(response.status_code, 200)
cps = ActivityComponent.objects.filter(numeric_activity = a, deleted = False)
self.assertEqual(len(cps), 4)
self.assertEqual(cps[2].title, 'part3')
self.assertEqual(cps[3].title, 'part4')
示例9: test_mark_history
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_mark_history(self):
c = CourseOffering.objects.get(slug = self.c_slug)
#add a numeric activity
a = NumericActivity(offering = c, name = 'test_assignment_1', \
short_name = 'ta1', status = 'RLS', \
due_date = datetime.now(), max_grade = 100, position = 0)
a.save()
#take 2 students to make a group
stud1 = Member.objects.get(person = Person.objects.get(userid = '0aaa0'), offering = c)
stud2 = Member.objects.get(person = Person.objects.get(userid = '0aaa1'), offering = c)
group = Group.objects.create(courseoffering = c, name = 'hello', manager = stud1)
member1 = GroupMember.objects.create(group = group, student = stud1, confirmed = True, activity=a)
member2 = GroupMember.objects.create(group = group, student = stud2, confirmed = True, activity=a)
ngrade = NumericGrade(activity = a, member = stud2)
ngrade.save(entered_by='ggbaker')
#assign mark to 0aaa1 individually twice and via the group twice, make some interval between saves
std_mark = StudentActivityMark(numeric_grade = ngrade, created_by = 'ggbaker')
std_mark.setMark(20, entered_by='ggbaker')
std_mark.save()
group_mark = GroupActivityMark(group = group, numeric_activity = a, created_by = 'ggbaker')
group_mark.setMark(30, entered_by='ggbaker')
group_mark.save()
std_mark = StudentActivityMark(numeric_grade = ngrade, created_by = 'ggbaker')
std_mark.setMark(40, entered_by='ggbaker')
std_mark.save()
group_mark = GroupActivityMark(group = group, numeric_activity = a, created_by = 'ggbaker')
group_mark.setMark(50, entered_by='ggbaker')
group_mark.save()
self.client.login_user('ggbaker')
response = self.client.get(reverse('offering:marking:mark_history_student', args=(self.c_slug, a.slug, '0aaa1')))
self.assertEqual(response.status_code, 200)
latest_act_mark = response.context['current_mark']
self.assertEqual(len(response.context['marks_individual']), 2)
self.assertEqual(len(response.context['marks_via_group']), 2)
self.assertEqual(group_mark, latest_act_mark)
示例10: test_calc_letter
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_calc_letter(self):
"""
Test calculated letter functionality
"""
s, c = create_offering()
na = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=c, position=2, max_grade=15, percent=10, group=False)
na.save()
a = CalLetterActivity(offering=c, name="A1 Letter", short_name="A1L", status="RLS", numeric_activity=na, exam_activity=None, position=3)
a.save()
# test cutoff getter/setter
cs = a.get_cutoffs()
cs[1] = decimal.Decimal('271') / decimal.Decimal('3')
a.set_cutoffs(cs)
s.save()
cs = a.get_cutoffs()
self.assertAlmostEquals(float(cs[1]), 90.333333333333)
示例11: TestImportViews
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
class TestImportViews(TestCase):
fixtures = ['basedata', 'coredata', 'grades']
def setUp(self):
self.c_slug = TEST_COURSE_SLUG
self.client = Client()
self.c = CourseOffering.objects.get(slug = self.c_slug)
self.a1 = NumericActivity(offering = self.c, name = 'test_assignment_1',
short_name = 'ta1', status = 'RLS',
due_date = datetime.now(), max_grade = 100,
position = 0)
self.a1.save()
def check_student_db_grade(self, grade, s, g):
self.assertEqual(grade.member, s)
self.assertEqual(grade.value, Decimal(g))
self.assertEqual(grade.flag, 'GRAD')
def test_import_view(self):
self.client.login_user('ggbaker')
# Import the file, check that resulting HTML has correct entries in fields for two affected students
url = reverse('offering:mark_all_students', kwargs={'course_slug':self.c_slug, 'activity_slug':self.a1.slug})
with open('marking/testfiles/newformat_noprob_userid.csv') as file:
post_data = {'import-file-file':[file]}
response = self.client.post(url+"?import=true", post_data, follow=True)
self.assertEqual(response.status_code, 200)
stud1 = Member.objects.get(person = Person.objects.get(userid = '0aaa0'), offering = self.c)
stud2 = Member.objects.get(person = Person.objects.get(userid = '0aaa1'), offering = self.c)
STUD1_GRADE = '88'
STUD2_GRADE = '15'
self.assertContains(response, b'value="%b"' % (STUD1_GRADE.encode('utf8'),))
self.assertContains(response, b'value="%b"' % (STUD2_GRADE.encode('utf8'),))
# Submit the grades, check that they were added to DB
post_data={'0aaa0-value':STUD1_GRADE, '0aaa1-value':STUD2_GRADE}
response = self.client.post(url, post_data, follow=True)
self.assertEqual(response.status_code, 200)
num_grades = NumericGrade.objects.filter(activity = self.a1).order_by('member__person__userid')
self.assertEqual(len(num_grades), 2)
self.check_student_db_grade(num_grades[0], stud1, STUD1_GRADE)
self.check_student_db_grade(num_grades[1], stud2, STUD2_GRADE)
示例12: test_activity_pages
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_activity_pages(self):
"""
Test pages around activities
"""
s, c = create_offering()
# add some assignments and members
a = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=c, position=2, max_grade=15, percent=10)
a.save()
a1=a
a = NumericActivity(name="Assignment 2", short_name="A2", status="URLS", offering=c, position=6, max_grade=20, group=True)
a.save()
p = Person.objects.get(userid="ggbaker")
m = Member(person=p, offering=c, role="INST", added_reason="UNK")
m.save()
p = Person.objects.get(userid="0aaa0")
m = Member(person=p, offering=c, role="STUD", added_reason="UNK")
m.save()
# test instructor pages
client = Client()
client.login_user("ggbaker")
response = basic_page_tests(self, client, '/' + c.slug + '/')
self.assertContains(response, 'href="' + reverse('groups.views.groupmanage', kwargs={'course_slug':c.slug}) +'"')
basic_page_tests(self, client, c.get_absolute_url())
basic_page_tests(self, client, reverse('grades.views.student_info', kwargs={'course_slug': c.slug, 'userid': '0aaa0'}))
basic_page_tests(self, client, reverse('grades.views.add_numeric_activity', kwargs={'course_slug':c.slug}))
basic_page_tests(self, client, reverse('grades.views.add_letter_activity', kwargs={'course_slug':c.slug}))
# test student pages
client = Client()
client.login_user("0aaa0")
response = basic_page_tests(self, client, '/' + c.slug + '/')
self.assertContains(response, "Gregory Baker")
self.assertContains(response, 'href="' + reverse('groups.views.groupmanage', kwargs={'course_slug':c.slug}) +'"')
response = basic_page_tests(self, client, a.get_absolute_url())
# small class (one student) shouldn't contain summary stats
self.assertNotContains(response, "Histogram")
self.assertNotContains(response, "Standard Deviation")
示例13: test_component_view_page
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_component_view_page(self):
_, course = create_offering()
a1 = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=course, position=2, max_grade=15, due_date="2010-04-01")
a1.save()
a2 = NumericActivity(name="Assignment 2", short_name="A2", status="RLS", offering=course, position=1, max_grade=15, due_date="2010-03-01")
a2.save()
p = Person.objects.get(userid="ggbaker")
member = Member(person=p, offering=course, role="INST", career="NONS", added_reason="UNK")
member.save()
c1 = URL.Component(activity=a1, title="URL Link", position=8)
c1.save()
c2 = Archive.Component(activity=a1, title="Archive File", position=1, max_size=100000)
c2.save()
c3 = Code.Component(activity=a1, title="Code File", position=3, max_size=2000, allowed=".py")
c3.save()
client = Client()
client.login_user("ggbaker")
# When no component, should display error message
url = reverse('submission.views.show_components', kwargs={'course_slug':course.slug, 'activity_slug':a2.slug})
response = basic_page_tests(self, client, url)
self.assertContains(response, 'No components configured.')
# add component and test
component = URL.Component(activity=a2, title="URL2", position=1)
component.save()
component = Archive.Component(activity=a2, title="Archive2", position=1, max_size=100)
component.save()
# should all appear
response = basic_page_tests(self, client, url)
self.assertContains(response, "URL2")
self.assertContains(response, "Archive2")
# make sure type displays
#self.assertContains(response, '<li class="view"><label>Type:</label>Archive</li>')
# delete component
self.assertRaises(NotImplementedError, component.delete)
示例14: test_activities
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_activities(self):
"""
Test activity classes: subclasses, selection, sorting.
"""
s, c = create_offering()
a = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=c, position=2, max_grade=15)
a.save()
a = NumericActivity(name="Assignment 2", short_name="A2", status="RLS", offering=c, position=6, max_grade=15)
a.save()
a = LetterActivity(name="Project", short_name="Proj", status="URLS", offering=c, position=1)
a.save()
a = CalNumericActivity(name="Total", short_name="Total", status="URLS", offering=c, position=42, max_grade=30, formula="[A1]+[A2]")
a.save()
allact = all_activities_filter(offering=c)
self.assertEqual(len(allact), 4)
self.assertEqual(allact[0].slug, 'proj') # make sure position=1 is first
self.assertEqual(type(allact[1]), NumericActivity)
self.assertEqual(type(allact[3]), CalNumericActivity)
示例15: test_replace_activity
# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import save [as 别名]
def test_replace_activity(self):
"""
Can we safely replace an activity with one of the same name/shortname?
"""
c = CourseOffering.objects.get(slug=self.course_slug)
a = NumericActivity(offering=c, name="Assign1", short_name="A1", status="RLS", group=False, deleted=False, max_grade=10, position=1)
a.save()
a.safely_delete()
self.assertEqual(a.deleted, True)
self.assertNotEqual(a.name, 'Assign1')
self.assertNotEqual(a.short_name, 'A1')
# replace with same type
a = CalNumericActivity(offering=c, name="Assign1", short_name="A1", status="URLS", group=True, deleted=False, max_grade=15, position=2)
a.save()
a.safely_delete()
# replace with a different type
a = LetterActivity(offering=c, name="Assign1", short_name="A1", status="RLS", group=False, deleted=False, position=3)
a.save()