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


Python CourseMetadata.fetch方法代码示例

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


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

示例1: advanced_settings_handler

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
def advanced_settings_handler(request, package_id=None, branch=None, version_guid=None, block=None, tag=None):
    """
    Course settings configuration
    GET
        html: get the page
        json: get the model
    PUT, POST
        json: update the Course's settings. The payload is a json rep of the
            metadata dicts. The dict can include a "unsetKeys" entry which is a list
            of keys whose values to unset: i.e., revert to default
    """
    locator, course_module = _get_locator_and_course(package_id, branch, version_guid, block, request.user)
    if "text/html" in request.META.get("HTTP_ACCEPT", "") and request.method == "GET":

        return render_to_response(
            "settings_advanced.html",
            {
                "context_course": course_module,
                "advanced_dict": json.dumps(CourseMetadata.fetch(course_module)),
                "advanced_settings_url": locator.url_reverse("settings/advanced"),
            },
        )
    elif "application/json" in request.META.get("HTTP_ACCEPT", ""):
        if request.method == "GET":
            return JsonResponse(CourseMetadata.fetch(course_module))
        else:
            # Whether or not to filter the tabs key out of the settings metadata
            filter_tabs = _config_course_advanced_components(request, course_module)
            try:
                return JsonResponse(
                    CourseMetadata.update_from_json(course_module, request.json, filter_tabs=filter_tabs)
                )
            except (TypeError, ValueError) as err:
                return HttpResponseBadRequest("Incorrect setting format. {}".format(err), content_type="text/plain")
开发者ID:Bachmann1234,项目名称:edx-platform,代码行数:36,代码来源:course.py

