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


Python CourseGradingModel.update_from_json方法代码示例

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


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

示例1: test_update_from_json

# 需要导入模块: from models.settings.course_grading import CourseGradingModel [as 别名]
# 或者: from models.settings.course_grading.CourseGradingModel import update_from_json [as 别名]
    def test_update_from_json(self):
        test_grader = CourseGradingModel.fetch(self.course_location)
        altered_grader = CourseGradingModel.update_from_json(
            test_grader.__dict__)
        self.assertDictEqual(
            test_grader.__dict__, altered_grader.__dict__, "Noop update")

        test_grader.graders[0][
            'weight'] = test_grader.graders[0].get('weight') * 2
        altered_grader = CourseGradingModel.update_from_json(
            test_grader.__dict__)
        self.assertDictEqual(
            test_grader.__dict__, altered_grader.__dict__, "Weight[0] * 2")

        test_grader.grade_cutoffs['D'] = 0.3
        altered_grader = CourseGradingModel.update_from_json(
            test_grader.__dict__)
        self.assertDictEqual(
            test_grader.__dict__, altered_grader.__dict__, "cutoff add D")

        test_grader.grace_period = {'hours': 4, 'minutes': 5, 'seconds': 0}
        altered_grader = CourseGradingModel.update_from_json(
            test_grader.__dict__)
        print test_grader.grace_period, altered_grader.grace_period
        self.assertDictEqual(
            test_grader.__dict__, altered_grader.__dict__, "4 hour grace period")
开发者ID:hughdbrown,项目名称:edx-platform,代码行数:28,代码来源:test_course_settings.py

示例2: test_update_from_json

# 需要导入模块: from models.settings.course_grading import CourseGradingModel [as 别名]
# 或者: from models.settings.course_grading.CourseGradingModel import update_from_json [as 别名]
    def test_update_from_json(self):
        test_grader = CourseGradingModel.fetch(self.course.location)
        altered_grader = CourseGradingModel.update_from_json(test_grader.__dict__)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "Noop update")

        test_grader.graders[0]["weight"] = test_grader.graders[0].get("weight") * 2
        altered_grader = CourseGradingModel.update_from_json(test_grader.__dict__)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "Weight[0] * 2")

        test_grader.grade_cutoffs["D"] = 0.3
        altered_grader = CourseGradingModel.update_from_json(test_grader.__dict__)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "cutoff add D")

        test_grader.grace_period = {"hours": 4, "minutes": 5, "seconds": 0}
        altered_grader = CourseGradingModel.update_from_json(test_grader.__dict__)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "4 hour grace period")
开发者ID:rajeshpillai,项目名称:edx-platform,代码行数:18,代码来源:test_course_settings.py

示例3: test_update_from_json

# 需要导入模块: from models.settings.course_grading import CourseGradingModel [as 别名]
# 或者: from models.settings.course_grading.CourseGradingModel import update_from_json [as 别名]
    def test_update_from_json(self, store):
        self.course = CourseFactory.create(default_store=store)

        test_grader = CourseGradingModel.fetch(self.course.id)
        altered_grader = CourseGradingModel.update_from_json(self.course.id, test_grader.__dict__, self.user)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "Noop update")

        test_grader.graders[0]['weight'] = test_grader.graders[0].get('weight') * 2
        altered_grader = CourseGradingModel.update_from_json(self.course.id, test_grader.__dict__, self.user)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "Weight[0] * 2")

        # test for bug LMS-11485
        with modulestore().bulk_operations(self.course.id):
            new_grader = test_grader.graders[0].copy()
            new_grader['type'] += '_foo'
            new_grader['short_label'] += '_foo'
            new_grader['id'] = len(test_grader.graders)
            test_grader.graders.append(new_grader)
            # don't use altered cached def, get a fresh one
            CourseGradingModel.update_from_json(self.course.id, test_grader.__dict__, self.user)
            altered_grader = CourseGradingModel.fetch(self.course.id)
            self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__)

        test_grader.grade_cutoffs['D'] = 0.3
        altered_grader = CourseGradingModel.update_from_json(self.course.id, test_grader.__dict__, self.user)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "cutoff add D")

        test_grader.grace_period = {'hours': 4, 'minutes': 5, 'seconds': 0}
        altered_grader = CourseGradingModel.update_from_json(self.course.id, test_grader.__dict__, self.user)
        self.assertDictEqual(test_grader.__dict__, altered_grader.__dict__, "4 hour grace period")
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:32,代码来源:test_course_settings.py

