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


Python PersistentGradesEnabledFlag.feature_enabled方法代码示例

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


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

示例1: create

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
    def create(self, subsection, block_structure=None, read_only=False):
        """
        Returns the SubsectionGrade object for the student and subsection.

        If block_structure is provided, uses it for finding and computing
        the grade instead of the course_structure passed in earlier.

        If read_only is True, doesn't save any updates to the grades.
        """
        self._log_event(
            log.warning, u"create, read_only: {0}, subsection: {1}".format(read_only, subsection.location)
        )

        block_structure = self._get_block_structure(block_structure)
        subsection_grade = self._get_saved_grade(subsection, block_structure)
        if not subsection_grade:
            subsection_grade = SubsectionGrade(subsection, self.course)
            subsection_grade.init_from_structure(
                self.student, block_structure, self._scores_client, self._submissions_scores
            )
            if PersistentGradesEnabledFlag.feature_enabled(self.course.id):
                if read_only:
                    self._unsaved_subsection_grades.append(subsection_grade)
                else:
                    with persistence_safe_fallback():
                        grade_model = subsection_grade.create_model(self.student)
                        self._update_saved_subsection_grade(subsection.location, grade_model)
        return subsection_grade
开发者ID:jjmiranda,项目名称:edx-platform,代码行数:30,代码来源:subsection_grade.py

示例2: test_persistent_grades_not_enabled_on_course

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_persistent_grades_not_enabled_on_course(self, default_store):
     with self.store.default_store(default_store):
         self.set_up_course(enable_persistent_grades=False)
         self.assertFalse(PersistentGradesEnabledFlag.feature_enabled(self.course.id))
         with check_mongo_calls(0):
             with self.assertNumQueries(0):
                 self._apply_recalculate_subsection_grade()
开发者ID:shevious,项目名称:edx-platform,代码行数:9,代码来源:test_tasks.py

示例3: _get_saved_grade

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def _get_saved_grade(self, course, course_structure):  # pylint: disable=unused-argument
     """
     Returns the saved grade for the given course and student.
     """
     if PersistentGradesEnabledFlag.feature_enabled(course.id):
         # TODO LATER Retrieve the saved grade for the course, if it exists.
         _pretend_to_save_course_grades()
开发者ID:jjmiranda,项目名称:edx-platform,代码行数:9,代码来源:course_grade.py

示例4: recalculate_subsection_grade_handler

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
def recalculate_subsection_grade_handler(sender, **kwargs):  # pylint: disable=unused-argument
    """
    Consume the SCORE_CHANGED signal and trigger an update.
    This method expects that the kwargs dictionary will contain the following
    entries (See the definition of SCORE_CHANGED):
       - points_possible: Maximum score available for the exercise
       - points_earned: Score obtained by the user
       - user: User object
       - course_id: Unicode string representing the course
       - usage_id: Unicode string indicating the courseware instance
    """
    try:
        course_id = kwargs.get('course_id', None)
        usage_id = kwargs.get('usage_id', None)
        student = kwargs.get('user', None)

        course_key = CourseLocator.from_string(course_id)
        if not PersistentGradesEnabledFlag.feature_enabled(course_key):
            return

        usage_key = UsageKey.from_string(usage_id).replace(course_key=course_key)

        from lms.djangoapps.grades.new.subsection_grade import SubsectionGradeFactory
        SubsectionGradeFactory(student).update(usage_key, course_key)
    except Exception as ex:  # pylint: disable=broad-except
        log.exception(
            u"Failed to process SCORE_CHANGED signal. "
            "user: %s, course_id: %s, "
            "usage_id: %s. Exception: %s", unicode(student), course_id, usage_id, ex.message
        )
开发者ID:louyihua,项目名称:edx-platform,代码行数:32,代码来源:signals.py

示例5: test_query_counts

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_query_counts(self, default_store, num_mongo_calls, num_sql_calls, create_multiple_subsections):
     with self.store.default_store(default_store):
         self.set_up_course(create_multiple_subsections=create_multiple_subsections)
         self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course.id))
         with check_mongo_calls(num_mongo_calls):
             with self.assertNumQueries(num_sql_calls):
                 self._apply_recalculate_subsection_grade()
开发者ID:dehamzah,项目名称:edx-platform,代码行数:9,代码来源:test_tasks.py

示例6: test_persistent_grades_feature_flags

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_persistent_grades_feature_flags(self, global_flag, enabled_for_all_courses, enabled_for_course_1):
     with persistent_grades_feature_flags(
         global_flag=global_flag,
         enabled_for_all_courses=enabled_for_all_courses,
         course_id=self.course_id_1,
         enabled_for_course=enabled_for_course_1
     ):
         self.assertEqual(PersistentGradesEnabledFlag.feature_enabled(), global_flag)
         self.assertEqual(
             PersistentGradesEnabledFlag.feature_enabled(self.course_id_1),
             global_flag and (enabled_for_all_courses or enabled_for_course_1)
         )
         self.assertEqual(
             PersistentGradesEnabledFlag.feature_enabled(self.course_id_2),
             global_flag and enabled_for_all_courses
         )
开发者ID:Colin-Fredericks,项目名称:edx-platform,代码行数:18,代码来源:test_models.py

