def generate_fields(cls): """ A class decorator that generates fields for all field scopes. These fields are Dicts, and map usage_ids to values. """ for scope in Scope.scopes(): setattr(cls, scope.name, Dict( help="Values stored in the {} scope".format(scope), scope=scope )) return cls
def generate_fields(cls): """ A class decorator that generates fields for all field scopes. These fields are Dicts, and map usage_ids to values. """ for scope in Scope.scopes(): setattr( cls, scope.name, Dict(help="Values stored in the {} scope".format(scope), scope=scope)) return cls
def fallback_view(self, view_name, context=None): # pylint: disable=W0613 """ This view is used by the Acid XBlock to test various features of the runtime it is contained in """ block_template = self.resource_string("static/html/acid.html") storage_test_template = self.resource_string('static/html/scope_storage_test.html') scopes = ( scope for scope in Scope.scopes() if (view_name not in self.enabled_fields or scope.name in self.enabled_fields[view_name]) ) scope_test_contexts = [] for scope in scopes: try: scope_test_contexts.append(self.setup_storage(scope.name)) except Exception as exc: logging.warning('Unable to use scope in acid test', exc_info=True) frag = Fragment(block_template.format( error_class=self.ERROR_CLASS, success_class=self.SUCCESS_CLASS, failure_class=self.FAILURE_CLASS, unknown_class=self.UNKNOWN_CLASS, storage_tests='\n'.join( storage_test_template.format( alt="alt" if idx % 2 else "", unknown_class=self.UNKNOWN_CLASS, **context ) for idx, context in enumerate(scope_test_contexts) ), )) frag.add_javascript(self.resource_string("static/js/jquery.ajaxq-0.0.1.js")) frag.add_javascript(self.resource_string('static/js/acid.js')) frag.add_css(self.resource_string("static/css/acid.css")) frag.add_css_url('//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css') frag.initialize_js('AcidBlock') return frag
def aside_view(self, block, context=None): """ This view is used by the Acid Aside to test various features of the runtime it is contained in """ scopes = (scope for scope in Scope.scopes() if scope.name in self.enabled_fields['student_view']) scope_test_contexts = [] for scope in scopes: try: scope_test_contexts.append(self.setup_storage(scope.name)) except Exception: logging.warning('Unable to use scope in acid test', exc_info=True) frag = Fragment( self.render_template( 'html/aside.html.mako', usage_id=block.scope_ids.usage_id, error_class=self.ERROR_CLASS, success_class=self.SUCCESS_CLASS, failure_class=self.FAILURE_CLASS, unknown_class=self.UNKNOWN_CLASS, storage_tests=scope_test_contexts, local_resource_url=self.runtime.local_resource_url( self, 'public/test_data.json'), )) frag.add_javascript( self.resource_string("static/js/jquery.ajaxq-0.0.1.js")) frag.add_javascript( self.resource_string('static/js/acid_update_status.js')) frag.add_javascript(self.resource_string('static/js/acid.js')) frag.add_css(self.resource_string("static/css/acid.css")) frag.add_css_url( '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' ) frag.initialize_js('AcidAsideBlock', {'test_aside': isinstance(block, AcidBlock)}) return frag
def aside_view(self, block, context=None): """ This view is used by the Acid Aside to test various features of the runtime it is contained in """ scopes = ( scope for scope in Scope.scopes() if scope.name in self.enabled_fields['student_view'] ) scope_test_contexts = [] for scope in scopes: try: scope_test_contexts.append(self.setup_storage(scope.name)) except Exception: logging.warning('Unable to use scope in acid test', exc_info=True) frag = Fragment(self.render_template( 'html/aside.html.mako', usage_id=block.scope_ids.usage_id, error_class=self.ERROR_CLASS, success_class=self.SUCCESS_CLASS, failure_class=self.FAILURE_CLASS, unknown_class=self.UNKNOWN_CLASS, storage_tests=scope_test_contexts, local_resource_url=self.runtime.local_resource_url(self, 'public/test_data.json'), )) frag.add_javascript(self.resource_string("static/js/jquery.ajaxq-0.0.1.js")) frag.add_javascript(self.resource_string('static/js/acid_update_status.js')) frag.add_javascript(self.resource_string('static/js/acid.js')) frag.add_css(self.resource_string("static/css/acid.css")) frag.add_css_url('//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css') frag.initialize_js('AcidAsideBlock', {'test_aside': isinstance(block, AcidBlock)}) return frag