def create_explorer_page_registry(): """Create the registry for course properties.""" reg = FieldRegistry( 'Explorer Page', description='Explorer Page', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout'}) # Course level settings. course_opts = reg.add_sub_registry('top_half', 'Top Half') course_opts.add_property(SchemaField( 'top_text', 'Top Text', 'html', optional=False, description=('Problem Statement and description of program, visible' ' to student.'), extra_schema_dict_values={ 'supportCustomTags': tags.CAN_USE_DYNAMIC_TAGS.value, 'className': 'inputEx-Field content'})) course_opts.add_property(SchemaField( 'video_id', 'Right hand side video', 'string', optional=True)) category_list_items = FieldRegistry('', '') category_list_items.add_property(SchemaField( 'category', 'Category', 'string', optional=True, extra_schema_dict_values={}, select_data=[])) category_list_opts = FieldArray( 'category_list', 'Category Order', item_type=category_list_items, extra_schema_dict_values={ 'sortable': True, 'listAddLabel': 'Add Category', 'listRemoveLabel': 'Delete Category'}) cli = reg.add_sub_registry('category_list', 'Category List') cli.add_property(category_list_opts) return reg
def make_labels_group_schema_field(cls): label = FieldRegistry(None, description='label') label.add_property( SchemaField('id', 'ID', 'integer', hidden=True, editable=False)) label.add_property(SchemaField('checked', None, 'boolean')) label.add_property( SchemaField('title', None, 'string', optional=True, editable=False)) label.add_property( SchemaField( 'description', None, 'string', optional=True, editable=False, extra_schema_dict_values={'className': 'label-description'})) label.add_property( SchemaField( 'no_labels', None, 'string', optional=True, editable=False, extra_schema_dict_values={'className': 'label-none-in-group'})) label_group = FieldRegistry('', description='label groups') label_group.add_property( SchemaField('title', None, 'string', editable=False)) label_group.add_property( FieldArray('labels', None, item_type=label, extra_schema_dict_values={'className': 'label-group'})) return label_group
def SCHEMA(cls, title, announcement_email): schema = FieldRegistry(title) schema.add_property(SchemaField( 'key', 'ID', 'string', editable=False, extra_schema_dict_values={'className': 'inputEx-Field keyHolder'})) schema.add_property(SchemaField( 'title', 'Title', 'string', optional=True)) schema.add_property(SchemaField( 'html', 'Body', 'html', optional=True, extra_schema_dict_values={ 'supportCustomTags': tags.CAN_USE_DYNAMIC_TAGS.value, 'excludedCustomTags': tags.EditorBlacklists.COURSE_SCOPE})) schema.add_property(SchemaField( 'date', 'Date', 'date', optional=True, extra_schema_dict_values={ '_type': 'date', 'dateFormat': 'Y-m-d', 'valueFormat': 'Y-m-d'})) schema.add_property(FieldArray( 'label_groups', 'Labels', item_type=LabelGroupsHelper.make_labels_group_schema_field(), extra_schema_dict_values={ 'className': 'inputEx-Field label-group-list'})) schema.add_property(SchemaField( 'send_email', 'Send Email', 'boolean', optional=True, extra_schema_dict_values={ 'description': AnnouncementsItemRESTHandler.get_send_email_description( announcement_email)})) schema.add_property(SchemaField( 'is_draft', 'Status', 'boolean', select_data=[(True, DRAFT_TEXT), (False, PUBLISHED_TEXT)], extra_schema_dict_values={'className': 'split-from-main-group'})) return schema
class ProgrammingAssignmentSettings(base.ProgAssignment): language_opts = FieldRegistry('Programming Language', '') language_opts.add_property( SchemaField( 'language', 'Programming Language', 'string', select_data=base.ProgAssignment.PROG_LANG_FILE_MAP.items())) language_opts.add_property( SchemaField('build', 'Build extra args', 'string', optional=True)) language_opts.add_property( SchemaField('exec', 'Execution extra args', 'string', optional=True)) language_opts.add_property( SchemaField('time_limit', 'Time Limit', 'integer', optional=True)) language_opts.add_property( SchemaField('memory_limit', 'Memory Limit', 'integer', optional=True)) language_opts.add_property( SchemaField('process_limit', 'process Limit', 'integer', optional=True)) language_opts.add_property( SchemaField('compilation_time_limit', 'Compilation Time Limit', 'integer', optional=True)) language_opts.add_property( SchemaField('compilation_memory_limit', 'Compilation Memory Limit', 'integer', optional=True)) language_opts.add_property( SchemaField('compilation_process_limit', 'Compilation process Limit', 'integer', optional=True)) allowed_languages = FieldArray( programming_assignment_key('allowed_languages'), 'Programming Languages for this Course', item_type=language_opts, extra_schema_dict_values={ 'sortable': False, 'listAddLabel': 'Add Language', 'listRemoveLabel': 'Delete', 'minItems': 1 }) @classmethod def register(cls): programming_settings_fields = set() programming_settings_fields.add(lambda c: cls.allowed_languages) courses.Course.OPTIONS_SCHEMA_PROVIDERS[ cls.SETTINGS_SECTION] += programming_settings_fields tabs.Registry.register('settings', cls.DASHBOARD_NAV, cls.NAME, cls.SETTINGS_SECTION) @classmethod def unregister(cls): programming_settings_fields = set() programming_settings_fields.add(lambda c: cls.allowed_languages) for field in programming_settings_fields: courses.Course.OPTIONS_SCHEMA_PROVIDERS[ cls.SETTINGS_SECTION].remove(field)
def create_prog_assignment_registry(): """Create the registry for course properties.""" reg = FieldRegistry('Prog Assignment Entity', description='Prog Assignment', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout' }) # Course level settings. course_opts = reg.add_sub_registry('prog_assignment', 'Assignment Config') course_opts.add_property( SchemaField( 'key', 'ID', 'string', editable=False, extra_schema_dict_values={'className': 'inputEx-Field keyHolder'}, description='Unique Id of the Assignment')) course_opts.add_property( SchemaField( 'pa_id', 'PA_ID', 'string', editable=False, extra_schema_dict_values={'className': 'inputEx-Field keyHolder'}, description='Unique id of the test cases in this assignment.')) course_opts.add_property( SchemaField('parent_unit', 'Parent Unit', 'string', select_data=[])) course_opts.add_property( SchemaField('type', 'Type', 'string', editable=False)) course_opts.add_property( SchemaField('title', 'Title', 'string', optional=False)) course_opts.add_property( SchemaField('weight', 'Weight', 'number', optional=False)) course_opts.add_property( SchemaField(content_key('question'), 'Problem Statement', 'html', optional=False, description=( 'Problem Statement and description of program, visible' ' to student.'), extra_schema_dict_values={ 'supportCustomTags': tags.CAN_USE_DYNAMIC_TAGS.value, 'className': 'inputEx-Field content' })) course_opts.add_property( SchemaField('html_check_answers', 'Allow "Compile & Run"', 'boolean', optional=True, extra_schema_dict_values={ 'className': 'inputEx-Field assessment-editor-check-answers' })) course_opts.add_property( SchemaField( content_key('evaluator'), 'Program Evaluator', 'string', optional=True, select_data=[ (eid, eid) for eid in evaluator.ProgramEvaluatorRegistory.list_ids() ])) course_opts.add_property( SchemaField(content_key('ignore_presentation_errors'), 'Ignore Presentation Errors', 'boolean', optional=True, extra_schema_dict_values={ 'className': 'inputEx-Field assessment-editor-check-answers' })) course_opts.add_property( SchemaField(workflow_key(courses.SUBMISSION_DUE_DATE_KEY), 'Submission Due Date', 'string', optional=True, description=str(messages.DUE_DATE_FORMAT_DESCRIPTION))) course_opts.add_property( SchemaField(content_key('show_sample_solution'), 'Show sample solution after deadline', 'boolean', optional=True, extra_schema_dict_values={ 'className': 'inputEx-Field assessment-editor-check-answers' })) test_case_opts = FieldRegistry('', '') test_case_opts.add_property( SchemaField('input', 'Input', 'text', optional=True, extra_schema_dict_values={})) test_case_opts.add_property( SchemaField( 'output', 'Output', 'text', optional=True, extra_schema_dict_values={'className': 'inputEx-Field content'})) test_case_opts.add_property( SchemaField('weight', 'Weight', 'number', optional=False, extra_schema_dict_values={ 'className': 'inputEx-Field content', 'value': 1 })) public_test_cases = FieldArray(content_key('public_testcase'), '', item_type=test_case_opts, extra_schema_dict_values={ 'sortable': False, 'listAddLabel': 'Add Public Test Case', 'listRemoveLabel': 'Delete' }) public_tests_reg = course_opts.add_sub_registry('public_testcase', title='Public Test Cases') public_tests_reg.add_property(public_test_cases) private_test_cases = FieldArray(content_key('private_testcase'), '', item_type=test_case_opts, extra_schema_dict_values={ 'sortable': False, 'listAddLabel': 'Add Private Test Case', 'listRemoveLabel': 'Delete' }) private_tests_reg = course_opts.add_sub_registry( 'private_testcase', title='Private Test Cases') private_tests_reg.add_property(private_test_cases) lang_reg = course_opts.add_sub_registry( 'allowed_languages', title='Allowed Programming Languages') language_opts = FieldRegistry('', '') language_opts.add_property( SchemaField( 'language', 'Programming Language', 'string', select_data=base.ProgAssignment.PROG_LANG_FILE_MAP.items())) language_opts.add_property( SchemaField( 'prefixed_code', 'Prefixed Fixed Code', 'text', optional=True, description=('The uneditable code for the assignment. ' 'This will be prepended at the start of user code'), extra_schema_dict_values={'className': 'inputEx-Field content'})) language_opts.add_property( SchemaField( 'code_template', 'Template Code', 'text', optional=True, description=('The default code that is populated on opening ' + 'an assignment.'), extra_schema_dict_values={'className': 'inputEx-Field content'})) language_opts.add_property( SchemaField( 'uneditable_code', 'Suffixed Fixed Code', 'text', optional=True, description=('The uneditable code for the assignment. ' 'This will be appended at the end of user code'), extra_schema_dict_values={'className': 'inputEx-Field content'})) language_opts.add_property( SchemaField( 'suffixed_invisible_code', 'Invisible Code', 'text', optional=True, description=( 'This code will not be visible to the student and will be' ' appended at the very end.'), extra_schema_dict_values={'className': 'inputEx-Field content'})) language_opts.add_property( SchemaField('sample_solution', 'Sample Solution', 'text', optional=True, extra_schema_dict_values={'className': 'inputEx-Field'})) language_opts.add_property( SchemaField('filename', 'Sample Solution Filename', 'string', optional=True, extra_schema_dict_values={'className': 'inputEx-Field'})) allowed_languages = FieldArray(content_key('allowed_languages'), '', item_type=language_opts, extra_schema_dict_values={ 'sortable': False, 'listAddLabel': 'Add Language', 'listRemoveLabel': 'Delete', 'minItems': 1 }) lang_reg.add_property(allowed_languages) course_opts.add_property( SchemaField( 'is_draft', 'Status', 'boolean', select_data=[(True, DRAFT_TEXT), (False, PUBLISHED_TEXT)], extra_schema_dict_values={'className': 'split-from-main-group'})) return reg