示例7: update

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
    def update(self, subsection, only_if_higher=None):
        """
        Updates the SubsectionGrade object for the student and subsection.
        """
        # Save ourselves the extra queries if the course does not persist
        # subsection grades.
        if not PersistentGradesEnabledFlag.feature_enabled(self.course.id):
            return

        self._log_event(log.warning, u"update, subsection: {}".format(subsection.location), subsection)

        calculated_grade = SubsectionGrade(subsection).init_from_structure(
            self.student, self.course_structure, self._submissions_scores, self._csm_scores,
        )

        if only_if_higher:
            try:
                grade_model = PersistentSubsectionGrade.read_grade(self.student.id, subsection.location)
            except PersistentSubsectionGrade.DoesNotExist:
                pass
            else:
                orig_subsection_grade = SubsectionGrade(subsection).init_from_model(
                    self.student, grade_model, self.course_structure, self._submissions_scores, self._csm_scores,
                )
                if not is_score_higher(
                        orig_subsection_grade.graded_total.earned,
                        orig_subsection_grade.graded_total.possible,
                        calculated_grade.graded_total.earned,
                        calculated_grade.graded_total.possible,
                ):
                    return orig_subsection_grade

        grade_model = calculated_grade.update_or_create_model(self.student)
        self._update_saved_subsection_grade(subsection.location, grade_model)
        return calculated_grade
开发者ID:shevious,项目名称:edx-platform,代码行数:37,代码来源:subsection_grade.py

示例8: _get_saved_grade

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
    def _get_saved_grade(self, course, course_structure):
        """
        Returns the saved grade for the given course and student.
        """
        if not PersistentGradesEnabledFlag.feature_enabled(course.id):
            return None

        return CourseGrade.load_persisted_grade(self.student, course, course_structure)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:10,代码来源:course_grade.py

示例9: test_query_count_does_not_change_with_more_problems

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_query_count_does_not_change_with_more_problems(self, default_store):
     with self.store.default_store(default_store):
         self.set_up_course()
         self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course.id))
         ItemFactory.create(parent=self.sequential, category='problem', display_name='problem2')
         ItemFactory.create(parent=self.sequential, category='problem', display_name='problem3')
         with check_mongo_calls(2) and self.assertNumQueries(15):
             recalculate_subsection_grade_handler(None, **self.score_changed_kwargs)
开发者ID:singingwolfboy,项目名称:edx-platform,代码行数:10,代码来源:test_signals.py

示例10: test_query_count_does_not_change_with_more_problems

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_query_count_does_not_change_with_more_problems(self, default_store, added_queries):
     with self.store.default_store(default_store):
         self.set_up_course()
         self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course.id))
         ItemFactory.create(parent=self.sequential, category="problem", display_name="problem2")
         ItemFactory.create(parent=self.sequential, category="problem", display_name="problem3")
         with check_mongo_calls(2) and self.assertNumQueries(20 + added_queries):
             self._apply_recalculate_subsection_grade()
开发者ID:CUCWD,项目名称:edx-platform,代码行数:10,代码来源:test_tasks.py

示例11: test_single_call_to_create_block_structure

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_single_call_to_create_block_structure(self):
     self.set_up_course()
     self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course.id))
     with patch(
         "openedx.core.lib.block_structure.factory.BlockStructureFactory.create_from_cache", return_value=None
     ) as mock_block_structure_create:
         self._apply_recalculate_subsection_grade()
         self.assertEquals(mock_block_structure_create.call_count, 1)
开发者ID:CUCWD,项目名称:edx-platform,代码行数:10,代码来源:test_tasks.py

示例12: test_single_call_to_create_block_structure

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_single_call_to_create_block_structure(self):
     self.set_up_course()
     self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course.id))
     with patch(
         'openedx.core.lib.block_structure.factory.BlockStructureFactory.create_from_cache',
         return_value=None,
     ) as mock_block_structure_create:
         recalculate_subsection_grade_handler(None, **self.score_changed_kwargs)
         self.assertEquals(mock_block_structure_create.call_count, 1)
开发者ID:singingwolfboy,项目名称:edx-platform,代码行数:11,代码来源:test_signals.py

示例13: get_persisted

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
    def get_persisted(self, student, course):
        """
        Returns the saved grade for the given course and student,
        irrespective of whether the saved grade is up-to-date.
        """
        if not PersistentGradesEnabledFlag.feature_enabled(course.id):
            return None

        return CourseGrade.get_persisted_grade(student, course)
开发者ID:shevious,项目名称:edx-platform,代码行数:11,代码来源:course_grade.py

示例14: test_block_structure_created_only_once

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_block_structure_created_only_once(self):
     self.set_up_course()
     self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course.id))
     with patch(
         'openedx.core.djangoapps.content.block_structure.factory.BlockStructureFactory.create_from_store',
         side_effect=BlockStructureNotFound(self.course.location),
     ) as mock_block_structure_create:
         self._apply_recalculate_subsection_grade()
         self.assertEquals(mock_block_structure_create.call_count, 1)
开发者ID:dehamzah,项目名称:edx-platform,代码行数:11,代码来源:test_tasks.py

示例15: test_enable_disable_course_flag

# 需要导入模块: from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag [as 别名]
# 或者: from lms.djangoapps.grades.config.models.PersistentGradesEnabledFlag import feature_enabled [as 别名]
 def test_enable_disable_course_flag(self):
     """
     Ensures that the flag, once enabled for a course, can also be disabled.
     """
     with persistent_grades_feature_flags(
         global_flag=True,
         enabled_for_all_courses=False,
         course_id=self.course_id_1,
         enabled_for_course=True
     ):
         self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course_id_1))
         # Prior to TNL-5698, creating a second object would fail due to db constraints
         with persistent_grades_feature_flags(
             global_flag=True,
             enabled_for_all_courses=False,
             course_id=self.course_id_1,
             enabled_for_course=False
         ):
             self.assertFalse(PersistentGradesEnabledFlag.feature_enabled(self.course_id_1))
开发者ID:Colin-Fredericks,项目名称:edx-platform,代码行数:21,代码来源:test_models.py


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