当前位置: 首页>>代码示例>>Python>>正文


Python PersistentCourseGrade.update_or_create_course_grade方法代码示例

本文整理汇总了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)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:10,代码来源:test_models.py

示例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)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:11,代码来源:test_models.py

示例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)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:43,代码来源:test_models.py

示例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)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:6,代码来源:test_models.py

示例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)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:6,代码来源:test_models.py

示例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)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:5,代码来源:test_models.py

示例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)
开发者ID:chrisndodge,项目名称:edx-platform,代码行数:8,代码来源:test_models.py

示例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)
开发者ID:CredoReference,项目名称:edx-platform,代码行数:6,代码来源:test_models.py

示例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))
开发者ID:shevious,项目名称:edx-platform,代码行数:6,代码来源:test_models.py


注:本文中的lms.djangoapps.grades.models.PersistentCourseGrade.update_or_create_course_grade方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。