query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Returns the database query to find the given asset location.
def asset_db_key(location): return location.to_deprecated_son(tag=XASSET_LOCATION_TAG, prefix='_id.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attrs(self, location):\r\n asset_db_key = self.asset_db_key(location)\r\n item = self.fs_files.find_one(asset_db_key)\r\n if item is None:\r\n raise NotFoundError(asset_db_key)\r\n return item", "def get_asset(location, filename):\r\n return contentstore().fi...
[ "0.5652785", "0.5511313", "0.5455425", "0.5360465", "0.5324643", "0.5256943", "0.5235382", "0.5230763", "0.5214064", "0.51997906", "0.5188913", "0.5163305", "0.5133617", "0.5131037", "0.5077882", "0.50372463", "0.5022103", "0.5016169", "0.5013831", "0.49542478", "0.49523282",...
0.46965352
48
The JSON object can have the keys GRADER and GRADE_CUTOFFS. If either is missing, it reverts to the default.
def set_grading_policy(self, course_policy): if course_policy is None: course_policy = {} # Load the global settings as a dictionary grading_policy = self.grading_policy # BOY DO I HATE THIS grading_policy CODE ACROBATICS YET HERE I ADD MORE (dhm)--this fixes things pe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten_json_data(beer_json):\n if 'available' in beer_json:\n if 'name' in beer_json['available']:\n beer_json['available_name'] = beer_json['available']['name']\n del beer_json['available']\n if 'glass' in beer_json:\n if 'name' in beer_json['glass']:\n beer_j...
[ "0.57342833", "0.527421", "0.5253611", "0.51271605", "0.49843758", "0.49404567", "0.49253455", "0.48989308", "0.48327962", "0.48006636", "0.47974375", "0.47807437", "0.47618684", "0.47528195", "0.47517538", "0.47423542", "0.47395542", "0.47294793", "0.47274524", "0.46848315", ...
0.0
-1
Returns True if the current time is after the specified course end date. Returns False if there is no end date specified.
def has_ended(self): if self.end is None: return False return datetime.now(UTC()) > self.end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_after(self, dt: datetime) -> bool:\n return self.target_time >= make_tz_aware(dt)", "def verify_end_date(self, course_id, expected_end_text=None):\r\n request = self.request_factory.get(\"foo\")\r\n request.user = self.user\r\n\r\n # TODO: Remove the dependency on MakoMiddlewar...
[ "0.67607945", "0.6660763", "0.6508607", "0.6384293", "0.6239729", "0.6085512", "0.60788363", "0.60313255", "0.5977848", "0.59406424", "0.59334904", "0.5901181", "0.5888965", "0.58883065", "0.5866658", "0.5841183", "0.5834581", "0.58182824", "0.5805732", "0.57896936", "0.57803...
0.6599205
2
Returns if the course has been flagged as new. If there is no flag, return a heuristic value considering the announcement and the start dates.
def is_newish(self): flag = self.is_new if flag is None: # Use a heuristic if the course has not been flagged announcement, start, now = self._sorting_dates() if announcement and (now - announcement).days < 30: # The course has been announced for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latest_flag(self) -> bool:\n if CoronaCaseRaw.objects.all().count() == 0:\n return True\n return CoronaCaseRaw.objects.latest('date_received').update_flag", "def today(self) -> bool:\n return self._algorithm.can_study_now(self._stat)", "def is_new_contact(self):\n ret...
[ "0.5639769", "0.54335535", "0.5382395", "0.5343272", "0.51759464", "0.51518166", "0.5146502", "0.5126739", "0.51061237", "0.5091997", "0.50710094", "0.4951645", "0.49487716", "0.49402007", "0.49307576", "0.49058756", "0.4877854", "0.4873938", "0.48576993", "0.48526734", "0.48...
0.7489471
0
Checks if the start date set for the course is still default, i.e. .start has not been modified, and .advertised_start has not been set.
def start_date_is_still_default(self): return self.advertised_start is None and self.start == CourseFields.start.default
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_none_start(self):\n self.assertEquals(self.event.start, None)\n self.event.all_day = True\n self.assertEquals(self.event.start, None)", "def _check_start_timestamp(self):\n if self.descriptor.type in (\n metric_descriptor.MetricDescriptorType.CUMULATIVE_INT64,\...
[ "0.6731386", "0.6677384", "0.6413971", "0.62301046", "0.6212698", "0.6150108", "0.6035324", "0.6015327", "0.5908797", "0.5793581", "0.5769606", "0.5768054", "0.5748641", "0.57441956", "0.57087326", "0.56994694", "0.56853116", "0.56697047", "0.5630526", "0.5619133", "0.5609948...
0.86839414
0
Returns the end date for the course formatted as a string. If the course does not have an end date set (course.end is None), an empty string will be returned.
def end_date_text(self): if self.end is None: return '' else: strftime = self.runtime.service(self, "i18n").strftime return strftime(self.end, "SHORT_DATE")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end_date(self) -> str:\n return self._end_date", "def end_date(self) -> str:\n return pulumi.get(self, \"end_date\")", "def end_date(self) -> str:\n return pulumi.get(self, \"end_date\")", "def enddate_display(self):\n if self.enddate:\n return self.enddate.strftime...
[ "0.7523559", "0.7513702", "0.7513702", "0.74961925", "0.7398378", "0.7398378", "0.70343894", "0.70343894", "0.70343894", "0.6975979", "0.6766016", "0.67515767", "0.66754806", "0.65607464", "0.65388036", "0.65218675", "0.6437243", "0.64228517", "0.6333024", "0.6333024", "0.632...
0.75994354
0
Return a display organization if it has been specified, otherwise return the 'org' that is in the location
def display_org_with_default(self): if self.display_organization: return self.display_organization return self.org
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_organization(self):\n pos_or_org = self.position.to_object\n if pos_or_org is None:\n return None\n elif pos_or_org.portal_type == 'position':\n return pos_or_org.get_organization()\n elif pos_or_org.portal_type == 'organization':\n return pos_or...
[ "0.74695474", "0.70707303", "0.7053702", "0.6827814", "0.6783866", "0.6474201", "0.64571905", "0.64016706", "0.6374657", "0.63554865", "0.6286062", "0.6286062", "0.62798345", "0.6272442", "0.6248169", "0.6248169", "0.6216031", "0.621005", "0.6182634", "0.6181735", "0.6167851"...
0.7993151
0
Converts capa numerical answer format to a string representation of the answer. Loncapa dependent. Assumes that the problem only has one part.
def numerical_answer_to_str(self, answer): return str(answer.values()[0])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formula_answer_to_str(self, answer):\r\n return str(answer.values()[0])", "def format_answer(answer):\n # a regular expression matching the predicted outcome\n # by timbl.\n pattern = re.compile(r'CATEGORY \\{([^}]+)\\}')\n answer = pattern.search(answer)\n return answer and answer.grou...
[ "0.6648168", "0.6186033", "0.58328104", "0.5831725", "0.5776737", "0.5728774", "0.5678935", "0.559391", "0.5552964", "0.5551606", "0.553241", "0.5524226", "0.5504572", "0.5468956", "0.54607266", "0.54579735", "0.5448434", "0.54476464", "0.54270756", "0.54212713", "0.5402274",...
0.7227054
0
Convert a time struct to a string
def to_json(self, value): if value is None: return None if isinstance(value, time.struct_time): # struct_times are always utc return time.strftime('%Y-%m-%dT%H:%M:%SZ', value) elif isinstance(value, datetime.datetime): if value.tzinfo is Non...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datetime_to_str(time):\n return '{hour}:{min}:{second}:{millisecond}'.format(\n hour=time.hour,\n min=time.minute, \n second=time.second,\n millisecond=str(int(round(time.microsecond / 1000.0))),\n )", "def time_to_str(obj):\n if not obj:\n return False\n re...
[ "0.77680427", "0.762379", "0.76063067", "0.75496", "0.7522265", "0.7501699", "0.7443586", "0.74263066", "0.7275576", "0.7251571", "0.7238477", "0.71851826", "0.7089223", "0.7089223", "0.7075622", "0.7052778", "0.70288104", "0.70210063", "0.70210063", "0.6953103", "0.69333386"...
0.0
-1
This method will return the appropriate default store mapping for the current Django request, else 'default' which is the system default
def get_default_store_name_for_current_request(): store_name = 'default' # see what request we are currently processing - if any at all - and get hostname for the request hostname = get_current_request_hostname() # get mapping information which is defined in configurations mappings = getatt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mixed_stores(mixed_setting):\n return mixed_setting[\"default\"][\"OPTIONS\"][\"stores\"]", "def _store(request):\n return _config(request)['store_factory'](request)", "def get_store(self, store_name: str) -> Any:\n pass", "def test_get_modulestore_type(self, default_ms):\r\n self...
[ "0.6276891", "0.6251207", "0.6135652", "0.61205834", "0.601869", "0.6011108", "0.5964686", "0.59291106", "0.58340496", "0.581568", "0.57886", "0.5775034", "0.5761274", "0.57419735", "0.5727711", "0.57265663", "0.5684543", "0.5654816", "0.5607001", "0.5536909", "0.55281293", ...
0.7683841
0
Retrieve a modulestore that we can modify. This is useful for tests that need to insert test data into the modulestore. Currently, only Mongobacked modulestores can be modified. Returns `None` if no editable modulestore is available.
def editable_modulestore(name='default'): # Try to retrieve the ModuleStore # Depending on the settings, this may or may not # be editable. store = modulestore(name) # If this is a `MixedModuleStore`, then we will need # to retrieve the actual Mongo instance. # We assume that the ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_modulestore(ms_type, key):\r\n try:\r\n store = modulestore(key)\r\n if isinstance(store, MixedModuleStore):\r\n store = store.modulestores[key]\r\n if store.get_modulestore_type(None) == ms_type:\r\n return store...
[ "0.72399956", "0.72340655", "0.7020093", "0.7009532", "0.6868856", "0.6632174", "0.6568829", "0.6421057", "0.6302858", "0.61311907", "0.6094468", "0.5937874", "0.57503796", "0.5747805", "0.57161206", "0.5688276", "0.5687673", "0.56852204", "0.56828547", "0.553555", "0.5513571...
0.8318627
0
Create an InheritanceFieldData that inherits the names in InheritanceMixin.
def inheriting_field_data(kvs): return InheritingFieldData( inheritable_names=InheritanceMixin.fields.keys(), kvs=kvs, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, inheritable_names, **kwargs):\r\n super(InheritingFieldData, self).__init__(**kwargs)\r\n self.inheritable_names = set(inheritable_names)", "def add_inheritable_field(self, fields):\n if type(fields) is str:\n fields = set(fields)\n self.simple_ray_inheri...
[ "0.78165466", "0.58962965", "0.5658826", "0.5635996", "0.55522555", "0.54909414", "0.54579157", "0.5454516", "0.5402143", "0.5321289", "0.53185254", "0.5290968", "0.52798265", "0.5275111", "0.5264213", "0.5252944", "0.5252944", "0.5247061", "0.52205044", "0.52161676", "0.5201...
0.79579383
0
The organization that this course belongs to.
def org(self): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def organization(self):\n return self._tower.get_organization_by_id(self._data.get('organization'))", "def course_org(self):\n return self.course_key.org", "def get_organization(self):\n return self.reference[REF_ORGANIZATION][REF_VALUE]", "def organization(self) -> Optional[pulumi.Input...
[ "0.8521223", "0.84891623", "0.84483767", "0.8009036", "0.78114146", "0.7773846", "0.7745689", "0.76899457", "0.76899457", "0.76899457", "0.76617867", "0.7653498", "0.7600683", "0.7537766", "0.74463785", "0.7364198", "0.73485404", "0.7243176", "0.7213195", "0.71875197", "0.718...
0.0
-1
Return the path for this asset.
def path(self): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_path(self):\n raise NotImplementedError(\"This asset does not support absolute paths\")", "def assets_path(self) -> str:\n return self._assets_path", "def get_path(self):\n return StaticAsset.get_static_path(self._name)", "def path(self):\n return self.file_path()", "def...
[ "0.87223566", "0.8286424", "0.8067571", "0.7907655", "0.7870393", "0.7750036", "0.7750036", "0.77138096", "0.77138096", "0.77138096", "0.77138096", "0.76863474", "0.7668038", "0.7664641", "0.7625266", "0.7615557", "0.76039106", "0.7597966", "0.7590397", "0.7590397", "0.759039...
0.6651983
99
invalid should be a compiled regexp of chars to replace with '_'
def _clean(cls, value, invalid): return re.sub('_+', '_', invalid.sub('_', value))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(value):\r\n return re.sub('_+', '_', INVALID_CHARS.sub('_', value))", "def clean_keeping_underscores(cls, value):\r\n return INVALID_CHARS.sub('_', value)", "def Clean(s):\n for c in BAD_CHARACTERS:\n s = s.replace(c, '_')\n return s", "def sanitize(mystr):\n retainlist = ...
[ "0.7402018", "0.671584", "0.6527408", "0.640729", "0.61885387", "0.6187685", "0.61818516", "0.61610377", "0.6094333", "0.6072379", "0.6065664", "0.60413474", "0.6021995", "0.5994089", "0.59903145", "0.59842455", "0.5958002", "0.5896804", "0.5885662", "0.5877805", "0.58507574"...
0.77644265
0
Return value, replacing INVALID_CHARS, but not collapsing multiple '_' chars. This for cleaning asset names, as the YouTube ID's may have underscores in them, and we need the transcript asset name to match. In the future we may want to change the behavior of _clean.
def clean_keeping_underscores(cls, value): return INVALID_CHARS.sub('_', value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(value):\r\n return re.sub('_+', '_', INVALID_CHARS.sub('_', value))", "def _clean(cls, value, invalid):\r\n return re.sub('_+', '_', invalid.sub('_', value))", "def sanitize_name(self, value):\n if self.sanitize_names:\n new_value = re.sub('[^a-zA-Z0-9_]', '_', value[:127]...
[ "0.7799888", "0.77742094", "0.7500471", "0.6899067", "0.68390024", "0.68037474", "0.67979693", "0.6768203", "0.6763724", "0.66477895", "0.6597783", "0.65479594", "0.6507222", "0.65055853", "0.6480736", "0.6455904", "0.63612306", "0.63569266", "0.6348076", "0.63297117", "0.630...
0.7623774
2
Returns the ObjectId referencing this specific location.
def version(self): return self.version_guid
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def identifier(self):\n return location_id(self.__dict__)", "def objectId( self ):\n return self._objectId", "def getLastObjectId(self):\n return self.objId", "def obj_id(self) -> int:\n return int(self.index.split(\"/\")[-1]) if self.index else None", "def get_objectID(self):\n...
[ "0.7754908", "0.71126366", "0.69354415", "0.67558396", "0.6680665", "0.66456324", "0.6594632", "0.6594632", "0.6578678", "0.6572679", "0.6572679", "0.6572679", "0.6572679", "0.6572679", "0.6572679", "0.65300655", "0.65300655", "0.65300655", "0.65300655", "0.65300655", "0.6530...
0.0
-1
Return a UsageLocator for the same block in a different branch of the course.
def for_branch(self, branch): return BlockUsageLocator( self.course_key.for_branch(branch), block_type=self.block_type, block_id=self.block_id )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def course_agnostic(self):\r\n return BlockUsageLocator(\r\n course_key=self.course_key.course_agnostic(),\r\n block_type=self.block_type,\r\n block_id=self.block_id\r\n )", "def version_agnostic(self):\r\n return BlockUsageLocator(\r\n course_key=...
[ "0.73189044", "0.7130702", "0.6932069", "0.68403745", "0.67775464", "0.6739059", "0.62568265", "0.5974072", "0.5964026", "0.59514165", "0.5830531", "0.5726849", "0.57207584", "0.56016576", "0.55972403", "0.55671054", "0.55113626", "0.54633486", "0.5276065", "0.5259994", "0.50...
0.8006385
0
Return a UsageLocator for the same block in a different branch of the course.
def for_version(self, version_guid): return BlockUsageLocator( self.course_key.for_version(version_guid), block_type=self.block_type, block_id=self.block_id )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def for_branch(self, branch):\r\n return BlockUsageLocator(\r\n self.course_key.for_branch(branch),\r\n block_type=self.block_type,\r\n block_id=self.block_id\r\n )", "def course_agnostic(self):\r\n return BlockUsageLocator(\r\n course_key=self.cou...
[ "0.80067426", "0.7321937", "0.713317", "0.69299185", "0.68431747", "0.6779138", "0.62562174", "0.5975161", "0.5965037", "0.5952846", "0.5830503", "0.5728475", "0.5722131", "0.5604953", "0.55980337", "0.55695987", "0.55144477", "0.54622924", "0.52757365", "0.5260093", "0.50889...
0.67407537
6
Return a new instance which has the given block_id in the given course
def make_relative(cls, course_locator, block_type, block_id): if hasattr(course_locator, 'course_key'): course_locator = course_locator.course_key return BlockUsageLocator( course_key=course_locator, block_type=block_type, block_id=block_id ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def course_from_id(course_id):\r\n return modulestore().get_course(course_id)", "def __init__(self, resource_id, course):\n self.id = resource_id\n self.course = course", "def _create_courselike( # lint-amnesty, pylint: disable=too-many-statements\n self, locator, user_id, master_branc...
[ "0.63635236", "0.6158784", "0.6145058", "0.6059773", "0.6021473", "0.59582555", "0.59180814", "0.58894306", "0.58688414", "0.58392656", "0.5791905", "0.5771714", "0.57216376", "0.5690368", "0.5602603", "0.5595446", "0.55847675", "0.5570241", "0.5564901", "0.55620694", "0.5550...
0.531727
50
Return a new instance which has the this block_id in the given course
def map_into_course(self, course_key): return BlockUsageLocator.make_relative(course_key, self.block_type, self.block_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, resource_id, course):\n self.id = resource_id\n self.course = course", "def course_from_id(course_id):\r\n return modulestore().get_course(course_id)", "def gen_new_block(self):\n block = BasicBlock()\n self.blocks.append(block)\n return block", "def s...
[ "0.65604025", "0.627936", "0.6274098", "0.6237522", "0.61984825", "0.60775465", "0.60102975", "0.59771425", "0.5923658", "0.5898647", "0.5878954", "0.5823618", "0.58097523", "0.5782286", "0.57768893", "0.5757831", "0.57215", "0.5721321", "0.57003", "0.5693283", "0.56816506", ...
0.588399
10
Returns the ObjectId referencing this specific location.
def version(self): return self.definition_id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def identifier(self):\n return location_id(self.__dict__)", "def objectId( self ):\n return self._objectId", "def getLastObjectId(self):\n return self.objId", "def obj_id(self) -> int:\n return int(self.index.split(\"/\")[-1]) if self.index else None", "def get_objectID(self):\n...
[ "0.77540237", "0.71123", "0.6935531", "0.6756416", "0.6681636", "0.66462964", "0.6595073", "0.6595073", "0.6579363", "0.6572986", "0.6572986", "0.6572986", "0.6572986", "0.6572986", "0.6572986", "0.6530216", "0.6530216", "0.6530216", "0.6530216", "0.6530216", "0.6530216", "...
0.0
-1
This method is explicitly not implemented as we need a course_id to disambiguate We should be able to fix this when the datamodel rearchitecting is done
def get_item(self, usage_key, depth=0): store = self._get_modulestore_for_courseid(usage_key.course_key) return store.get_item(usage_key, depth)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_course_id(self):\r\n\r\n cleaned_id = self.cleaned_data[\"course_id\"]\r\n try:\r\n course_key = CourseKey.from_string(cleaned_id)\r\n except InvalidKeyError:\r\n try:\r\n course_key = SlashSeparatedCourseKey.from_deprecated_string(cleaned_id)\r\n...
[ "0.61106795", "0.60958374", "0.5891352", "0.57394135", "0.567488", "0.5616914", "0.55979025", "0.5597866", "0.5572611", "0.55128646", "0.54954034", "0.54866046", "0.5485668", "0.5481332", "0.54750395", "0.546679", "0.5466751", "0.5424801", "0.5399171", "0.53863066", "0.534289...
0.0
-1
Create a new course in split_mongo representing the published and draft versions of the course from the original mongo store. And return the new CourseLocator If the new course already exists, this raises DuplicateItemError
def migrate_mongo_course(self, course_key, user, new_org=None, new_offering=None): new_course_locator = self.loc_mapper.create_map_entry(course_key, new_org, new_offering) # the only difference in data between the old and split_mongo xblocks are the locations; # so, any field which holds a lo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cloned_course(self):\r\n original_locator = CourseLocator(org='testx', offering='wonderful', branch='draft')\r\n original_index = modulestore().get_course_index_info(original_locator)\r\n new_draft = modulestore().create_course(\r\n 'best', 'leech', 'leech_master',\r\n ...
[ "0.7136302", "0.6618715", "0.6177206", "0.61265546", "0.6021689", "0.60199636", "0.5912586", "0.5802224", "0.5747839", "0.5737438", "0.5713451", "0.56089425", "0.55861664", "0.5492149", "0.5475935", "0.54435354", "0.54299694", "0.5396299", "0.5392754", "0.53746146", "0.531922...
0.7210311
0
Find the descriptor cache for this course if it exists
def _get_cache(self, course_version_guid): if not hasattr(self.thread_cache, 'course_cache'): self.thread_cache.course_cache = {} system = self.thread_cache.course_cache return system.get(course_version_guid)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_cache(self, course_version_guid):\n if self.request_cache is None:\n return None\n\n return self.request_cache.data.setdefault('course_cache', {}).get(course_version_guid)", "def _get_module(self, course_id, descriptor, location):\r\n field_data_cache = FieldDataCache.cac...
[ "0.6379798", "0.58891815", "0.5730449", "0.56331074", "0.56136787", "0.5510936", "0.5429821", "0.5353631", "0.52459174", "0.524442", "0.5220026", "0.5212898", "0.5152162", "0.5146877", "0.5133081", "0.510259", "0.5093875", "0.5093407", "0.5089998", "0.50672305", "0.5051693", ...
0.636324
1
Returns True if location exists in its course. Returns false if the course or the block w/in the course do not exist for the given version. raises InsufficientSpecificationError if the locator does not id a block
def has_item(self, usage_key): if usage_key.block_id is None: raise InsufficientSpecificationError(usage_key) try: course_structure = self._lookup_course(usage_key)['structure'] except ItemNotFoundError: # this error only occurs if the course does not ex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raise_if_labware_in_location(\n self, location: Union[DeckSlotLocation, ModuleLocation]\n ) -> None:\n for labware in self.get_all():\n if labware.location == location:\n raise errors.LocationIsOccupiedError(\n f\"Labware {labware.loadName} is alrea...
[ "0.626063", "0.6256207", "0.6178798", "0.60510486", "0.58758384", "0.57542783", "0.5600924", "0.55328345", "0.5452853", "0.5432218", "0.539423", "0.53933257", "0.5310996", "0.5294802", "0.52859914", "0.52728105", "0.5261895", "0.5258414", "0.5257261", "0.52301407", "0.5225812...
0.58344024
5
Create a new entry in the active courses index which points to an existing or new structure. Returns the course root of the resulting entry (the location has the course id)
def create_course( self, org, offering, user_id, fields=None, master_branch='draft', versions_dict=None, root_category='course', root_block_id='course', **kwargs ): # check offering's uniqueness locator = CourseLocator(org=org, offering=offering, branch=master_branch) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_courselike( # lint-amnesty, pylint: disable=too-many-statements\n self, locator, user_id, master_branch, fields=None,\n versions_dict=None, search_targets=None, root_category='course',\n root_block_id=None, **kwargs\n ):\n index = self.get_course_index(locator, ignore_ca...
[ "0.69278735", "0.6400577", "0.6148355", "0.6142394", "0.59251183", "0.5896548", "0.5786264", "0.56717485", "0.56686103", "0.5665256", "0.5566582", "0.5550538", "0.55279166", "0.5510442", "0.5488653", "0.54875845", "0.54454076", "0.5408501", "0.53710383", "0.53661376", "0.5356...
0.62061465
2
This method instantiates the correct subclass of XModuleDescriptor based on the contents of json_data. It does not persist it and can create one which has no usage id. parent_xblock is used to compute inherited metadata as well as to append the new xblock.
def create_xblock(self, runtime, category, fields=None, block_id=None, definition_id=None, parent_xblock=None): xblock_class = runtime.load_block_type(category) json_data = { 'category': category, 'fields': fields or {}, } if definition_id is not None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_xblock(\n self, runtime, course_key, block_type, block_id=None, fields=None,\n definition_id=None, parent_xblock=None, **kwargs\n ):\n assert runtime is not None\n\n xblock_class = runtime.load_block_type(block_type)\n json_data = {\n 'block_type'...
[ "0.64976245", "0.59309393", "0.58429277", "0.5813348", "0.56976664", "0.56646776", "0.56216145", "0.55531055", "0.5544792", "0.5509474", "0.5467875", "0.54390776", "0.54084545", "0.5332981", "0.53160113", "0.5199698", "0.51962095", "0.5189353", "0.5138907", "0.5138148", "0.51...
0.652071
0
Return True if the settings are not == to the original fields
def _compare_settings(self, settings, original_fields): original_keys = original_fields.keys() if 'children' in original_keys: original_keys.remove('children') if len(settings) != len(original_keys): return True else: new_keys = settings.keys() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _compare_settings(self, settings, original_fields):\n original_keys = list(original_fields.keys())\n if 'children' in original_keys:\n original_keys.remove('children')\n if len(settings) != len(original_keys):\n return True\n else:\n new_keys = list(...
[ "0.7936154", "0.7118527", "0.6934282", "0.68726224", "0.686396", "0.68064344", "0.66815805", "0.664834", "0.6247836", "0.61969346", "0.616874", "0.61615676", "0.6160348", "0.6114915", "0.6095754", "0.60906893", "0.6058233", "0.60563254", "0.6052456", "0.6044839", "0.6026975",...
0.79467356
0
If using a Mongobacked modulestore & contentstore, drop the collections.
def drop_mongo_collections(store_name='default'): # This will return the mongo-backed modulestore # even if we're using a mixed modulestore store = editable_modulestore(store_name) if hasattr(store, 'collection'): connection = store.collection.database.connection ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_mongo_collections():\n AnalysisResultMeta.drop_collection()\n Sample.drop_collection()\n for tool_result in all_tool_results:\n tool_result.result_model().drop_collection()", "def clear_collections():\n LOGGER.debug('Clearing all collections from database.')\n with MongoDBConnectio...
[ "0.80337965", "0.77449983", "0.7689917", "0.7622799", "0.761489", "0.75467503", "0.74742573", "0.7048103", "0.70082074", "0.69801664", "0.694413", "0.6917051", "0.6856907", "0.68114746", "0.6560429", "0.65425277", "0.6354624", "0.6351222", "0.6287168", "0.61932", "0.6146881",...
0.84350675
0
Test that the ssck constructor fails if given invalid chars
def test_invalid_chars_ssck(self): valid_base = SlashSeparatedCourseKey(u'org.dept-1%2', u'course.sub-2%3', u'run.faster-4%5') for key in SlashSeparatedCourseKey.KEY_FIELDS: with self.assertRaises(InvalidKeyError): # this ends up calling the constructor where the legality...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testConstructorValueError(self):\n test_cases = [\n 'these',\n 'are',\n 'bad',\n 'data',\n 'types',\n 'FILE',\n 'STRING',\n 'JSON',\n ]\n for bad_data_type in test_cases:\n with self.assertRa...
[ "0.6912771", "0.6581253", "0.64885414", "0.6435747", "0.64250857", "0.63796055", "0.6370428", "0.63700557", "0.6367095", "0.6322118", "0.6310139", "0.62948954", "0.6292142", "0.62305874", "0.62297577", "0.61909515", "0.615182", "0.6139743", "0.6139014", "0.61292756", "0.61026...
0.7319966
0
Test that the location constructor fails if given invalid chars
def test_invalid_chars_location(self): course_key = SlashSeparatedCourseKey(u'org.dept-1%2', u'course.sub-2%3', u'run.faster-4%5') valid_base = course_key.make_usage_key('tomato-again%9', 'block-head:sub-4%9') for key in SlashSeparatedCourseKey.KEY_FIELDS: with self.assertRaises(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_special_chars(self):\r\n # afaik, location.check_list prevents $ in all fields\r\n org = 'foo.org.edu'\r\n course = 'bar.course-4'\r\n name = 'baz.run_4-3'\r\n location = Location(org, course, name, 'course', name)\r\n prob_locator = loc_mapper().translate_locatio...
[ "0.692415", "0.6923763", "0.6632969", "0.6504344", "0.6430441", "0.64055324", "0.64047635", "0.63560605", "0.6348949", "0.6340072", "0.6320804", "0.62783074", "0.62543017", "0.6243548", "0.6240298", "0.6235918", "0.6221203", "0.6201329", "0.6166374", "0.6103393", "0.60963076"...
0.7109078
0
Test the location translation mechanisms which try to dowhatimean by creating new entries for never seen queries.
def test_translate_location_dwim(self): org = 'foo_org' course = 'bar_course' run = 'baz_run' problem_name = 'abc123abc123abc123abc123abc123f9' location = Location(org, course, run, 'problem', problem_name) new_offering = '{}.{}'.format(course, run) self.tr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_translate_location_read_only(self):\r\n # lookup before there are any maps\r\n org = 'foo_org'\r\n course = 'bar_course'\r\n run = 'baz_run'\r\n slash_course_key = SlashSeparatedCourseKey(org, course, run)\r\n with self.assertRaises(ItemNotFoundError):\r\n ...
[ "0.6747906", "0.6340642", "0.63365674", "0.6297696", "0.6157931", "0.6140443", "0.6081878", "0.5992594", "0.59479016", "0.5938542", "0.59163404", "0.5910256", "0.58933806", "0.58575726", "0.5834789", "0.58164924", "0.57948935", "0.57834923", "0.57775366", "0.57577467", "0.574...
0.739527
0
Mocks the global location mapper.
def loc_mapper(): return LocMapperSetupSansDjango.loc_store
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_split_inject_loc_mapper(self):\r\n # instantiate location mapper before split\r\n mapper = loc_mapper()\r\n # split must inject the location mapper itself since the mapper existed before it did\r\n self.assertEqual(modulestore('split').loc_mapper, mapper)", "def test_loc_inje...
[ "0.72872454", "0.69331765", "0.65773726", "0.64912045", "0.6381519", "0.63003856", "0.6248782", "0.62294996", "0.61578715", "0.60714376", "0.6055396", "0.60553414", "0.6049398", "0.6022371", "0.5925882", "0.58960086", "0.58821833", "0.5851979", "0.5805651", "0.57922506", "0.5...
0.6764591
2
Test the get_courses_for_wiki method
def test_get_courses_for_wiki(self, default_ms): self.initdb(default_ms) course_locations = self.store.get_courses_for_wiki('toy') self.assertEqual(len(course_locations), 1) self.assertIn(self.course_locations[self.XML_COURSEID1], course_locations) course_locations = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_courses_for_wiki(self):\r\n store = XMLModuleStore(DATA_DIR, course_dirs=['toy', 'simple'])\r\n for course in store.get_courses():\r\n course_locations = store.get_courses_for_wiki(course.wiki_slug)\r\n self.assertEqual(len(course_locations), 1)\r\n self....
[ "0.8502628", "0.7971719", "0.7702734", "0.7662821", "0.7349185", "0.72656924", "0.7188036", "0.7130054", "0.7103404", "0.7090293", "0.7082584", "0.7077868", "0.7044578", "0.69923735", "0.698069", "0.69443756", "0.69442993", "0.6933087", "0.69249994", "0.691421", "0.6913397", ...
0.8460977
1
Test get_course and has_course with ids which don't exist
def test_no_such_course(self): for course_key in [ SlashSeparatedCourseKey(*fields) for fields in [ ['edX', 'simple', 'no_such_course'], ['edX', 'no_such_course', '2012_Fall'], ['NO_SUCH_COURSE', 'Test_iMport_courSe', '2012_Fall'], ] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_api_get_course_by_id_course_not_found(client):\n add_course(client=client, times=10)\n response = client.get(\n \"/api/1.0/courses/20\"\n )\n response = json.loads(response.data)\n assert (\n {\n 'code': 404,\n 'message': 'Course not found'\n }\n ...
[ "0.7269935", "0.7202401", "0.7034515", "0.6953434", "0.69391704", "0.6935571", "0.689563", "0.6889411", "0.68865323", "0.6885177", "0.68534964", "0.68376046", "0.6823371", "0.68100655", "0.6792407", "0.67406934", "0.67159086", "0.6702904", "0.66463", "0.6618904", "0.66170615"...
0.70248455
3
Test the get_courses_for_wiki method
def test_get_courses_for_wiki(self): for course_number in self.courses: course_locations = self.store.get_courses_for_wiki(course_number) assert_equals(len(course_locations), 1) assert_equals(Location('edX', course_number, '2012_Fall', 'course', '2012_Fall'), course_locat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_courses_for_wiki(self):\r\n store = XMLModuleStore(DATA_DIR, course_dirs=['toy', 'simple'])\r\n for course in store.get_courses():\r\n course_locations = store.get_courses_for_wiki(course.wiki_slug)\r\n self.assertEqual(len(course_locations), 1)\r\n self....
[ "0.8502628", "0.8460977", "0.7702734", "0.7662821", "0.7349185", "0.72656924", "0.7188036", "0.7130054", "0.7103404", "0.7090293", "0.7082584", "0.7077868", "0.7044578", "0.69923735", "0.698069", "0.69443756", "0.69442993", "0.6933087", "0.69249994", "0.691421", "0.6913397", ...
0.7971719
2
Test that old mongo finds the orphans
def test_mongo_orphan(self): orphans = self.old_mongo.get_orphans(self.old_course_key) self.assertEqual(len(orphans), 3, "Wrong # {}".format(orphans)) location = self.old_course_key.make_usage_key('chapter', name='OrphanChapter') self.assertIn(location.to_deprecated_string(), orphans...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mongo_orphan_delete(self):\r\n self.client.delete(self.orphan_url)\r\n orphans = json.loads(\r\n self.client.get(self.orphan_url, HTTP_ACCEPT='application/json').content\r\n )\r\n self.assertEqual(len(orphans), 0, \"Orphans not deleted {}\".format(orphans))", "def ...
[ "0.76553106", "0.73093486", "0.6820571", "0.65045714", "0.62482643", "0.61683047", "0.61096334", "0.6010656", "0.6007425", "0.59727925", "0.59520775", "0.5915541", "0.5883634", "0.5877788", "0.58766073", "0.58474076", "0.58434767", "0.58387196", "0.58383524", "0.57930446", "0...
0.76557106
0
Clear persistence between each test.
def tearDown(self): collection_prefix = SplitModuleTest.MODULESTORE['DOC_STORE_CONFIG']['collection'] + '.' if SplitModuleTest.modulestore: for collection in ('active_versions', 'structures', 'definitions'): modulestore().db.drop_collection(collection_prefix + collection)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n self.all_ob = storage.all()\n self.all_ob.clear()\n storage.save()", "def teardown(self):\n # dump persistent storage to file\n dump_persistent_settings(self.settings_path, self.id_dict)", "def tearDown(self):\r\n testing.tearDown()\r\n emp...
[ "0.7534589", "0.74918497", "0.7430392", "0.7430392", "0.7430392", "0.7430392", "0.7430392", "0.7430392", "0.7430392", "0.7430392", "0.7430392", "0.72746307", "0.72746307", "0.72746307", "0.72746307", "0.72746307", "0.72746307", "0.724489", "0.7243673", "0.7243673", "0.7243673...
0.0
-1
test updating an item's children ensuring the definition doesn't version but the course does if it should
def test_update_children(self): locator = BlockUsageLocator( CourseLocator(org='testx', offering='GreekHero', branch='draft'), 'chapter', 'chapter3' ) block = modulestore().get_item(locator) pre_def_id = block.definition_locator.definition_id pre_version_guid = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_reorder_children(self):\r\n # Create 2 child units and re-order them. There was a bug about @draft getting added\r\n # to the IDs.\r\n unit_1_resp = self.create_xblock(parent_usage_key=self.seq_usage_key, category='vertical')\r\n unit_2_resp = self.create_xblock(parent_usage_ke...
[ "0.6859448", "0.6796133", "0.6618923", "0.6510391", "0.6497287", "0.64373606", "0.6311737", "0.6230069", "0.61779785", "0.61620146", "0.60393155", "0.60392326", "0.6034382", "0.60267717", "0.60132664", "0.59937143", "0.5947568", "0.59402645", "0.59401727", "0.59036225", "0.58...
0.7870027
0
Test making a course which points to an existing draft and published but not making any changes to either.
def test_cloned_course(self): original_locator = CourseLocator(org='testx', offering='wonderful', branch='draft') original_index = modulestore().get_course_index_info(original_locator) new_draft = modulestore().create_course( 'best', 'leech', 'leech_master', versions...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def testCourses(self):\n self.person.invokeFactory(type_name=\"FSDCourse\", id=\"test-course\")\n self.failUnless('test-course' in self.person.contentIds())\n self.failUnless('test-course' in [c.id for c in self.person....
[ "0.7641873", "0.7380443", "0.733186", "0.72995895", "0.7115093", "0.7085003", "0.7055328", "0.7011537", "0.6968633", "0.68924177", "0.68618476", "0.6853815", "0.68512446", "0.6802292", "0.67641294", "0.6753243", "0.6749831", "0.67388797", "0.67385215", "0.67375827", "0.663067...
0.76476145
0
Create a new course which overrides metadata and course_data
def test_derived_course(self): original_locator = CourseLocator(org='guestx', offering='contender', branch='draft') original = modulestore().get_course(original_locator) original_index = modulestore().get_course_index_info(original_locator) fields = {} for field in original....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_course(self):\r\n # If the course already exists, this will respond\r\n # with a 200 and an error message, which we ignore.\r\n response = self.session.post(\r\n STUDIO_BASE_URL + '/course/',\r\n data=self._encode_post_dict(self._course_dict),\r\n h...
[ "0.78669626", "0.7514143", "0.746979", "0.74154717", "0.73781025", "0.73540235", "0.7245959", "0.7212707", "0.7101593", "0.7092988", "0.700042", "0.6978713", "0.6898622", "0.67727774", "0.6769677", "0.665754", "0.66489786", "0.66460407", "0.6611397", "0.660408", "0.6591145", ...
0.5907169
51
Test create_course with a specified root id and category
def test_create_with_root(self): user = random.getrandbits(32) new_course = modulestore().create_course( 'test_org', 'test_transaction', user, root_block_id='top', root_category='chapter' ) self.assertEqual(new_course.location.block_id, 'top') self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course(self):\r\n self.assert_created_course()", "def test_create_category(self):\n pass", "def _create_course(test, course_key, course_data):\r\n course_url = get_url('course_handler', course_key, 'course_key_string')\r\n response = test.client.ajax_post(course_url, course_...
[ "0.74091667", "0.73380226", "0.70720077", "0.68306935", "0.67980903", "0.67979455", "0.6678013", "0.6633165", "0.66286314", "0.65682817", "0.65607196", "0.6519016", "0.64459795", "0.6436103", "0.64006114", "0.63987106", "0.634912", "0.6330544", "0.63231796", "0.632105", "0.63...
0.74172986
0
Test create_course rejects duplicate id
def test_create_id_dupe(self): user = random.getrandbits(32) courses = modulestore().get_courses() with self.assertRaises(DuplicateCourseError): dupe_course_key = courses[0].location.course_key modulestore().create_course(dupe_course_key.org, dupe_course_key.offering...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_course_duplicate_course(self):\r\n self.client.ajax_post('/course/', self.course_data)\r\n self.assert_course_creation_failed('There is already a course defined with the same organization, course number, and course run. Please change either organization or course number to be unique.'...
[ "0.8662303", "0.8102626", "0.8100951", "0.8006457", "0.7679953", "0.7492593", "0.720408", "0.7080545", "0.69750273", "0.6848277", "0.6826825", "0.67943805", "0.67721885", "0.6764486", "0.67135376", "0.6700668", "0.66677105", "0.6656433", "0.66544265", "0.6591809", "0.6588006"...
0.79581314
4
Test publishing moves and deletes.
def test_move_delete(self): source_course = CourseLocator(org='testx', offering='GreekHero', branch='draft') dest_course = CourseLocator(org='testx', offering='GreekHero', branch="published") head = source_course.make_usage_key('course', "head12345") chapter2 = source_course.make_usa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_publish1(self):\n publish = self.queue.publish(TEST_QUEUE, 'this is a test msg')\n assert publish", "def test_stream_publish(self):\n pass", "def test_durable_exchange_publish(self):\n self.durable_exchange_publisher._connect()\n with self.assertLogs(level='INFO') as...
[ "0.67133373", "0.6537801", "0.6401798", "0.63574666", "0.6353617", "0.6155333", "0.60700065", "0.60445523", "0.59720165", "0.59716237", "0.5917139", "0.5904562", "0.58986485", "0.5896337", "0.5860222", "0.5858181", "0.5842002", "0.5822993", "0.58074844", "0.5803652", "0.57900...
0.62625355
5
Check that the course has the expected blocks and does not have the unexpected blocks
def _check_course(self, source_course_loc, dest_course_loc, expected_blocks, unexpected_blocks): history_info = modulestore().get_course_history_info(dest_course_loc) self.assertEqual(history_info['edited_by'], self.user) for expected in expected_blocks: # since block_type has no...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_block_bad_consensus(self):\n pass", "def verify_blocks_details(app, styles):\n error = []\n for column in range(2):\n for row in range(2):\n if app.board.blocks[column][row].get_style() != styles[column][row]:\n error.append(f'block[{column}][{row}] invalid ...
[ "0.7147128", "0.68357617", "0.6737821", "0.6720834", "0.66191113", "0.6602214", "0.6594975", "0.65155697", "0.6486563", "0.6482774", "0.63398176", "0.63357425", "0.6300901", "0.62861335", "0.6197858", "0.6182083", "0.61534166", "0.6150057", "0.61467755", "0.614243", "0.612361...
0.72621477
0
Ensure dest_children == source_children minus unexpected
def _compare_children(self, source_children, dest_children, unexpected): dest_cursor = 0 for child in source_children: child = child.version_agnostic() if child.block_id in unexpected: self.assertNotIn(child.block_id, [dest.block_id for dest in dest_children]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _sync_children(self, source_parent, destination_parent, new_child):\n destination_reordered = []\n destination_children = set(destination_parent.fields['children'])\n source_children = source_parent.fields['children']\n orphans = destination_children - set(source_children)\n ...
[ "0.72376657", "0.7149683", "0.6665351", "0.62044317", "0.60696596", "0.59046614", "0.58840996", "0.5824687", "0.5781102", "0.5772946", "0.57359165", "0.57331353", "0.5722438", "0.56982905", "0.56558967", "0.560037", "0.55996275", "0.55879194", "0.5584096", "0.5582137", "0.556...
0.78690517
0
Remove the test collections, close the db connection
def tear_down_split(self): split_db = self.split_mongo.db split_db.drop_collection(split_db.course_index) split_db.drop_collection(split_db.structures) split_db.drop_collection(split_db.definitions)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_collections():\n LOGGER.debug('Clearing all collections from database.')\n with MongoDBConnection() as mongo:\n database = mongo.connection.hp_norton\n database.products.drop()\n database.customers.drop()\n database.rentals.drop()", "def teardown():\n teardown_db()"...
[ "0.7646687", "0.7529864", "0.75180423", "0.7504739", "0.7487321", "0.73821604", "0.73779976", "0.73409635", "0.73328674", "0.73328674", "0.7326699", "0.73126435", "0.73110193", "0.7309709", "0.7309709", "0.7309709", "0.7309709", "0.7309709", "0.7309709", "0.7309709", "0.73097...
0.75324893
1
Remove the test collections, close the db connection
def tear_down_mongo(self): split_db = self.split_mongo.db # old_mongo doesn't give a db attr, but all of the dbs are the same split_db.drop_collection(self.old_mongo.collection)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_collections():\n LOGGER.debug('Clearing all collections from database.')\n with MongoDBConnection() as mongo:\n database = mongo.connection.hp_norton\n database.products.drop()\n database.customers.drop()\n database.rentals.drop()", "def tear_down_split(self):\r\n ...
[ "0.7646687", "0.75324893", "0.7529864", "0.75180423", "0.7504739", "0.7487321", "0.73821604", "0.73779976", "0.73409635", "0.73328674", "0.73328674", "0.7326699", "0.73126435", "0.73110193", "0.7309709", "0.7309709", "0.7309709", "0.7309709", "0.7309709", "0.7309709", "0.7309...
0.72442937
42
A wrapper for the `glob.glob` function, but it always returns files that end in a tilde (~) at the end of the list of results.
def glob_tildes_at_end(path): result = glob(path) with_tildes = [f for f in result if f.endswith("~")] no_tildes = [f for f in result if not f.endswith("~")] return no_tildes + with_tildes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def glob1(self, dirname, pattern):\n names = self.listdir(dirname)\n if pattern[0] != '.':\n names = filter(lambda x: x[0] != '.',names)\n return fnmatch.filter(names, pattern)", "def recursive_glob(self, rootdir='.', suffix=''):\n return [os.path.join(rootdir, filename)\n ...
[ "0.62767416", "0.62644243", "0.61405843", "0.60665786", "0.60083485", "0.600145", "0.59973687", "0.59938824", "0.5933983", "0.592274", "0.58913916", "0.58913916", "0.5878338", "0.5876343", "0.5851471", "0.58380294", "0.5832061", "0.58036524", "0.5800996", "0.5798833", "0.5780...
0.738306
0
Test the get_courses_for_wiki method
def test_get_courses_for_wiki(self): store = XMLModuleStore(DATA_DIR, course_dirs=['toy', 'simple']) for course in store.get_courses(): course_locations = store.get_courses_for_wiki(course.wiki_slug) self.assertEqual(len(course_locations), 1) self.assertIn(course...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_courses_for_wiki(self, default_ms):\r\n self.initdb(default_ms)\r\n course_locations = self.store.get_courses_for_wiki('toy')\r\n self.assertEqual(len(course_locations), 1)\r\n self.assertIn(self.course_locations[self.XML_COURSEID1], course_locations)\r\n\r\n course_...
[ "0.8460977", "0.7971719", "0.7702734", "0.7662821", "0.7349185", "0.72656924", "0.7188036", "0.7130054", "0.7103404", "0.7090293", "0.7082584", "0.7077868", "0.7044578", "0.69923735", "0.698069", "0.69443756", "0.69442993", "0.6933087", "0.69249994", "0.691421", "0.6913397", ...
0.8502628
0
Create an XBlock instance from XML data.
def create_block_from_xml(xml_data, system, id_generator): node = etree.fromstring(xml_data) raw_class = system.load_block_type(node.tag) xblock_class = system.mixologist.mix(raw_class) # leave next line commented out - useful for low-level debugging # log.debug('[create_block_from_xml] tag=%...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_xml(cls, node, runtime, keys, id_generator):\r\n xml = etree.tostring(node)\r\n block = cls.from_xml(xml, runtime, id_generator)\r\n return block", "def from_xml(self, xml_data):\n data = BeautifulStoneSoup(xml_data.find('string').contents[0])\n data = data.contents[0]\n s...
[ "0.70274645", "0.68794304", "0.6743776", "0.6393156", "0.6296787", "0.6229261", "0.6175537", "0.61723477", "0.6143768", "0.59674925", "0.5952811", "0.59514713", "0.5847602", "0.5828071", "0.5822624", "0.57970876", "0.5761853", "0.5753262", "0.5731429", "0.57144403", "0.569732...
0.8156796
0
Returns an XBlock instance for the item for this UsageKey. If any segment of the location is None except revision, raises xmodule.modulestore.exceptions.InsufficientSpecificationError If no object is found at that location, raises xmodule.modulestore.exceptions.ItemNotFoundError
def get_item(self, usage_key, depth=0): try: return self.modules[usage_key.course_key][usage_key] except KeyError: raise ItemNotFoundError(usage_key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_item(self, location):\r\n assert isinstance(location, Location)\r\n json_data = self.module_data.get(location)\r\n if json_data is None:\r\n module = self.modulestore.get_item(location)\r\n if module is not None:\r\n # update our own cache after go...
[ "0.654212", "0.60453594", "0.6005268", "0.60044295", "0.58093905", "0.5691051", "0.56527084", "0.5641596", "0.56159747", "0.5613722", "0.55903625", "0.5577727", "0.5576677", "0.55627054", "0.5545749", "0.55129355", "0.5477619", "0.54507256", "0.5418911", "0.5411781", "0.53832...
0.61474156
1
Convert a reference to the new namespace, but only if the original namespace matched the original course. Otherwise, returns the input value.
def _convert_reference_fields_to_new_namespace(reference): assert isinstance(reference, UsageKey) if source_course_id == reference.course_key: return reference.map_into_course(dest_course_id) else: return reference
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_namespace(self, namespace, lowercase=True, trim_namespace=True):\n\t\treturn self.get_namespace_view(namespace, lowercase, trim_namespace).copy()", "def test_replace_net_namespace(self):\n pass", "def _fixNS(self, namespace):\n if isinstance(namespace, bytes):\n namespace = str...
[ "0.55002266", "0.5487474", "0.52681303", "0.5123195", "0.5012319", "0.49208102", "0.4911433", "0.4905525", "0.4905525", "0.4887224", "0.4878213", "0.484855", "0.48240834", "0.47869772", "0.47506508", "0.47394314", "0.47305918", "0.47245178", "0.46803206", "0.46559107", "0.463...
0.7401923
0
Return a key for sorting a list of indexed task_states, by how far the student got through the tasks, what their highest score was, and then the index of the submission.
def states_sort_key(self, idx_task_states): idx, task_states = idx_task_states state_values = { OpenEndedChild.INITIAL: 0, OpenEndedChild.ASSESSING: 1, OpenEndedChild.POST_ASSESSMENT: 2, OpenEndedChild.DONE: 3 } if not task_stat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_key(self):\n ...", "def job_sorter(self, job):\n key = natsort.natsort_keygen(key=self.job_title, alg=natsort.REAL)\n return key(job)", "def table_key(self, reindex_dict):\n reindexed_marks = []\n for m in self.component1.marks:\n new_m = reindex_dict.get(...
[ "0.60499537", "0.5699991", "0.56935567", "0.5686954", "0.56462675", "0.5605116", "0.55651915", "0.54815257", "0.5417188", "0.5385709", "0.535983", "0.52993727", "0.5270261", "0.52555144", "0.52327573", "0.521551", "0.52074593", "0.5191875", "0.51797575", "0.5167946", "0.51555...
0.71451104
0
Gets the current state of the module.
def get_current_state(self, data): return self.get_context()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_state(self):\n return self._env.get_state()", "def get_current_state(self):\n return self._current_state", "def get_current_state(self):\n return self.game.get_current_state()", "def _get_state(self):\n return self.__state", "def _get_state(self):\n return self.__state", ...
[ "0.7818938", "0.77633864", "0.76860726", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", "0.7662738", ...
0.0
-1
Returns the current instance state. The module can be recreated from the instance state.
def get_instance_state(self): state = { 'version': self.STATE_VERSION, 'current_task_number': self.current_task_number, 'state': self.state, 'task_states': self.task_states, 'student_attempts': self.student_attempts, 'ready_to_rese...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Current(self):\r\n return dict([(vname, copy.deepcopy(getattr(self.module, vname)))\r\n for vname in self.module.state ])", "def current_instance_state(self):\r\n cur = {}\r\n for prop in self.__class__.entity_atts:\r\n cur[prop] = getattr(self, prop)\r\n r...
[ "0.7538599", "0.7302177", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "0.7297075", "...
0.7077322
80
Maximum score possible in this module. Returns the max score if finished, None if not.
def max_score(self): max_score = None if self.check_if_done_and_scored(): max_score = self._max_score return max_score
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_score(self):\n return max(self._extract_set('score') or [0])", "def max_score(self):\r\n return self.lcp.get_max_score()", "def getNextHighest(self):\r\n maxScore = -1\r\n idx = -1\r\n for i, s in enumerate(self.scores):\r\n if s.score > maxScore:\r\n ...
[ "0.83737", "0.8289203", "0.82116586", "0.79630494", "0.7857447", "0.7755862", "0.77016425", "0.7676018", "0.7440806", "0.74222463", "0.73931855", "0.73862565", "0.73533314", "0.734479", "0.73010796", "0.7277054", "0.72752285", "0.7244557", "0.7237665", "0.7208156", "0.7160643...
0.876525
0
Return a metric name for datadog, using `self.METRIC_NAME` as a prefix, and `suffix` as the suffix.
def _metric_name(self, suffix): return '{}.{}'.format(self.METRIC_NAME, suffix)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metric_name(self) -> str:\n return self._metric_name", "def metric_name(self) -> str:\n return pulumi.get(self, \"metric_name\")", "def metric_name(self) -> str:\n return pulumi.get(self, \"metric_name\")", "def metric_name(self) -> str:\n return self._values.get('metric_name'...
[ "0.6514743", "0.6367603", "0.6367603", "0.63626045", "0.63626045", "0.63112867", "0.62159795", "0.6142327", "0.6142327", "0.60858077", "0.6064859", "0.59745336", "0.5925784", "0.591612", "0.591612", "0.59030545", "0.59030545", "0.5885057", "0.5879638", "0.5879638", "0.5879638...
0.85057163
0
Return sum of rubric scores for ML grading otherwise return attempt["score"].
def score_for_attempt(self, index): attempt = self.child_history[index] score = attempt.get('score') post_assessment_data = self._parse_score_msg(attempt.get('post_assessment', "{}"), self.system) grader_types = post_assessment_data.get('grader_types') # According to _pars...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_score(self):\r\n correct = 0\r\n for key in self.correct_map:\r\n try:\r\n correct += self.correct_map.get_npoints(key)\r\n except Exception:\r\n log.error('key=%s, correct_map = %s', key, self.correct_map)\r\n raise\r\n\r\n ...
[ "0.6778691", "0.6617835", "0.6526328", "0.6498285", "0.63939387", "0.6371459", "0.63563436", "0.63501567", "0.63409454", "0.63327694", "0.63237214", "0.62967634", "0.6284817", "0.6244364", "0.6223233", "0.6222291", "0.6222291", "0.6222291", "0.62203914", "0.6198994", "0.61819...
0.72522956
0
Returns the current instance state. The module can be recreated from the instance state.
def get_instance_state(self): state = { 'student_data_for_location': self.student_data_for_location, } return json.dumps(state)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Current(self):\r\n return dict([(vname, copy.deepcopy(getattr(self.module, vname)))\r\n for vname in self.module.state ])", "def current_instance_state(self):\r\n cur = {}\r\n for prop in self.__class__.entity_atts:\r\n cur[prop] = getattr(self, prop)\r\n r...
[ "0.7538825", "0.7303557", "0.72968906", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", "0.7296337", ...
0.0
-1
Returns a list of XModuleDescriptor instances upon which this module depends, but are not children of this module.
def get_required_module_descriptors(self): # If use_for_single_location is True, this is linked to an open ended problem. if self.use_for_single_location: # Try to load the linked module. # If we can't load it, return empty list to avoid exceptions on progress page. ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_required_module_descriptors(self):\r\n return []", "def independent_nodes(self):\n dependent_nodes = set(node for dependents in self.graph.values()\n for node in dependents)\n return [node for node in self.graph.keys()\n if node not in depe...
[ "0.6333644", "0.6233837", "0.61472094", "0.6074668", "0.5942525", "0.59388065", "0.5846368", "0.5839168", "0.5825109", "0.57997644", "0.5764753", "0.5744539", "0.573339", "0.57291114", "0.57049495", "0.5673412", "0.5640174", "0.5628698", "0.5606574", "0.56044275", "0.558171",...
0.574758
11
Returns the group ID, or None if none is available.
def get_group_id(self): partitions_service = self.runtime.service(self, 'partitions') if not partitions_service: return None return partitions_service.get_user_group_for_partition(self.user_partition_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"group_id\")", "def group_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"group_id\")", "def group_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"group_id\")", "def gr...
[ "0.83392334", "0.83392334", "0.83392334", "0.8139402", "0.79065126", "0.7810767", "0.7668793", "0.76541704", "0.76541704", "0.75214523", "0.7515195", "0.7515195", "0.7515195", "0.74781495", "0.7463667", "0.7448542", "0.74093425", "0.73308223", "0.731729", "0.72702885", "0.727...
0.6979069
44
Determines whether the tab should be displayed in the UI for the given course and a particular user. This method is to be overridden by subclasses when applicable. The base class implementation always returns True.
def can_display(self, course, settings, is_user_authenticated, is_user_staff): # pylint: disable=unused-argument return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_visible_to(self, user):\n return True", "def show_staff_ui(self):\n return self.is_course_staff and not self.in_studio_preview", "def uses_usercase(self):\n return any(form.uses_usercase() for form in self.get_forms())", "def has_user(self, user): # pylint: disable=unused-argumen...
[ "0.64779395", "0.6196852", "0.60749257", "0.6067025", "0.6046976", "0.59978956", "0.596981", "0.59660643", "0.59246266", "0.59246266", "0.5909461", "0.5891531", "0.5882209", "0.5881221", "0.58762616", "0.5847106", "0.58242184", "0.5810905", "0.58028847", "0.5779431", "0.57720...
0.69893545
0
Overrides the equal operator to check equality of member variables rather than the object's address. Also allows comparison with dicttype tabs (needed to support callers implemented before this class was implemented).
def __eq__(self, other): if type(other) is dict and not self.validate(other, raise_error=False): # 'other' is a dict-type tab and did not validate return False # allow tabs without names; if a name is required, its presence was checked in the validator. name_is_e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n if type(self) != type(other):\n return False\n s_vars = vars(self)\n o_vars = vars(other)\n for v in vars(self):\n if s_vars[v] != o_vars[v]:\n print(\"unequal property {0}\\n\".format(v))\n if v.endswith(\"l...
[ "0.67167056", "0.6684552", "0.6665325", "0.6615569", "0.6608195", "0.6599843", "0.65909874", "0.6577676", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", "0.6575211", ...
0.72556347
0
Overrides the not equal operator as a partner to the equal operator.
def __ne__(self, other): return not (self == other)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ne (self, other):\n return not (self == other) # opposite of eq", "def __ne__(self, other):\n return not (self == other) # opposite of __eq__", "def __ne__(self, other):\n return not (self == other) # opposite of __eq__", "def __ne__(self, other):\n ...
[ "0.79315966", "0.7928583", "0.7893225", "0.78848577", "0.7801279", "0.7794095", "0.7707086", "0.7707086", "0.7707086", "0.7707086", "0.7687718", "0.7687718", "0.7687718", "0.7687718", "0.7687718", "0.7687718", "0.7687718", "0.7687718", "0.7687718", "0.7687718", "0.7687718", ...
0.7539391
51
Returns the discussion tab for the given course. It can be either of type DiscussionTab or ExternalDiscussionTab. The returned tab object is selfaware of the 'link' that it corresponds to.
def get_discussion(course): # the discussion_link setting overrides everything else, even if there is a discussion tab in the course tabs if course.discussion_link: return ExternalDiscussionTab(link_value=course.discussion_link) # find one of the discussion tab types in the c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_discussion(self, discussion_type, anchor, channel):\n discussion = self.create(anchor=anchor, channel=channel)\n return discussion", "def initialize_default(course):\r\n\r\n course.tabs.extend([\r\n CoursewareTab(),\r\n CourseInfoTab(),\r\n ])\r\n\r\n ...
[ "0.53998476", "0.53376985", "0.5164423", "0.50362676", "0.5034032", "0.48982075", "0.48952717", "0.48616037", "0.48280808", "0.46626192", "0.44977206", "0.44241196", "0.44095153", "0.4407402", "0.43646505", "0.43616956", "0.43471545", "0.4317977", "0.42794436", "0.42743933", ...
0.88190097
0
Check that the tabs set for the specified course is valid. If it isn't, raise InvalidTabsException with the complaint.
def validate_tabs(cls, tabs): if tabs is None or len(tabs) == 0: return if len(tabs) < 2: raise InvalidTabsException("Expected at least two tabs. tabs: '{0}'".format(tabs)) if tabs[0].get('type') != CoursewareTab.type: raise InvalidTabsException( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_course(self):\n # Verify that the selected mode is valid for the given course .\n course_details = self.cleaned_data.get(self.Fields.COURSE)\n if course_details:\n course_mode = self.cleaned_data.get(self.Fields.COURSE_MODE)\n if not course_mode:\n ...
[ "0.6194052", "0.59568197", "0.5790666", "0.5566758", "0.54618204", "0.5330842", "0.5321842", "0.5284483", "0.52529186", "0.5209842", "0.51681006", "0.5115677", "0.50990885", "0.50735706", "0.5062133", "0.505827", "0.5048679", "0.50263906", "0.50247186", "0.5013862", "0.500034...
0.78137916
0
Overrides the from_json method to deserialize the CourseTab objects from a jsonlike representation.
def from_json(self, values): self.validate_tabs(values) return [CourseTab.from_json(tab_dict) for tab_dict in values]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_json(tab_dict):\r\n sub_class_types = {\r\n 'courseware': CoursewareTab,\r\n 'course_info': CourseInfoTab,\r\n 'wiki': WikiTab,\r\n 'discussion': DiscussionTab,\r\n 'external_discussion': ExternalDiscussionTab,\r\n 'external_link': E...
[ "0.71116537", "0.5608602", "0.5492041", "0.54743767", "0.5423208", "0.541069", "0.5341958", "0.52665263", "0.52291095", "0.52248454", "0.52134323", "0.51871216", "0.5183182", "0.5169521", "0.51274395", "0.50873184", "0.50866884", "0.5086507", "0.50743467", "0.50580233", "0.50...
0.75752425
0
Asserts that the html generated by the `studio_view` view is correct for the supplied block
def assert_studio_view_valid_html(block, html): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_student_view_valid_html(block, html):\r\n pass", "def assert_studio_view_invalid_html(block, html):\r\n assert False, \"studio_view should produce valid html\"", "def assert_studio_view(block, fragment):\r\n try:\r\n html = lxml.html.fragment_fromstring(fragment.content)\r\n excep...
[ "0.81550205", "0.8050443", "0.7783626", "0.7692428", "0.7240709", "0.71940446", "0.6920114", "0.6879939", "0.68427247", "0.68058455", "0.6805143", "0.6800901", "0.6742836", "0.6736332", "0.6708364", "0.66887796", "0.6603679", "0.6603679", "0.6573001", "0.6573001", "0.6481818"...
0.86351585
0
Asserts that the html generated by the `studio_view` view is correct for the supplied block
def assert_studio_view_invalid_html(block, html): assert False, "studio_view should produce valid html"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_studio_view_valid_html(block, html):\r\n pass", "def assert_student_view_valid_html(block, html):\r\n pass", "def assert_studio_view(block, fragment):\r\n try:\r\n html = lxml.html.fragment_fromstring(fragment.content)\r\n except lxml.etree.ParserError:\r\n assert_studio_vi...
[ "0.8634515", "0.815477", "0.7784076", "0.7691771", "0.7242", "0.71949303", "0.69204485", "0.68808335", "0.684496", "0.68066996", "0.68045205", "0.68009865", "0.67438924", "0.67368567", "0.6709049", "0.66884273", "0.6605138", "0.6605138", "0.6573879", "0.6573879", "0.6481578",...
0.80494195
2
Helper function to assert that the `fragment` is valid output the specified `block`s `studio_view`
def assert_studio_view(block, fragment): try: html = lxml.html.fragment_fromstring(fragment.content) except lxml.etree.ParserError: assert_studio_view_invalid_html(block, fragment.content) else: assert_studio_view_valid_html(block, html)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_studio_view_valid_html(block, html):\r\n pass", "def assert_student_view(block, fragment):\r\n try:\r\n html = lxml.html.fragment_fromstring(fragment.content)\r\n except lxml.etree.ParserError:\r\n assert_student_view_invalid_html(block, fragment.content)\r\n else:\r\n ...
[ "0.72564584", "0.72531605", "0.7092045", "0.66398716", "0.6623806", "0.65054315", "0.6359715", "0.6359715", "0.63492846", "0.6051868", "0.6023491", "0.6022666", "0.5953618", "0.592662", "0.59047914", "0.59047914", "0.5867221", "0.5748623", "0.5733178", "0.5657606", "0.5604923...
0.8003223
0
With showanswer="past_due" should only show answer after the problem is closed for everyonee.g. after due date + grace period.
def test_showanswer_past_due(self): # can't see after attempts used up, even with due date in the future used_all_attempts = CapaFactory.create(showanswer='past_due', max_attempts="1", attempts="1", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_showanswer_default(self):\r\n # default, no due date, showanswer 'closed', so problem is open, and show_answer\r\n # not visible.\r\n problem = CapaFactory.create()\r\n self.assertFalse(problem.answer_available())", "def past_due(self):\n return self.state == self.STAT...
[ "0.69670767", "0.62138057", "0.61704504", "0.6160297", "0.60756606", "0.59044915", "0.5871378", "0.58649874", "0.58595836", "0.5844253", "0.5817951", "0.5720997", "0.5696027", "0.56543666", "0.5652984", "0.56491405", "0.5592568", "0.55633664", "0.5562324", "0.55272883", "0.55...
0.7920774
0
Check that may_certify correctly tells us when a course may wrap.
def test_may_certify(self): self.assertTrue(self.past_show_certs.may_certify()) self.assertTrue(self.past_noshow_certs.may_certify()) self.assertTrue(self.future_show_certs.may_certify()) self.assertFalse(self.future_noshow_certs.may_certify())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def may_certify(self):\r\n return self.certificates_show_before_end or self.has_ended()", "def validate_course_policy(module_store, course_id):\r\n # is there a reliable way to get the module location just given the course_id?\r\n warn_cnt = 0\r\n for module in module_store.modules[course_id].ite...
[ "0.6783614", "0.63133246", "0.62132454", "0.6053967", "0.60526514", "0.5886137", "0.5805113", "0.5677905", "0.5644085", "0.5617096", "0.5586786", "0.55596006", "0.55341417", "0.5489371", "0.5440506", "0.5415976", "0.535819", "0.53400505", "0.5322223", "0.5294252", "0.52831686...
0.7273606
0
Assert a number of conditions that must be true for `block` to be good.
def assert_xblocks_are_good(self, block): scope_ids = block.scope_ids self.assertIsNotNone(scope_ids.usage_id) self.assertIsNotNone(scope_ids.def_id) for child_id in block.children: child = block.runtime.get_block(child_id) self.assert_xblocks_are_good(chi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_block(self, block):\n pass", "def check_block(block):\n asides = block.runtime.get_asides(block)\n assert len(asides) == 1, f'Found {asides} asides but expected only test_aside'\n assert isinstance(asides[0], AsideTestType)\n category =...
[ "0.63454187", "0.60078126", "0.59535265", "0.5949494", "0.5922644", "0.5894551", "0.58413744", "0.58310854", "0.58134854", "0.5787228", "0.5784887", "0.5734746", "0.57320493", "0.5713013", "0.56817836", "0.56665826", "0.5652933", "0.56525123", "0.5649863", "0.5641986", "0.564...
0.6378562
0
Test we get a 404 when we don't GET or PUT
def test_lti20_unsupported_method_error(self): self.setup_system_xmodule_mocks_for_lti20_request_test() mock_request = self.get_signed_lti20_mock_request(self.GOOD_JSON_PUT) for bad_method in self.UNSUPPORTED_HTTP_METHODS: mock_request.method = bad_method response = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testNotFound(self):\n data = {'text': 'toto'}\n response = requests.put(url=self.invalid_url, json=data)\n headers = response.headers\n json_data = response.json()\n\n self.assertEqual(response.status_code, 404, WRONG_STATUS_CODE_MSG)\n self.assertEqual(\n h...
[ "0.7834553", "0.7664394", "0.7632061", "0.75503045", "0.7398227", "0.7294192", "0.72619766", "0.72440153", "0.71948844", "0.71932596", "0.71754545", "0.71687114", "0.7154305", "0.7151365", "0.71449274", "0.7131901", "0.7116995", "0.7053308", "0.7050866", "0.703935", "0.703711...
0.0
-1
Test that we get a 401 when header verification fails
def test_lti20_request_handler_bad_headers(self): self.setup_system_xmodule_mocks_for_lti20_request_test() self.xmodule.verify_lti_2_0_result_rest_headers = Mock(side_effect=LTIError()) mock_request = self.get_signed_lti20_mock_request(self.GOOD_JSON_PUT) response = self.xmodule.lti_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_401_response(self):\n mock = Mock()\n mock.status_code = 401\n\n with self.assertRaises(AuthError):\n check_response(mock)", "def test_unauthorized(self):\n self._error_test(fitbit_exceptions.HTTPUnauthorized)", "def test_unauthorized_exception(exception_app):\n ...
[ "0.7852", "0.7630532", "0.76169425", "0.7611051", "0.75710446", "0.7492745", "0.74897814", "0.74601537", "0.73968107", "0.73909837", "0.7384213", "0.7374583", "0.7374282", "0.73393625", "0.7325925", "0.7316605", "0.7313595", "0.73073655", "0.72572666", "0.72550297", "0.725502...
0.7388339
10
Test that we get a 404 when there's no (or badly formatted) user specified in the url
def test_lti20_request_handler_bad_dispatch_user(self): self.setup_system_xmodule_mocks_for_lti20_request_test() mock_request = self.get_signed_lti20_mock_request(self.GOOD_JSON_PUT) response = self.xmodule.lti_2_0_result_rest_handler(mock_request, None) self.assertEqual(response.sta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request_users_user_invalid_resource(self):\n response = requests.get(self.url + '/users/John/invalid')\n\n self.assertEqual(response.status_code, 404)", "def test_request_users_user_invalid(self):\n response = requests.get(self.url + '/users/invalid')\n\n self.assertEqual(res...
[ "0.7607052", "0.74047196", "0.7361166", "0.7124908", "0.7075741", "0.68808466", "0.68588334", "0.6829845", "0.68194526", "0.68117887", "0.67619216", "0.67417", "0.67187995", "0.6692933", "0.66922045", "0.6686699", "0.66431516", "0.6619435", "0.6597381", "0.65855545", "0.65818...
0.0
-1
Test that we get a 404 when json verification fails
def test_lti20_request_handler_bad_json(self): self.setup_system_xmodule_mocks_for_lti20_request_test() self.xmodule.parse_lti_2_0_result_json = Mock(side_effect=LTIError()) mock_request = self.get_signed_lti20_mock_request(self.GOOD_JSON_PUT) response = self.xmodule.lti_2_0_result_r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_json_data_throw_not_found_error(self):\n response = self.app.test_client().get('/test/get_json_data/99999')\n self.assertEqual(response.json['status'], 'failure')\n self.assertEqual(response.json['error'], 'Test not found')", "def testNotFound(self):\n response = requests...
[ "0.813259", "0.77942365", "0.77891874", "0.778844", "0.77330405", "0.7704023", "0.76398516", "0.75817454", "0.74765724", "0.7395625", "0.7379669", "0.737147", "0.73683184", "0.7348031", "0.7322908", "0.7264359", "0.7230101", "0.7218871", "0.72118676", "0.72104055", "0.7207346...
0.7176032
23
Test that we get a 404 when the supplied user does not exist
def test_lti20_request_handler_bad_user(self): self.setup_system_xmodule_mocks_for_lti20_request_test() self.system.get_real_user = Mock(return_value=None) mock_request = self.get_signed_lti20_mock_request(self.GOOD_JSON_PUT) response = self.xmodule.lti_2_0_result_rest_handler(mock_r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_user_404(self):\n resp = self.app.get('/users/thisuserdoesntexist')\n assert resp.status_code == 404", "def test_returns_404_if_user_doesnt_exist(self):\n # Act\n response = self.client.get(\"/api/v2/projects/queries/non_existent/touched/\")\n self.assertEqual(resp...
[ "0.85501176", "0.8504392", "0.8290125", "0.826329", "0.8255436", "0.80806535", "0.80696154", "0.799053", "0.78236765", "0.78197956", "0.7783803", "0.77730113", "0.77625686", "0.77509975", "0.76924", "0.76815456", "0.74781424", "0.74644864", "0.743018", "0.7429335", "0.7398514...
0.69276136
49
Request Authorization header has no value. This is an unknown service request, i.e., it is not a part of the original service specification.
def test_authorization_header_empty(self, get_key_secret): request = Request(self.environ) request.authorization = "bad authorization header" request.body = self.get_request_body() response = self.xmodule.grade_handler(request, '') real_response = self.get_response_values(re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_authorization_header_empty(self, _get_key_secret):\n request = Request(self.environ)\n request.authorization = \"bad authorization header\"\n request.body = self.get_request_body()\n response = self.xmodule.grade_handler(request, '')\n real_response = self.get_response_v...
[ "0.7190639", "0.70740837", "0.7053938", "0.69206196", "0.68703353", "0.66283286", "0.6526909", "0.6519208", "0.65063936", "0.6474814", "0.6427451", "0.63927", "0.6355573", "0.6321812", "0.6321812", "0.63100004", "0.6300273", "0.6272517", "0.624514", "0.6241907", "0.62278664",...
0.72020614
0
Tests that LTI parameter context_id is equal to course_id.
def test_context_id(self): self.assertEqual(self.system.course_id.to_deprecated_string(), self.xmodule.context_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_context_id(self):\n assert str(self.system.course_id) == self.xmodule.context_id", "def verify_course(self, course, course_id='edX/toy/2012_Fall'):\n assert course_id == str(course.id)", "def test_course_filter(self):\n user = self.make_user()\n enrollment = EnrollmentFacto...
[ "0.7922114", "0.7152441", "0.65048265", "0.6160573", "0.6051045", "0.6012263", "0.59553283", "0.5949394", "0.5751065", "0.5742978", "0.57279915", "0.5715011", "0.56983054", "0.5660396", "0.5651517", "0.5636871", "0.5605565", "0.5605334", "0.5599952", "0.5582131", "0.5577095",...
0.731177
1
Get the instance state dict
def test_get_instance_state(self): self.peer_grading.get_instance_state()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getstate__(self):\n return self.__dict__", "def __getstate__(self):\n\n state = {}\n for key in self.__slots__:\n state[key] = getattr(self, key)\n\n return state", "def get_state(self) -> dict:\n return {\n \"name\": self.name,\n \"name...
[ "0.8227891", "0.8178968", "0.81671953", "0.8103271", "0.80877984", "0.80877984", "0.8083822", "0.80594534", "0.803867", "0.7999772", "0.79888046", "0.78941226", "0.78841585", "0.7884015", "0.7859658", "0.7834527", "0.780188", "0.77361244", "0.7692266", "0.76921254", "0.767610...
0.0
-1
Test to see if a descriptor with an ItemNotFound error when trying to get its linked module behaves properly.
def test_descriptor_with_item_not_found(self): self._get_descriptor_with_invalid_link(ItemNotFoundError)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_descriptor_with_nopath(self):\r\n\r\n self._get_descriptor_with_invalid_link(NoPathToItem)", "def test_broken_error_descriptor(self):\r\n with self.assertRaises(TestException):\r\n module = self.descriptor._xmodule", "def _get_descriptor_with_invalid_link(self, exception_to_ra...
[ "0.7159248", "0.70729786", "0.68406785", "0.659168", "0.658644", "0.62692666", "0.6208487", "0.617717", "0.61051476", "0.60776305", "0.60373366", "0.6026367", "0.60145485", "0.5913795", "0.59131455", "0.58811945", "0.58782256", "0.5872372", "0.58643377", "0.584044", "0.582359...
0.8673435
0
Test a course with tabs configured but without a discussion tab
def test_tabs_without_discussion(self): self.settings.FEATURES['ENABLE_DISCUSSION_SERVICE'] = True self.check_discussion( tab_list=self.tabs_without_discussion, expected_discussion_link=not None, expected_can_display_value=False, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dashboard_no_courses(self):\r\n self.auth_page.visit()\r\n self.dashboard_page.visit()", "def test_tabs_with_discussion(self):\r\n self.settings.FEATURES['ENABLE_DISCUSSION_SERVICE'] = True\r\n self.check_discussion(\r\n tab_list=self.tabs_with_discussion,\r\n ...
[ "0.7184634", "0.7151695", "0.69192004", "0.68143964", "0.6593743", "0.6565447", "0.6560973", "0.65398455", "0.64714164", "0.6393442", "0.6354645", "0.6344383", "0.6300744", "0.629076", "0.62906486", "0.62496024", "0.6221416", "0.6210183", "0.61902857", "0.6186057", "0.6161021...
0.7383977
0
Test no due date.
def test_no_due_date(self): node = object() self.assertEqual(self.call_fut(node), None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def past_due(self):\n return self.due_date and self.due_date < datetime.utcnow()", "def _is_past_due(self):\n if self.due is None:\n return False\n\n if timezone.now() > self.due:\n return True", "def is_past_due(self):\n return self.due_date < timezone.now()",...
[ "0.6930805", "0.68681216", "0.6771246", "0.67354906", "0.667936", "0.6644642", "0.66312075", "0.6598844", "0.65437335", "0.6531998", "0.6504827", "0.6482573", "0.6462784", "0.64073735", "0.63681316", "0.631711", "0.63160115", "0.6314741", "0.630462", "0.6246658", "0.6238684",...
0.75157344
0
Test the rendering of the student view.
def test_render_student_view(self): html = self.module_system.render(self.vertical, 'student_view', {}).content self.assertIn(self.test_html_1, html) self.assertIn(self.test_html_2, html)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_student_view(self):\n # pylint: disable=protected-access\n student_view = self.xblock.student_view()\n student_view_html = student_view.content\n self.assertIn(self.xblock.get_attempts_message(), student_view_html)\n self.assertIn(self.xblock.display_name, student_view_h...
[ "0.8262079", "0.7536749", "0.7418994", "0.7328344", "0.68831056", "0.68831056", "0.6842372", "0.68409306", "0.68409306", "0.67806494", "0.6741908", "0.6719433", "0.67174965", "0.6618989", "0.65939075", "0.6587468", "0.65329236", "0.65295374", "0.64928454", "0.64735246", "0.64...
0.8488358
0
Flatten a dict from cls > [fields, ...] and yields values of the form (cls, fields) for each entry in the dictionary value.
def flatten(class_dict): for cls, fields_list in class_dict.items(): for fields in fields_list: yield (cls, fields)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterate_over_fields(cls):\n for attr in dir(cls):\n clsattr = getattr(cls, attr)\n if isinstance(clsattr, BaseField):\n yield attr, clsattr", "def classIterator(classIter):\n for attribute, value in classIter.__dict__.iteritems():\n yield attribute, value...
[ "0.65474945", "0.63139", "0.6111041", "0.6078096", "0.60221606", "0.595208", "0.59164363", "0.58520657", "0.57993263", "0.57899624", "0.56738156", "0.5619137", "0.56171674", "0.56165504", "0.5605291", "0.5592314", "0.5550517", "0.55351824", "0.55213827", "0.55139935", "0.5453...
0.8378496
0
Assert that both student_view and get_html render the same.
def check_property(self, descriptor): self.assertEqual( descriptor._xmodule.get_html(), descriptor.render('student_view').content )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_render_student_view(self):\r\n html = self.module_system.render(self.vertical, 'student_view', {}).content\r\n self.assertIn(self.test_html_1, html)\r\n self.assertIn(self.test_html_2, html)", "def test_student_view(self):\n # pylint: disable=protected-access\n student...
[ "0.844235", "0.78461826", "0.7325946", "0.7113012", "0.7102766", "0.70949227", "0.6866544", "0.6866544", "0.6844828", "0.6809082", "0.677154", "0.677154", "0.6657015", "0.6582918", "0.65099454", "0.64731437", "0.6456018", "0.6385331", "0.6382244", "0.63272005", "0.6324332", ...
0.6475028
15
Asserts input value is returned for None or something that is not a string. For all types, 'null' is also always returned as None.
def assertDeserializeNonString(self): self.assertDeserializeEqual(None, None) self.assertDeserializeEqual(3.14, 3.14) self.assertDeserializeEqual(True, True) self.assertDeserializeEqual([10], [10]) self.assertDeserializeEqual({}, {}) self.assertDeserializeEqual([], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testIsNullTrueAgain(self):\n val = is_null('') \n self.assertTrue(val)", "def testIsNullTrue(self):\n val = is_null(\"\") \n self.assertTrue(val)", "def _str_validator(arg):\n if arg is None or arg is '' or type(arg) != str:\n raise ValueError('Incorr...
[ "0.706667", "0.69587487", "0.6909714", "0.6852868", "0.67765933", "0.6735922", "0.6734802", "0.6690444", "0.6690178", "0.6659383", "0.65629256", "0.6542498", "0.6501961", "0.6474271", "0.64556164", "0.6431954", "0.6398344", "0.63532066", "0.6350719", "0.6334706", "0.63224036"...
0.595896
79
Return the stringified version of the generated xml
def xml_string(self): if self._xml_string is not None: return self._xml_string return etree.tostring(self._xml_node)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xml_string(self):\n if self._xml_string is not None:\n return self._xml_string\n\n return etree.tostring(self._xml_node)", "def get_xml(self):\n return etree.tostring(self.get_etree())", "def __str__(self):\n result = xml.dom.minidom.parseString(\n xml.etree.Elemen...
[ "0.75533724", "0.75093937", "0.73519486", "0.7305151", "0.7270105", "0.7247037", "0.7233472", "0.7179993", "0.6997982", "0.6933634", "0.6902677", "0.6804051", "0.67816865", "0.6749053", "0.67372775", "0.6714559", "0.6683492", "0.6683492", "0.6599032", "0.6549627", "0.6547702"...
0.75306624
1
Generate proper filename for storage.
def subs_filename(subs_id, lang='en'): if lang == 'en': return u'subs_{0}.srt.sjson'.format(subs_id) else: return u'{0}_subs_{1}.srt.sjson'.format(lang, subs_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_object_storage_name(checksum, filename, default_ext=''):\n h = checksum\n basename, actual_ext = os.path.splitext(filename)\n ext = actual_ext if actual_ext else default_ext\n\n # Use / instead of os.path.join as Windows makes this \\\\\n directory = \"/\".join([settings.STORAGE_ROOT, h...
[ "0.7778935", "0.7761019", "0.768247", "0.7665403", "0.75529724", "0.7473607", "0.74504334", "0.7331525", "0.7328498", "0.72739685", "0.72433144", "0.7230905", "0.72097486", "0.71922475", "0.7180632", "0.7126684", "0.71216315", "0.7114514", "0.7098584", "0.7092928", "0.7090580...
0.0
-1
Creates an instance of this descriptor from the supplied xml_data. This may be overridden by subclasses
def from_xml(cls, xml_data, system, id_generator): xml_object = etree.fromstring(xml_data) url_name = xml_object.get('url_name', xml_object.get('slug')) block_type = 'video' definition_id = id_generator.create_definition(block_type, url_name) usage_id = id_generator.create_u...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_xml(cls, xml_data, system, id_generator):\r\n raise NotImplementedError('Modules must implement from_xml to be parsable from xml')", "def from_xml(cls, xml_data, system, id_generator):\r\n\r\n xml_object = etree.fromstring(xml_data)\r\n # VS[compat] -- just have the url_name lookup,...
[ "0.73408526", "0.7005306", "0.69459045", "0.6879055", "0.67644304", "0.6368884", "0.63268465", "0.62995803", "0.62804395", "0.6258567", "0.6251504", "0.6251504", "0.6251504", "0.62447244", "0.62004364", "0.61400247", "0.6116172", "0.61040455", "0.6095235", "0.6076624", "0.602...
0.63083524
7
Create a string of Youtube IDs from `module`'s metadata attributes. Only writes a speed if an ID is present in the module. Necessary for backwards compatibility with XMLbased courses.
def create_youtube_string(module): youtube_ids = [ module.youtube_id_0_75, module.youtube_id_1_0, module.youtube_id_1_25, module.youtube_id_1_5 ] youtube_speeds = ['0.75', '1.00', '1.25', '1.50'] return ','.join([ ':'.join(pair) for pair ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_youtube_ids(self):\r\n item = modulestore().get_item(self.video_usage_key)\r\n\r\n return {\r\n 0.75: item.youtube_id_0_75,\r\n 1: item.youtube_id_1_0,\r\n 1.25: item.youtube_id_1_25,\r\n 1.5: item.youtube_id_1_5\r\n }", "def get_course_you...
[ "0.5561011", "0.5037911", "0.4738613", "0.47211576", "0.47087416", "0.46858904", "0.45949882", "0.45653906", "0.45202488", "0.451492", "0.4506048", "0.44814146", "0.4422248", "0.43981278", "0.43981105", "0.43781415", "0.43645257", "0.43614745", "0.43111795", "0.43047047", "0....
0.73852116
0
Convert words dictionary for client API.
def prepare_words(self, top_words, total_count): list_to_return = [] percents = 0 for num, word_tuple in enumerate(top_words.iteritems()): if num == len(top_words) - 1: percent = 100 - percents else: percent = round(100.0 * word_tupl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_words_from_dict(self, kind: str, fn: str, words: Any) -> None:\n for word in words or []:\n self.words.add(word)\n self.words.add(word.lower())", "def convert(self, word, readings={}):\r\n readingsMap = self.processReadings(readings)\r\n return convert(word, [re...
[ "0.62326586", "0.6160226", "0.61337864", "0.611224", "0.6038828", "0.60357934", "0.60186785", "0.5983747", "0.59805477", "0.5974115", "0.5865606", "0.58583474", "0.5834701", "0.5832293", "0.577437", "0.57722574", "0.57548565", "0.5739607", "0.5737952", "0.57377934", "0.571727...
0.0
-1
Return a string version of the value (where value is the JSONformatted, internally stored value). If the value is a string, then we simply return what was passed in. Otherwise, we return json.dumps on the input value.
def serialize_field(value): if isinstance(value, basestring): return value return json.dumps(value, cls=EdxJSONEncoder)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jsonify(value):\n return (\n json.JSONEncoder().encode(value) if type(value) is not str else value\n )", "def to_json(self, value):\n # force parsing of strings into correct json structures\n if isinstance(value, str):\n value = self.to_dict(value)\n return json.d...
[ "0.8274088", "0.7944534", "0.77294314", "0.766899", "0.7646635", "0.75742906", "0.7546013", "0.74878764", "0.748543", "0.7474429", "0.7425075", "0.74179596", "0.7408339", "0.733402", "0.7239838", "0.7152065", "0.71495", "0.7142402", "0.7124554", "0.70947206", "0.7074509", "...
0.7597283
5
Creates an instance of this descriptor from the supplied xml_data. This may be overridden by subclasses
def from_xml(cls, xml_data, system, id_generator): xml_object = etree.fromstring(xml_data) # VS[compat] -- just have the url_name lookup, once translation is done url_name = xml_object.get('url_name', xml_object.get('slug')) def_id = id_generator.create_definition(xml_object.tag, u...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_xml(cls, xml_data, system, id_generator):\r\n raise NotImplementedError('Modules must implement from_xml to be parsable from xml')", "def from_xml(cls, xml_data, system, id_generator):\r\n\r\n xml_object = etree.fromstring(xml_data)\r\n system.error_tracker('WARNING: the <{tag}> tag...
[ "0.7340154", "0.6944314", "0.6877584", "0.6762509", "0.636915", "0.6326981", "0.63084656", "0.6299853", "0.6280788", "0.6258931", "0.6251616", "0.6251616", "0.6251616", "0.62448657", "0.6199424", "0.6139214", "0.6116848", "0.61039835", "0.6094513", "0.60741806", "0.60285854",...
0.70042956
1
Return the XBlock runtime (backwards compatibility alias provided for XModules).
def system(self): return self.runtime
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _xmodule(self):\r\n if self.xmodule_runtime is None:\r\n raise UndefinedContext()\r\n assert self.xmodule_runtime.error_descriptor_class is not None\r\n if self.xmodule_runtime.xmodule_instance is None:\r\n try:\r\n self.xmodule_runtime.construct_xblock...
[ "0.6151863", "0.5921588", "0.5921588", "0.58006346", "0.57755893", "0.56982213", "0.56444144", "0.56444144", "0.5636773", "0.5636773", "0.5633604", "0.56003857", "0.5576458", "0.5492152", "0.5474717", "0.538309", "0.53357786", "0.52632445", "0.52558035", "0.5251784", "0.51856...
0.5961139
1
Retrieves the internal KeyValueStore for this XModule. Should only be used by the persistence layer. Use with caution.
def xblock_kvs(self): # if caller wants kvs, caller's assuming it's up to date; so, decache it self.save() return self._field_data._kvs # pylint: disable=protected-access
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kv(self):\n return self._kv_store", "def _get_store(self):\n return self._store", "def getSessionStore(self):\n pass", "def configStore(self):\n return getattr(self._data.configStore, self._name)", "def dict(self):\n return self.store", "def store(self):\n re...
[ "0.73674566", "0.64506495", "0.6398443", "0.61388844", "0.6032344", "0.58999115", "0.58696496", "0.5770434", "0.57686156", "0.57028663", "0.56944853", "0.56757975", "0.5546411", "0.5525141", "0.5507821", "0.54967916", "0.54890394", "0.5451692", "0.53882366", "0.5378055", "0.5...
0.5031858
48
Creates an instance of this descriptor from the supplied xml_data. This may be overridden by subclasses.
def from_xml(cls, xml_data, system, id_generator): raise NotImplementedError('Modules must implement from_xml to be parsable from xml')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_xml(cls, xml_data, system, id_generator):\r\n\r\n xml_object = etree.fromstring(xml_data)\r\n # VS[compat] -- just have the url_name lookup, once translation is done\r\n url_name = xml_object.get('url_name', xml_object.get('slug'))\r\n def_id = id_generator.create_definition(xm...
[ "0.6957737", "0.69423026", "0.68545395", "0.6751757", "0.63542086", "0.631036", "0.6295638", "0.62905246", "0.6284573", "0.6273534", "0.6273534", "0.6273534", "0.6253839", "0.6251651", "0.62199396", "0.6152068", "0.6139092", "0.61332154", "0.6129593", "0.60679096", "0.6033999...
0.72833675
0