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


Python models.PersistentGradesEnabledFlag类代码示例

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


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

示例1: test_persistent_grades_feature_flags

 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,代码行数:16,代码来源:test_models.py

示例2: test_query_counts

 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,代码行数:7,代码来源:test_tasks.py

示例3: recalculate_subsection_grade_handler

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,代码行数:30,代码来源:signals.py

示例4: test_persistent_grades_not_enabled_on_course

 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,代码行数:7,代码来源:test_tasks.py

示例5: update

    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,代码行数:35,代码来源:subsection_grade.py

示例6: create

    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,代码行数:28,代码来源:subsection_grade.py

示例7: _get_saved_grade

 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,代码行数:7,代码来源:course_grade.py

示例8: test_query_count_does_not_change_with_more_problems

 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,代码行数:8,代码来源:test_signals.py

示例9: test_query_count_does_not_change_with_more_problems

 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,代码行数:8,代码来源:test_tasks.py

示例10: test_single_call_to_create_block_structure

 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,代码行数:8,代码来源:test_tasks.py

示例11: _get_saved_grade

    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,代码行数:8,代码来源:course_grade.py


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