本文整理汇总了Python中lms.djangoapps.grades.models.PersistentCourseGrade.update_or_create_course_grade方法的典型用法代码示例。如果您正苦于以下问题:Python PersistentCourseGrade.update_or_create_course_grade方法的具体用法?Python PersistentCourseGrade.update_or_create_course_grade怎么用?Python PersistentCourseGrade.update_or_create_course_grade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lms.djangoapps.grades.models.PersistentCourseGrade
的用法示例。
在下文中一共展示了PersistentCourseGrade.update_or_create_course_grade方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_update(self):
created_grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.params["percent_grade"] = 88.8
self.params["letter_grade"] = "Better job"
updated_grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.assertEqual(updated_grade.percent_grade, 88.8)
self.assertEqual(updated_grade.letter_grade, "Better job")
self.assertEqual(created_grade.id, updated_grade.id)
示例2: test_create_and_read_grade
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_create_and_read_grade(self):
created_grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
read_grade = PersistentCourseGrade.read_course_grade(self.params["user_id"], self.params["course_id"])
for param in self.params:
if param == u'passed':
continue # passed/passed_timestamp takes special handling, and is tested separately
self.assertEqual(self.params[param], getattr(created_grade, param))
self.assertIsInstance(created_grade.passed_timestamp, datetime)
self.assertEqual(created_grade, read_grade)
示例3: test_passed_timestamp
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_passed_timestamp(self):
# When the user has not passed, passed_timestamp is None
self.params.update({
u'percent_grade': 25.0,
u'letter_grade': u'',
u'passed': False,
})
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.assertIsNone(grade.passed_timestamp)
# After the user earns a passing grade, the passed_timestamp is set
self.params.update({
u'percent_grade': 75.0,
u'letter_grade': u'C',
u'passed': True,
})
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
passed_timestamp = grade.passed_timestamp
self.assertEqual(grade.letter_grade, u'C')
self.assertIsInstance(passed_timestamp, datetime)
# After the user improves their score, the new grade is reflected, but
# the passed_timestamp remains the same.
self.params.update({
u'percent_grade': 95.0,
u'letter_grade': u'A',
u'passed': True,
})
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.assertEqual(grade.letter_grade, u'A')
self.assertEqual(grade.passed_timestamp, passed_timestamp)
# If the grade later reverts to a failing grade, they keep their passed_timestamp
self.params.update({
u'percent_grade': 20.0,
u'letter_grade': u'',
u'passed': False,
})
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.assertEqual(grade.letter_grade, u'')
self.assertEqual(grade.passed_timestamp, passed_timestamp)
示例4: test_update_or_create_with_bad_params
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_update_or_create_with_bad_params(self, param, val, error):
self.params[param] = val
with self.assertRaises(error):
PersistentCourseGrade.update_or_create_course_grade(**self.params)
示例5: test_course_version_optional
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_course_version_optional(self):
del self.params["course_version"]
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.assertEqual("", grade.course_version)
示例6: test_passed_timestamp_is_now
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_passed_timestamp_is_now(self):
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.assertEqual(now(), grade.passed_timestamp)
示例7: test_create_and_read_grade
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_create_and_read_grade(self):
created_grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
read_grade = PersistentCourseGrade.read_course_grade(self.params["user_id"], self.params["course_id"])
for param in self.params:
self.assertEqual(self.params[param], getattr(created_grade, param))
self.assertEqual(created_grade, read_grade)
示例8: test_update_or_create_event
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_update_or_create_event(self):
with patch('lms.djangoapps.grades.models.tracker') as tracker_mock:
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self._assert_tracker_emitted_event(tracker_mock, grade)
示例9: test_optional_fields
# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create_course_grade [as 别名]
def test_optional_fields(self, field):
del self.params[field]
grade = PersistentCourseGrade.update_or_create_course_grade(**self.params)
self.assertFalse(getattr(grade, field))