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


Python PersistentCourseGrade.update_or_create方法代码示例

本文整理汇总了Python中lms.djangoapps.grades.models.PersistentCourseGrade.update_or_create方法的典型用法代码示例。如果您正苦于以下问题:Python PersistentCourseGrade.update_or_create方法的具体用法?Python PersistentCourseGrade.update_or_create怎么用?Python PersistentCourseGrade.update_or_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lms.djangoapps.grades.models.PersistentCourseGrade的用法示例。


在下文中一共展示了PersistentCourseGrade.update_or_create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update

# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create [as 别名]
 def test_update(self):
     created_grade = PersistentCourseGrade.update_or_create(**self.params)
     self.params["percent_grade"] = 88.8
     self.params["letter_grade"] = "Better job"
     updated_grade = PersistentCourseGrade.update_or_create(**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:Lektorium-LLC,项目名称: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 [as 别名]
 def test_create_and_read_grade(self):
     created_grade = PersistentCourseGrade.update_or_create(**self.params)
     read_grade = PersistentCourseGrade.read(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:Lektorium-LLC,项目名称:edx-platform,代码行数:11,代码来源:test_models.py

示例3: _update_or_create_grades

# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create [as 别名]
    def _update_or_create_grades(self, courses_keys=None):
        """
        Creates grades for all courses and subsections.
        """
        if courses_keys is None:
            courses_keys = self.course_keys

        course_grade_params = {
            "course_version": "JoeMcEwing",
            "course_edited_timestamp": datetime(
                year=2016,
                month=8,
                day=1,
                hour=18,
                minute=53,
                second=24,
                microsecond=354741,
            ),
            "percent_grade": 77.7,
            "letter_grade": "Great job",
            "passed": True,
        }
        subsection_grade_params = {
            "course_version": "deadbeef",
            "subtree_edited_timestamp": "2016-08-01 18:53:24.354741",
            "earned_all": 6.0,
            "possible_all": 12.0,
            "earned_graded": 6.0,
            "possible_graded": 8.0,
            "visible_blocks": MagicMock(),
            "first_attempted": datetime.now(),
        }

        for course_key in courses_keys:
            for user_id in self.user_ids:
                course_grade_params['user_id'] = user_id
                course_grade_params['course_id'] = course_key
                PersistentCourseGrade.update_or_create(**course_grade_params)
                for subsection_key in self.subsection_keys_by_course[course_key]:
                    subsection_grade_params['user_id'] = user_id
                    subsection_grade_params['usage_key'] = subsection_key
                    PersistentSubsectionGrade.update_or_create_grade(**subsection_grade_params)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:44,代码来源:test_reset_grades.py

示例4: test_passed_timestamp

# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create [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(**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(**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(**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(**self.params)
        self.assertEqual(grade.letter_grade, u'')
        self.assertEqual(grade.passed_timestamp, passed_timestamp)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:43,代码来源:test_models.py

示例5: test_update_or_create_event

# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create [as 别名]
 def test_update_or_create_event(self):
     with patch('lms.djangoapps.grades.models.tracker') as tracker_mock:
         grade = PersistentCourseGrade.update_or_create(**self.params)
     self._assert_tracker_emitted_event(tracker_mock, grade)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:6,代码来源:test_models.py

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

示例7: test_optional_fields

# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create [as 别名]
 def test_optional_fields(self, field):
     del self.params[field]
     grade = PersistentCourseGrade.update_or_create(**self.params)
     self.assertFalse(getattr(grade, field))
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:6,代码来源:test_models.py

示例8: test_passed_timestamp_is_now

# 需要导入模块: from lms.djangoapps.grades.models import PersistentCourseGrade [as 别名]
# 或者: from lms.djangoapps.grades.models.PersistentCourseGrade import update_or_create [as 别名]
 def test_passed_timestamp_is_now(self):
     with freeze_time(now()):
         grade = PersistentCourseGrade.update_or_create(**self.params)
         self.assertEqual(now(), grade.passed_timestamp)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:6,代码来源:test_models.py


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