Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'name', 'Name', 'string', description='user name'))
sub_registry.add_property(schema_fields.SchemaField(
'city', 'City', 'string', description='city name'))
reg.add_sub_registry('sub_registry', title='Sub Registry',
description='a sub-registry',
registry=sub_registry)
reg.add_property(schema_fields.FieldArray(
'simple_array', 'Simple Array', description='a simple array',
item_type=schema_fields.SchemaField(
'array_int', 'Array Int', 'integer', description='array int')))
complex_array_type = schema_fields.FieldRegistry('complex_array_type')
complex_array_type.add_property(schema_fields.SchemaField(
'this', 'This', 'string', description='the this'))
complex_array_type.add_property(schema_fields.SchemaField(
'that', 'That', 'number', description='the that'))
complex_array_type.add_property(schema_fields.SchemaField(
'these', 'These', 'datetime', description='the these'))
reg.add_property(schema_fields.FieldArray(
'complex_array', 'Complex Array', description='complex array',
item_type=complex_array_type))
actual_schema = self.job._json_schema_to_bigquery_schema(
reg.get_json_schema_dict()['properties'])
expected_schema = [
{'mode': 'NULLABLE',
'type': 'INTEGER',
'name': 'an_integer',
'description': 'an integer'},
{'mode': 'REQUIRED',
'type': 'STRING',
optional=True, description='an integer'))
reg.add_property(schema_fields.SchemaField(
'a_string', 'A String', 'string', description='a string'))
reg.add_property(schema_fields.SchemaField(
'some text', 'Some Text', 'text', description='some text'))
reg.add_property(schema_fields.SchemaField(
'some html', 'Some HTML', 'html', description='some html'))
reg.add_property(schema_fields.SchemaField(
'a url', 'A URL', 'url', description='a url'))
reg.add_property(schema_fields.SchemaField(
'a file', 'A File', 'file', description='a file'))
reg.add_property(schema_fields.SchemaField(
'a number', 'A Number', 'number', description='a number'))
reg.add_property(schema_fields.SchemaField(
'a boolean', 'A Boolean', 'boolean', description='a boolean'))
reg.add_property(schema_fields.SchemaField(
'a date', 'A Date', 'date', description='a date'))
reg.add_property(schema_fields.SchemaField(
'a datetime', 'A DateTime', 'datetime', description='a datetime'))
sub_registry = schema_fields.FieldRegistry('subregistry')
sub_registry.add_property(schema_fields.SchemaField(
'name', 'Name', 'string', description='user name'))
sub_registry.add_property(schema_fields.SchemaField(
'city', 'City', 'string', description='city name'))
reg.add_sub_registry('sub_registry', title='Sub Registry',
description='a sub-registry',
registry=sub_registry)
reg.add_property(schema_fields.FieldArray(
'simple_array', 'Simple Array', description='a simple array',
item_type=schema_fields.SchemaField(
choice_type = schema_fields.SchemaField(
'answer', 'Answer', 'string',
description='An answer to the question')
reg.add_property(schema_fields.FieldArray(
'answers', 'Answers', item_type=choice_type,
description='The answer from the student. Note that '
'this may be an array for questions permitting multiple answers.'))
reg.add_property(schema_fields.SchemaField(
'score', 'Score', 'number',
description='Value from the Question indicating the score for '
'this answer or set of answers.'))
reg.add_property(schema_fields.SchemaField(
'weighted_score', 'Weighted Score', 'number',
description='Question score, multiplied by weights in '
'containing Question Group, Assessment, etc.'))
reg.add_property(schema_fields.SchemaField(
'tallied', 'Tallied', 'boolean',
description='Whether the score counts towards the overall grade. '
'Lessons by default do not contribute to course score, but may '
'be marked as graded.'))
return reg.get_json_schema_dict()['properties']
optional=True))
opts.add_property(schema_fields.SchemaField(
'course:blurb', 'Abstract', 'html',
description=messages.HOMEPAGE_ABSTRACT_DESCRIPTION,
extra_schema_dict_values={
'supportCustomTags': common.tags.CAN_USE_DYNAMIC_TAGS.value,
'excludedCustomTags':
common.tags.EditorBlacklists.COURSE_SCOPE},
optional=True))
opts.add_property(schema_fields.SchemaField(
'course:instructor_details', 'Instructor Details', 'html',
description=messages.HOMEPAGE_INSTRUCTOR_DETAILS_DESCRIPTION,
optional=True))
opts.add_property(schema_fields.SchemaField(
'course:main_image:url', 'Image or Video', 'string',
description='URL for the preview image or YouTube video shown on '
'the course homepage.', optional=True,
extra_schema_dict_values={'_type': 'url', 'showMsg': True}))
opts.add_property(schema_fields.SchemaField(
'course:main_image:alt_text', 'Image Description', 'string',
description='Alt text for the preview image on the course '
'homepage.', optional=True))
opts.add_property(schema_fields.SchemaField(
'base:show_gplus_button', 'Show G+ Button', 'boolean',
description=messages.HOMEPAGE_SHOW_GPLUS_BUTTON_DESCRIPTION,
optional=True))
opts.add_property(schema_fields.SchemaField(
def get_schema(cls, course, key):
"""Return the InputEx schema for the question group editor."""
question_group = schema_fields.FieldRegistry(
'Question Group', description='question_group')
question_group.add_property(schema_fields.SchemaField(
'version', '', 'string', optional=True, hidden=True))
question_group.add_property(schema_fields.SchemaField(
'description', 'Description', 'string', optional=True))
question_group.add_property(schema_fields.SchemaField(
'introduction', 'Introduction', 'html', optional=True))
item_type = schema_fields.FieldRegistry(
'Item',
extra_schema_dict_values={'className': 'question-group-item'})
item_type.add_property(schema_fields.SchemaField(
'weight', 'Weight', 'number', optional=True, i18n=False,
extra_schema_dict_values={'className': 'question-group-weight'}))
question_select_data = [(q.id, q.description) for q in sorted(
models.QuestionDAO.get_all(), key=lambda x: x.description)]
item_type.add_property(schema_fields.SchemaField(
'question', 'Question', 'string', optional=True, i18n=False,
select_data=question_select_data,
extra_schema_dict_values={'className': 'question-group-question'}))
item_array_classes = 'question-group-items'
if not question_select_data:
item_array_classes += ' empty-question-list'
item_array = schema_fields.FieldArray(
def schema_provider(unused_course):
group = schema_fields.FieldRegistry(
COURSE_EXPLORER_SETTINGS.label, extra_schema_dict_values={
'className': 'inputEx-Group new-form-layout'})
group.add_property(schema_fields.SchemaField(
'title', 'Site Name', 'string',
description=models_messages.SITE_NAME_DESCRIPTION,
i18n=False,
optional=True,
))
group.add_property(schema_fields.SchemaField(
'logo_url', 'Site Logo', 'string',
description=messages.SITE_LOGO_DESCRIPTION,
editable=False,
extra_schema_dict_values={'visu': {
'visuType': 'funcName',
'funcName': 'renderImage',
}},
i18n=False,
optional=True,
lambda _: schema_fields.SchemaField(
'course:' + constants.SHOW_IN_EXPLORER, 'Show in Explorer',
'boolean',
description=messages.COURSE_INCLUDE_IN_EXPLORER_DESCRIPTION,
optional=True, i18n=False, default_value=True,
),
def get_schema(self, unused_handler):
reg = schema_fields.FieldRegistry(OppiaTag.name())
reg.add_property(
schema_fields.SchemaField(
'src', 'URL of the Oppia server', 'string', optional=False,
description=(
'Provide the full URL of the Oppia server\'s domain, '
'e.g. \'https://www.oppia.org\'')))
reg.add_property(
schema_fields.SchemaField(
'exploration_id', 'Exploration ID', 'string', optional=False,
description=('The Oppia exploration id.')))
return reg
def schema_provider(unused_course):
group = schema_fields.FieldRegistry(
COURSE_EXPLORER_SETTINGS.label, extra_schema_dict_values={
'className': 'inputEx-Group new-form-layout'})
group.add_property(schema_fields.SchemaField(
'title', 'Site Name', 'string',
description=models_messages.SITE_NAME_DESCRIPTION,
i18n=False,
optional=True,
))
group.add_property(schema_fields.SchemaField(
'logo_url', 'Site Logo', 'string',
description=messages.SITE_LOGO_DESCRIPTION,
editable=False,
extra_schema_dict_values={'visu': {
'visuType': 'funcName',
'funcName': 'renderImage',
}},
i18n=False,
optional=True,
))
group.add_property(schema_fields.SchemaField(
'logo', 'Change Site Logo', 'file',
i18n=False,
optional=True,
def generate_asset_rest_handler_schema(name, description, displayable=False):
"""Helper function for building schemas of asset-handling OEditor UIs."""
schema = schema_fields.FieldRegistry('Asset', description='Asset')
schema.add_property(schema_fields.SchemaField(
'file', name, 'file', description=description))
schema.add_property(schema_fields.SchemaField(
'key', 'Key', 'string', editable=False, hidden=True))
schema.add_property(schema_fields.SchemaField(
'base', 'Base', 'string', editable=False, hidden=True))
location_dict = {}
if displayable:
location_dict['visu'] = {
'visuType': 'funcName',
'funcName': 'renderAsset'}
schema.add_property(schema_fields.SchemaField(
'asset_url', 'Location', 'string', editable=False, optional=True,
extra_schema_dict_values=location_dict))
return schema