示例4: grading_handler

# 需要导入模块: from models.settings.course_grading import CourseGradingModel [as 别名]
# 或者: from models.settings.course_grading.CourseGradingModel import update_from_json [as 别名]
def grading_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None, grader_index=None):
    """
    Course Grading policy configuration
    GET
        html: get the page
        json no grader_index: get the CourseGrading model (graceperiod, cutoffs, and graders)
        json w/ grader_index: get the specific grader
    PUT
        json no grader_index: update the Course through the CourseGrading model
        json w/ grader_index: create or update the specific grader (create if index out of range)
    """
    locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, usage_id=block)
    if not has_access(request.user, locator):
        raise PermissionDenied()

    if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
        course_old_location = loc_mapper().translate_locator_to_location(locator)
        course_module = modulestore().get_item(course_old_location)
        course_details = CourseGradingModel.fetch(locator)

        return render_to_response('settings_graders.html', {
            'context_course': course_module,
            'course_locator': locator,
            'course_details': json.dumps(course_details, cls=CourseSettingsEncoder),
            'grading_url': locator.url_reverse('/settings/grading/'),
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            if grader_index is None:
                return JsonResponse(
                    CourseGradingModel.fetch(locator),
                    # encoder serializes dates, old locations, and instances
                    encoder=CourseSettingsEncoder
                )
            else:
                return JsonResponse(CourseGradingModel.fetch_grader(locator, grader_index))
        elif request.method in ('POST', 'PUT'):  # post or put, doesn't matter.
            # None implies update the whole model (cutoffs, graceperiod, and graders) not a specific grader
            if grader_index is None:
                return JsonResponse(
                    CourseGradingModel.update_from_json(locator, request.json),
                    encoder=CourseSettingsEncoder
                )
            else:
                return JsonResponse(
                    CourseGradingModel.update_grader_from_json(locator, request.json)
                )
        elif request.method == "DELETE" and grader_index is not None:
            CourseGradingModel.delete_grader(locator, grader_index)
            return JsonResponse()
开发者ID:e-ucm,项目名称:edx-platform,代码行数:52,代码来源:course.py

示例5: grading_handler

# 需要导入模块: from models.settings.course_grading import CourseGradingModel [as 别名]
# 或者: from models.settings.course_grading.CourseGradingModel import update_from_json [as 别名]
def grading_handler(request, course_key_string, grader_index=None):
    """
    Course Grading policy configuration
    GET
        html: get the page
        json no grader_index: get the CourseGrading model (graceperiod, cutoffs, and graders)
        json w/ grader_index: get the specific grader
    PUT
        json no grader_index: update the Course through the CourseGrading model
        json w/ grader_index: create or update the specific grader (create if index out of range)
    """
    course_key = CourseKey.from_string(course_key_string)
    course_module = _get_course_module(course_key, request.user)

    if "text/html" in request.META.get("HTTP_ACCEPT", "") and request.method == "GET":
        course_details = CourseGradingModel.fetch(course_key)

        return render_to_response(
            "settings_graders.html",
            {
                "context_course": course_module,
                "course_locator": course_key,
                "course_details": json.dumps(course_details, cls=CourseSettingsEncoder),
                "grading_url": reverse_course_url("grading_handler", course_key),
            },
        )
    elif "application/json" in request.META.get("HTTP_ACCEPT", ""):
        if request.method == "GET":
            if grader_index is None:
                return JsonResponse(
                    CourseGradingModel.fetch(course_key),
                    # encoder serializes dates, old locations, and instances
                    encoder=CourseSettingsEncoder,
                )
            else:
                return JsonResponse(CourseGradingModel.fetch_grader(course_key, grader_index))
        elif request.method in ("POST", "PUT"):  # post or put, doesn't matter.
            # None implies update the whole model (cutoffs, graceperiod, and graders) not a specific grader
            if grader_index is None:
                return JsonResponse(
                    CourseGradingModel.update_from_json(course_key, request.json, request.user),
                    encoder=CourseSettingsEncoder,
                )
            else:
                return JsonResponse(CourseGradingModel.update_grader_from_json(course_key, request.json, request.user))
        elif request.method == "DELETE" and grader_index is not None:
            CourseGradingModel.delete_grader(course_key, grader_index, request.user)
            return JsonResponse()
开发者ID:hmcmooc,项目名称:muddx-platform,代码行数:50,代码来源:course.py


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