def create_email_settings_registry(): """Create the registry for course properties.""" reg = FieldRegistry('Email Settings', description='Email Settings', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout' }) reg.add_property(SchemaField('unique_name', 'Unique Name', 'string')) select_data = [('APP_ENGINE_EMAIL', 'App Engine Email'), ('SEND_GRID', 'Send Grid')] reg.add_property( SchemaField('provider', 'Provider', 'string', optional=False, select_data=select_data, extra_schema_dict_values={ 'className': 'inputEx-Field assessment-dropdown' })) reg.add_property(SchemaField('from_email', 'From Email', 'string')) reg.add_property(SchemaField('api_key', 'API Key', 'string', optional=True)) return reg
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
class CourseExplorerSettings(object): blurb = SchemaField( course_explorer_key('blurb'), 'Course Abstract', 'html', optional=True, description='Text, shown on the course homepage, that explains what ' 'the course is about.', extra_schema_dict_values={ 'supportCustomTags': tags.CAN_USE_DYNAMIC_TAGS.value, 'excludedCustomTags': tags.EditorDenylists.COURSE_SCOPE}) list_in_explorer = SchemaField( course_explorer_key('list_in_explorer'), 'List the course in explorer', 'boolean') registration = SchemaField( 'reg_form:registration', 'Student Registration', 'string', optional=True, select_data=[ ('NOT_OPEN', 'Not Open'), ('OPENING_SHORTLY', 'Opening Shortly'), ('OPEN', 'Open'), ('CLOSED', 'Closed')], description='Set registration status for students.') closed = SchemaField( course_explorer_key('closed'), 'Course Closed', 'boolean', optional=True, description='Is course not currently running.') @classmethod def get_fields(cls): course_explorer_fields = set() course_explorer_fields.add(lambda c: cls.blurb) course_explorer_fields.add(lambda c: cls.list_in_explorer) course_explorer_fields.add(lambda c: cls.closed) return course_explorer_fields @classmethod def register(cls): courses.DEFAULT_COURSE_YAML_DICT[EXPLORER_SECTION] = dict() courses.DEFAULT_COURSE_YAML_DICT[EXPLORER_SECTION]['list_in_explorer'] = True courses.DEFAULT_COURSE_YAML_DICT[EXPLORER_SECTION]['blurb'] = '' courses.Course.OPTIONS_SCHEMA_PROVIDERS[ EXPLORER_SECTION] += cls.get_fields() courses.Course.OPTIONS_SCHEMA_PROVIDERS[ courses.Course.SCHEMA_SECTION_REGISTRATION] += [lambda c : cls.registration] tabs.Registry.register('settings', 'course_explorer', 'Explorer', EXPLORER_SECTION) @classmethod def unregister(cls): for field in cls.get_fields(): courses.Course.OPTIONS_SCHEMA_PROVIDERS[ EXPLORER_SECTION].remove(field) courses.Course.OPTIONS_SCHEMA_PROVIDERS[ courses.Course.SCHEMA_SECTION_REGISTRATION].remove( lambda c : cls.registration)
def create_course_featured_registry(): """Create the registry for course properties.""" reg = FieldRegistry( 'Course Featured', description='Course Featured', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout'}) # Course level settings. reg.add_property(SchemaField('id', 'Course id', 'string', editable=False)) reg.add_property(SchemaField('title', 'Title', 'string', editable=False)) reg.add_property(SchemaField('featured', 'Featured', 'boolean', optional=True)) return reg
class CourseThemeSettings(object): theme_opts = FieldRegistry('THEME', '') theme_opts_background_color = SchemaField( course_theme_key('background_color'), 'Header Background Color', 'string', optional=True, description='Color of the header background on the course homepage. Default is a90909') theme_opts_logo_url=SchemaField( course_theme_key('logo_url'), 'Header logo url', 'string', optional=True, description='URL of the logo in course page') theme_opts_logo_alt_text=SchemaField( course_theme_key('logo_alt_text'), 'Header logo alternate text', 'string', optional=True, description='Header logo alternate text') @classmethod def get_fields(cls): theme_fields = set() theme_fields.add(lambda c: cls.theme_opts_logo_alt_text) theme_fields.add(lambda c: cls.theme_opts_background_color) theme_fields.add(lambda c: cls.theme_opts_logo_url) return theme_fields @classmethod def register(cls): courses.DEFAULT_COURSE_YAML_DICT[THEME_SECTION] = dict() courses.DEFAULT_COURSE_YAML_DICT[THEME_SECTION]['background_color'] = 'a90909' courses.DEFAULT_COURSE_YAML_DICT[THEME_SECTION]['logo_url'] = '' courses.DEFAULT_COURSE_YAML_DICT[THEME_SECTION]['logo_alt_text'] = '' courses.DEFAULT_EXISTING_COURSE_YAML_DICT[THEME_SECTION] = { 'background_color': 'a90909' } courses.DEFAULT_EXISTING_COURSE_YAML_DICT[THEME_SECTION] = { 'logo_url': '' } courses.DEFAULT_EXISTING_COURSE_YAML_DICT[THEME_SECTION] = { 'logo_alt_text': '' } courses.Course.OPTIONS_SCHEMA_PROVIDERS[ THEME_SECTION] += cls.get_fields() tabs.Registry.register('settings', 'course_theme', 'Theme', THEME_SECTION) @classmethod def unregister(cls): for field in cls.get_fields(): courses.Course.OPTIONS_SCHEMA_PROVIDERS[ THEME_SECTION].remove(field)
def create_category_list_registry(): """Create the registry for course properties.""" reg = FieldRegistry( 'Course Category', description='Categories in which courses are divided.', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout'}) reg.add_property(SchemaField( 'category', 'Category', 'string')) reg.add_property(SchemaField( 'description', 'Visible Name', 'string')) reg.add_property(SchemaField( 'visible', 'Visible', 'boolean')) return reg
def create_local_chapter_list_registry(): """Create the registry for course properties.""" reg = FieldRegistry('Local Chapter', description='Local Chapters', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout' }) reg.add_property(SchemaField('code', 'Local Chapter Code', 'string')) reg.add_property(SchemaField('name', 'Local Chapter Name', 'string')) reg.add_property(SchemaField('city', 'City', 'string')) select_data = [('ANDAMAN AND NICOBAR ISLANDS', 'Andaman_and_Nicobar_Islands'), ('ANDHRA PRADESH', 'Andhra Pradesh'), ('ARUNACHAL PRADESH', 'Arunachal Pradesh'), ('ASSAM', 'Assam'), ('BIHAR', 'Bihar'), ('CHANDIGARH', 'Chandigarh'), ('CHHATTISGARH', 'Chhattisgarh'), ('DADRA AND NAGAR HAVELI', 'Dadra and Nagar Haveli'), ('DELHI', 'Delhi'), ('GOA', 'Goa'), ('GUJARAT', 'Gujarat'), ('HARYANA', 'Haryana'), ('HIMACHAL PRADESH', 'Himachal Pradesh'), ('JAMMU AND KASHMIR', 'Jammu and Kashmir'), ('JHARKHAND', 'Jharkhand'), ('KARNATAKA', 'Karnataka'), ('KERALA', 'Kerala'), ('LAKSHADWEEP', 'Lakshadweep'), ('MADHYA PRADESH', 'Madhya Pradesh'), ('MAHARASHTRA', 'Maharashtra'), ('MANIPUR', 'Manipur'), ('MEGHALAYA', 'Meghalaya'), ('MIZORAM', 'Mizoram'), ('NAGALAND', 'Nagaland'), ('ODISHA', 'Odisha'), ('PONDICHERRY', 'Pondicherry'), ('PUNJAB', 'Punjab'), ('RAJASTHAN', 'Rajasthan'), ('SIKKIM', 'Sikkim'), ('TAMIL NADU', 'Tamil Nadu'), ('TELANGANA', 'Telangana'), ('TRIPURA', 'Tripura'), ('UTTARAKHAND', 'Uttarakhand'), ('UTTAR PRADESH', 'Uttar Pradesh'), ('WEST BENGAL', 'West Bengal')] reg.add_property( SchemaField('state', 'State', 'string', optional=False, select_data=select_data, extra_schema_dict_values={ 'className': 'inputEx-Field assessment-dropdown' })) return reg
class NptelSettings(object): dump_folder = SchemaField( nptel_key(DUMP_FOLDER_ID), 'Google Drive Folder Id For Dumps', 'string', optional=True, description="""Id of Google Drive folder where all course dumps will be stored.""", validator=dump_folder_validator) @classmethod def get_fields(cls): nptel_fields = set() nptel_fields.add(lambda c: cls.dump_folder) return nptel_fields @classmethod def register(cls): courses.Course.OPTIONS_SCHEMA_PROVIDERS[ NPTEL_SECTION] += cls.get_fields() tabs.Registry.register('settings', 'nptel', 'NPTEL', NPTEL_SECTION) @classmethod def unregister(cls): for field in cls.get_fields(): courses.Course.OPTIONS_SCHEMA_PROVIDERS[NPTEL_SECTION].remove( field) courses.Course.OPTIONS_SCHEMA_PROVIDERS[ NPTEL_THEME_SECTION].remove(field)
class MentorSettings(base.MentorBase): enable_mentor_support = SchemaField(mentor_key(base.MentorBase.ENABLE_KEY), 'Enable Mentor Support', 'boolean') @classmethod def get_fields(cls): mentor_fields = set() mentor_fields.add(lambda c: cls.enable_mentor_support) return mentor_fields @classmethod def register(cls): courses.DEFAULT_COURSE_YAML_DICT[cls.MENTOR_SECTION] = dict() courses.DEFAULT_COURSE_YAML_DICT[ cls.MENTOR_SECTION]['enable_mentor_support'] = False courses.DEFAULT_EXISTING_COURSE_YAML_DICT[cls.MENTOR_SECTION] = { 'enable_mentor_support': False } courses.Course.OPTIONS_SCHEMA_PROVIDERS[ cls.MENTOR_SECTION] += cls.get_fields() tabs.Registry.register('settings', 'mentor', 'Mentor', cls.MENTOR_SECTION) @classmethod def unregister(cls): for field in cls.get_fields(): courses.Course.OPTIONS_SCHEMA_PROVIDERS[cls.MENTOR_SECTION].remove( field)
def create_course_category_registry(): """Create the registry for course properties.""" reg = FieldRegistry( 'Course Category', description='Course Category', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout'}) # Course level settings. reg.add_property(SchemaField( 'id', 'Course id', 'string', editable=False)) reg.add_property(SchemaField('title', 'Title', 'string', editable=False)) reg.add_property(SchemaField( 'category', 'Category', 'string', optional=True, extra_schema_dict_values={}, select_data=[('', '--')])) return reg
def create_assignment_registry(): """Create the registry for course properties.""" reg = FieldRegistry( base.OfflineAssignmentBase.NAME, description=base.OfflineAssignmentBase.DESCRIPTION) # Course level settings. reg.add_property(SchemaField( 'key', 'ID', 'string', editable=False, extra_schema_dict_values={'className': 'inputEx-Field keyHolder'})) reg.add_property( SchemaField('type', 'Type', 'string', editable=False)) reg.add_property( SchemaField('title', 'Title', 'string', optional=False)) reg.add_property( SchemaField('weight', 'Weight', 'number', optional=False)) reg.add_property(SchemaField('parent_unit', 'Parent Unit', 'string', select_data=[])) reg.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'})) reg.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
def create_bulk_local_chapter_list_registry(): """Create the registry for course properties.""" reg = FieldRegistry('Local Chapter', description='Bulk Local Chapters', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout' }) reg.add_property( SchemaField('bulk_addition', 'Bulk Local Chapters (code,name,city,state)', 'text')) 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
def create_queue_settings_registry(): """Create the registry for course properties.""" reg = FieldRegistry('Queue Settings', description='Queue Settings', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout' }) select_data = [ (models.WELCOME_NOTIFICATION_INTENT, 'WELCOME_NOTIFICATION_INTENT'), (invitation.INVITATION_INTENT, 'INVITATION_INTENT'), (announcements.ANNOUNCEMENTS_INTENT, 'ANNOUNCEMENTS_INTENT'), (student_questions.FORUM_QUESTION_INTENT, 'FORUM_QUESTION_INTENT') ] reg.add_property( SchemaField('queue_id', 'Queue ID', 'string', optional=False, select_data=select_data, extra_schema_dict_values={ 'className': 'inputEx-Field assessment-dropdown' })) reg.add_property( SchemaField('email_settings', 'Email Settings', 'string', optional=False, select_data=[], extra_schema_dict_values={ 'className': 'inputEx-Field assessment-dropdown' })) return reg
def create_bulk_offline_assignments_list_registry(): """Create the registry for course properties.""" reg = FieldRegistry( base.OfflineAssignmentBase.ADMIN_DESCRIPTION, description=base.OfflineAssignmentBase.ADMIN_DESCRIPTION, extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout' }) reg.add_property( SchemaField( 'csv_text', 'Bulk Scores (course_namespace, student_id, assignment_id, score)', 'text')) return reg
def register_module(): """Registers this module in the registry.""" evaluator.ProgramEvaluatorRegistory.register_evaluator( 'mooshak', MooshakEvaluator) mooshak_server = SchemaField( settings.programming_assignment_key(MOOSHAK_SERVER), 'URL/IP of mooshak server', 'string', '', optional=True) mooshak_settings_fields = set() mooshak_settings_fields.add(lambda c: mooshak_server) courses.Course.OPTIONS_SCHEMA_PROVIDERS[ base.ProgAssignment.SETTINGS_SECTION] += mooshak_settings_fields global custom_module # pylint: disable=global-statement custom_module = custom_modules.Module( 'Programming Assignment Mooshak Evaluator', 'A set pages to manage programming assignments.', [], []) return custom_module
def create_service_account_registry(cls): """Create the registry for course properties.""" reg = FieldRegistry('Google Service Account', description='Google Service Accounts', extra_schema_dict_values={ 'className': 'inputEx-Group new-form-layout' }) reg.add_property(SchemaField('id', 'ID', 'string', editable=False)) credential_type_tuple_list = ( service_account_models.GoogleServiceAccountTypes.to_dict( ).iteritems()) select_data = [] for a, b in credential_type_tuple_list: select_data.append((b, a)) # Making select_data read only for now since it will get auto populated # depending on which one of the three links to add/edit the user # clicks on. This will avoid overriding wrong data by mistake. reg.add_property( SchemaField('credential_type', 'Credential Type', 'string', select_data=select_data, editable=False)) reg.add_property( SchemaField('client_email', 'Client Email', 'string', description='Email ID ' 'of the account with which to use this credential')) reg.add_property( SchemaField('sub_user_email', 'Sub User Email', 'string', optional=True, description='Optional for service account')) reg.add_property( SchemaField('scope', 'Scopes', 'list', description='List of scopes you want ' 'to use with this credential')) reg.add_property( SchemaField('client_id', 'Client ID', 'string', optional=True, description='Required for Oauth2 Client ID')) reg.add_property( SchemaField('api_key', 'API Key', 'string', optional=True, description='Required for type API KEY, optional for ' 'service account')) reg.add_property( SchemaField('project_id', 'Project ID', 'string', optional=True, description='Optional for service account')) reg.add_property( SchemaField('project_key_id', 'Project ID Key', 'string', optional=True, description='Optional for service account')) reg.add_property( SchemaField('private_key', 'Private Key', 'text', optional=True, description='Required for service account')) reg.add_property( SchemaField('auth_uri', 'auth_uri', 'string', optional=True, description='Optional for service account')) reg.add_property( SchemaField('token_uri', 'token_uri', 'string', optional=True, description='Optional for service account')) reg.add_property( SchemaField('auth_provider_x509_cert_url', 'auth_provider_x509_cert_url', 'string', optional=True, description='Optional for service account')) reg.add_property( SchemaField('client_x509_cert_url', 'client_x509_cert_url', 'string', optional=True, description='Optional for service account')) return reg
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
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)