示例2: calendar_settings_handler

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
def calendar_settings_handler(request, package_id=None, branch=None, version_guid=None, block=None, tag=None):
    locator, course_module = _get_locator_and_course(
        package_id, branch, version_guid, block, request.user
    )
    if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':

        return render_to_response('settings_calendar.html', {
            'package_id': package_id,
            'context_course': course_module,
            'advanced_dict': json.dumps(CourseMetadata.fetch(course_module)),
            'advanced_settings_url': locator.url_reverse('settings/calendar')
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            return JsonResponse(CourseMetadata.fetch(course_module))
        else:
            # Whether or not to filter the tabs key out of the settings metadata
            filter_tabs = _config_course_advanced_components(request, course_module)
            try:
                return JsonResponse(CourseMetadata.update_from_json(
                    course_module,
                    request.json,
                    filter_tabs=filter_tabs,
                    user=request.user,
                ))
            except (TypeError, ValueError) as err:
                return HttpResponseBadRequest(
                    "Incorrect setting format. {}".format(err),
                    content_type="text/plain"
                )
开发者ID:xx34,项目名称:xiaodun-platform,代码行数:32,代码来源:course.py

示例3: test_fetch_initial_fields

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
    def test_fetch_initial_fields(self):
        test_model = CourseMetadata.fetch(self.course.location)
        self.assertIn('display_name', test_model, 'Missing editable metadata field')
        self.assertEqual(test_model['display_name'], 'Robot Super Course', "not expected value")

        test_model = CourseMetadata.fetch(self.fullcourse_location)
        self.assertNotIn('graceperiod', test_model, 'blacklisted field leaked in')
        self.assertIn('display_name', test_model, 'full missing editable metadata field')
        self.assertEqual(test_model['display_name'], 'Testing', "not expected value")
        self.assertIn('rerandomize', test_model, 'Missing rerandomize metadata field')
        self.assertIn('showanswer', test_model, 'showanswer field ')
        self.assertIn('xqa_key', test_model, 'xqa_key field ')
开发者ID:kathringh,项目名称:edx-platform,代码行数:14,代码来源:test_course_settings.py

示例4: test_fetch_initial_fields

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
    def test_fetch_initial_fields(self):
        test_model = CourseMetadata.fetch(self.course)
        self.assertIn('display_name', test_model, 'Missing editable metadata field')
        self.assertEqual(test_model['display_name']['value'], self.course.display_name)

        test_model = CourseMetadata.fetch(self.fullcourse)
        self.assertNotIn('graceperiod', test_model, 'blacklisted field leaked in')
        self.assertIn('display_name', test_model, 'full missing editable metadata field')
        self.assertEqual(test_model['display_name']['value'], self.fullcourse.display_name)
        self.assertIn('rerandomize', test_model, 'Missing rerandomize metadata field')
        self.assertIn('showanswer', test_model, 'showanswer field ')
        self.assertIn('xqa_key', test_model, 'xqa_key field ')
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:14,代码来源:test_course_settings.py

示例5: test_update_from_json

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
 def test_update_from_json(self):
     test_model = CourseMetadata.update_from_json(
         self.course,
         {
             "advertised_start": {"value": "start A"},
             "days_early_for_beta": {"value": 2},
         },
         user=self.user
     )
     self.update_check(test_model)
     # try fresh fetch to ensure persistence
     fresh = modulestore().get_course(self.course.id)
     test_model = CourseMetadata.fetch(fresh)
     self.update_check(test_model)
     # now change some of the existing metadata
     test_model = CourseMetadata.update_from_json(
         fresh,
         {
             "advertised_start": {"value": "start B"},
             "display_name": {"value": "jolly roger"},
         },
         user=self.user
     )
     self.assertIn('display_name', test_model, 'Missing editable metadata field')
     self.assertEqual(test_model['display_name']['value'], 'jolly roger', "not expected value")
     self.assertIn('advertised_start', test_model, 'Missing revised advertised_start metadata field')
     self.assertEqual(test_model['advertised_start']['value'], 'start B', "advertised_start not expected value")
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:29,代码来源:test_course_settings.py

示例6: test_validate_and_update_from_json_wrong_inputs

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
    def test_validate_and_update_from_json_wrong_inputs(self):
        # input incorrectly formatted data
        is_valid, errors, test_model = CourseMetadata.validate_and_update_from_json(
            self.course,
            {
                "advertised_start": {"value": 1, "display_name": "Course Advertised Start Date", },
                "days_early_for_beta": {"value": "supposed to be an integer",
                                        "display_name": "Days Early for Beta Users", },
                "advanced_modules": {"value": 1, "display_name": "Advanced Module List", },
            },
            user=self.user
        )

        # Check valid results from validate_and_update_from_json
        self.assertFalse(is_valid)
        self.assertEqual(len(errors), 3)
        self.assertFalse(test_model)

        error_keys = set([error_obj['model']['display_name'] for error_obj in errors])
        test_keys = set(['Advanced Module List', 'Course Advertised Start Date', 'Days Early for Beta Users'])
        self.assertEqual(error_keys, test_keys)

        # try fresh fetch to ensure no update happened
        fresh = modulestore().get_course(self.course.id)
        test_model = CourseMetadata.fetch(fresh)

        self.assertNotEqual(test_model['advertised_start']['value'], 1, 'advertised_start should not be updated to a wrong value')
        self.assertNotEqual(test_model['days_early_for_beta']['value'], "supposed to be an integer",
                            'days_early_for beta should not be updated to a wrong value')
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:31,代码来源:test_course_settings.py

示例7: advanced_settings_handler

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
def advanced_settings_handler(request, course_id=None, branch=None, version_guid=None, block=None, tag=None):
    """
    Course settings configuration
    GET
        html: get the page
        json: get the model
    PUT, POST
        json: update the Course's settings. The payload is a json rep of the
            metadata dicts. The dict can include a "unsetKeys" entry which is a list
            of keys whose values to unset: i.e., revert to default
    """
    locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, usage_id=block)
    if not has_access(request.user, locator):
        raise PermissionDenied()

    course_old_location = loc_mapper().translate_locator_to_location(locator)
    course_module = modulestore().get_item(course_old_location)

    if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':

        return render_to_response('settings_advanced.html', {
            'context_course': course_module,
            'advanced_dict': json.dumps(CourseMetadata.fetch(course_module)),
            'advanced_settings_url': locator.url_reverse('settings/advanced')
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            return JsonResponse(CourseMetadata.fetch(course_module))
        else:
            # Whether or not to filter the tabs key out of the settings metadata
            filter_tabs = _config_course_advanced_components(request, course_module)
            try:
                return JsonResponse(CourseMetadata.update_from_json(
                    course_module,
                    request.json,
                    filter_tabs=filter_tabs
                ))
            except (TypeError, ValueError) as err:
                return HttpResponseBadRequest(
                    "Incorrect setting format. {}".format(err),
                    content_type="text/plain"
                )
开发者ID:e-ucm,项目名称:edx-platform,代码行数:44,代码来源:course.py

示例8: advanced_settings_handler

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
def advanced_settings_handler(request, course_key_string):
    """
    Course settings configuration
    GET
        html: get the page
        json: get the model
    PUT, POST
        json: update the Course's settings. The payload is a json rep of the
            metadata dicts. The dict can include a "unsetKeys" entry which is a list
            of keys whose values to unset: i.e., revert to default
    """
    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':

        return render_to_response('settings_advanced.html', {
            'context_course': course_module,
            'advanced_dict': json.dumps(CourseMetadata.fetch(course_module)),
            'advanced_settings_url': reverse_course_url('advanced_settings_handler', course_key)
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            return JsonResponse(CourseMetadata.fetch(course_module))
        else:
            # Whether or not to filter the tabs key out of the settings metadata
            filter_tabs = _config_course_advanced_components(request, course_module)
            try:
                return JsonResponse(CourseMetadata.update_from_json(
                    course_module,
                    request.json,
                    filter_tabs=filter_tabs,
                    user=request.user,
                ))
            except (TypeError, ValueError) as err:
                return HttpResponseBadRequest(
                    "Incorrect setting format. {}".format(err),
                    content_type="text/plain"
                )
开发者ID:87maxi,项目名称:edx-platform,代码行数:40,代码来源:course.py

示例9: advanced_settings_handler

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
def advanced_settings_handler(request, course_key_string):
    """
    Course settings configuration
    GET
        html: get the page
        json: get the model
    PUT, POST
        json: update the Course's settings. The payload is a json rep of the
            metadata dicts.
    """
    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':

        return render_to_response('settings_advanced.html', {
            'context_course': course_module,
            'advanced_dict': json.dumps(CourseMetadata.fetch(course_module)),
            'advanced_settings_url': reverse_course_url('advanced_settings_handler', course_key)
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            return JsonResponse(CourseMetadata.fetch(course_module))
        else:
            try:
                # Whether or not to filter the tabs key out of the settings metadata
                filter_tabs = _config_course_advanced_components(request, course_module)
                return JsonResponse(CourseMetadata.update_from_json(
                    course_module,
                    request.json,
                    filter_tabs=filter_tabs,
                    user=request.user,
                ))
            except (TypeError, ValueError) as err:
                return HttpResponseBadRequest(
                    django.utils.html.escape(err.message),
                    content_type="text/plain"
                )
开发者ID:ibrahima,项目名称:edx-platform,代码行数:39,代码来源:course.py

示例10: course_config_advanced_page

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
def course_config_advanced_page(request, org, course, name):
    """
    Send models and views as well as html for editing the advanced course settings to the client.

    org, course, name: Attributes of the Location for the item to edit
    """
    location = get_location_and_verify_access(request, org, course, name)

    course_module = modulestore().get_item(location)

    return render_to_response('settings_advanced.html', {
        'context_course': course_module,
        'course_location': location,
        'advanced_dict': json.dumps(CourseMetadata.fetch(location)),
    })
开发者ID:bizdict,项目名称:edx-platform,代码行数:17,代码来源:course.py

示例11: mobi_get_topics

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
def mobi_get_topics(request, course_id):
    """
    Return course topics
    """
    course_id = course_id.replace('.', '/')
    nr_transaction = newrelic.agent.current_transaction()
    try:
        course = get_course_with_access(request.user, course_id, "load_forum")
    except:
        return JsonResponse({"success": False, 'errmsg': "can not find a course with " + course_id.replace('/', '.') + " id"})


    return JsonResponse({
        "topic-list": CourseMetadata.fetch(course).pop("discussion_topics"),
        "success": True
    })
开发者ID:JamseSun,项目名称:xiaodun-platform,代码行数:18,代码来源:views.py

示例12: test_update_from_json

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
 def test_update_from_json(self):
     test_model = CourseMetadata.update_from_json(
         self.course.location,
         {"advertised_start": "start A", "testcenter_info": {"c": "test"}, "days_early_for_beta": 2},
     )
     self.update_check(test_model)
     # try fresh fetch to ensure persistence
     test_model = CourseMetadata.fetch(self.course.location)
     self.update_check(test_model)
     # now change some of the existing metadata
     test_model = CourseMetadata.update_from_json(
         self.course.location, {"advertised_start": "start B", "display_name": "jolly roger"}
     )
     self.assertIn("display_name", test_model, "Missing editable metadata field")
     self.assertEqual(test_model["display_name"], "jolly roger", "not expected value")
     self.assertIn("advertised_start", test_model, "Missing revised advertised_start metadata field")
     self.assertEqual(test_model["advertised_start"], "start B", "advertised_start not expected value")
开发者ID:rajeshpillai,项目名称:edx-platform,代码行数:19,代码来源:test_course_settings.py

示例13: test_validate_and_update_from_json_correct_inputs

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
    def test_validate_and_update_from_json_correct_inputs(self):
        is_valid, errors, test_model = CourseMetadata.validate_and_update_from_json(
            self.course,
            {
                "advertised_start": {"value": "start A"},
                "days_early_for_beta": {"value": 2},
                "advanced_modules": {"value": ['combinedopenended']},
            },
            user=self.user
        )
        self.assertTrue(is_valid)
        self.assertTrue(len(errors) == 0)
        self.update_check(test_model)

        # fresh fetch to ensure persistence
        fresh = modulestore().get_course(self.course.id)
        test_model = CourseMetadata.fetch(fresh)
        self.update_check(test_model)

        # Tab gets tested in test_advanced_settings_munge_tabs
        self.assertIn('advanced_modules', test_model, 'Missing advanced_modules')
        self.assertEqual(test_model['advanced_modules']['value'], ['combinedopenended'], 'advanced_module is not updated')
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:24,代码来源:test_course_settings.py

示例14: test_edxnotes_not_present

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
 def test_edxnotes_not_present(self):
     """
     If feature flag ENABLE_EDXNOTES is off, don't show the setting at all on the Advanced Settings page.
     """
     test_model = CourseMetadata.fetch(self.fullcourse)
     self.assertNotIn('edxnotes', test_model)
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:8,代码来源:test_course_settings.py

示例15: test_edxnotes_present

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import fetch [as 别名]
 def test_edxnotes_present(self):
     """
     If feature flag ENABLE_EDXNOTES is on, show the setting as a non-deprecated Advanced Setting.
     """
     test_model = CourseMetadata.fetch(self.fullcourse)
     self.assertIn('edxnotes', test_model)
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:8,代码来源:test_course_settings.py


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