code
stringlengths
1
18.2k
def clear_target_names(self, target_id): """stub""" if self.get_targets_metadata().is_read_only(): raise NoAccess() updated_targets = [] for current_target in self.my_osid_object_form._my_map['targets']: if current_target['id'] != target_id: updated_targets.append(current_target) else: updated_targets.append({ 'id': cu...
def remove_target(self, target_id): """remove a target, given the id""" updated_targets = [] for target in self.my_osid_object_form._my_map['targets']: if target['id'] != target_id: updated_targets.append(target) self.my_osid_object_form._my_map['targets'] = updated_targets
def set_target_order(self, target_ids): """ reorder targets per the passed in list :param target_ids: :return: """ reordered_targets = [] current_target_ids = [t['id'] for t in self.my_osid_object_form._my_map['targets']] if set(target_ids) != set(current_target_ids): raise IllegalState('target_ids do not match existin...
def add_zone(self, spatial_unit, container_id, name='', description='', visible=True, reuse=0, drop_behavior_type=None): """container_id is a targetId that the zone belongs to """ if not isinstance(spatial_unit, abc_mapping_primitives.SpatialUnit): raise InvalidArgument('zone is not a SpatialUnit') # if not isinstance(...
def clear_zones(self): """stub""" if self.get_zones_metadata().is_read_only(): raise NoAccess() self.my_osid_object_form._my_map['zones'] = \ self._zones_metadata['default_object_values'][0]
def remove_zone(self, zone_id): """remove a zone, given the id""" updated_zones = [] for zone in self.my_osid_object_form._my_map['zones']: if zone['id'] != zone_id: updated_zones.append(zone) self.my_osid_object_form._my_map['zones'] = updated_zones
def set_zone_order(self, zone_ids): """ reorder zones per the passed in list :param zone_ids: :return: """ reordered_zones = [] current_zone_ids = [z['id'] for z in self.my_osid_object_form._my_map['zones']] if set(zone_ids) != set(current_zone_ids): raise IllegalState('zone_ids do not match existing zones') for zone_i...
def string_class(cls): """Define __unicode__ and __str__ methods on the given class in Python 2. The given class must define a __str__ method returning a unicode string, otherwise a TypeError is raised. Under Python 3, the class is returned as is. """ if not PY3: if '__str__' not in cls.__dict__: raise TypeError('the g...
def from_verb(cls, verb): """ Constructs a :class:`Spoolverb` instance from the string representation of the given verb. Args: verb (str): representation of the verb e.g.: ``'ASCRIBESPOOL01LOAN12/150526150528'``. Can also be in binary format (:obj:`bytes`): ``b'ASCRIBESPOOL01PIECE'``. Returns: :class:`Spoolverb` instan...
return cls(meta=meta, version=version, action=action) else: edition_num = data['arg1'] return cls(meta=meta, version=version, action=action, edition_num=int(edition_num))
def loan(self): """ str: representation of the ``LOAN`` spoolverb. E.g.: ``'ASCRIBESPOOL01LOAN1/150526150528'``. """ return '{}{}LOAN{}/{}{}'.format(self.meta, self.version, self.edition_number, self.loan_start, self.loan_end)
def get_objective_lookup_session(self): """Gets the OsidSession associated with the objective lookup service. return: (osid.learning.ObjectiveLookupSession) - an ObjectiveLookupSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective_lookup() is false compliance: optional - ...
def get_objective_lookup_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the objective lookup service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ObjectiveLookupSession) - an ObjectiveLookupSession...
def get_objective_query_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the objective query service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ObjectiveQuerySession) - an ObjectiveQuerySession rai...
def get_objective_search_session(self): """Gets the OsidSession associated with the objective search service. return: (osid.learning.ObjectiveSearchSession) - an ObjectiveSearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective_search() is false compliance: optional - ...
def get_objective_search_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the objective search service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ObjectiveSearchSession) - an ObjectiveSearchSession...
def get_objective_admin_session(self): """Gets the OsidSession associated with the objective administration service. return: (osid.learning.ObjectiveAdminSession) - an ObjectiveAdminSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective_admin() is false compliance: optiona...
def get_objective_admin_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the objective admin service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ObjectiveAdminSession) - an ObjectiveAdminSession rai...
def get_objective_hierarchy_session_for_objective_bank(self, objective_bank_id=None, *args, **kwargs): """Gets the OsidSession associated with the objective hierarchy traversal service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ObjectiveHierarchy...
def get_objective_hierarchy_design_session(self): """Gets the session for designing objective hierarchies. return: (osid.learning.ObjectiveHierarchyDesignSession) - an ObjectiveHierarchyDesignSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective_hierarchy_design() is fals...
def get_objective_hierarchy_design_session_for_objective_bank(self, objective_bank_id=None, *args, **kwargs): """Gets the OsidSession associated with the objective hierarchy design service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ObjectiveHiera...
def get_objective_requisite_session(self): """Gets the session for examining objective requisites. return: (osid.learning.ObjectiveRequisiteSession) - an ObjectiveRequisiteSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective_requisite() is false compliance: optional - Th...
def get_objective_requisite_session_for_objective_bank(self, objective_bank_id=None, *args, **kwargs): """Gets the OsidSession associated with the objective sequencing service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ObjectiveRequisiteSession) ...
def get_objective_requisite_assignment_session(self, *args, **kwargs): """Gets the session for managing objective requisites. return: (osid.learning.ObjectiveRequisiteAssignmentSession) - an ObjectiveRequisiteAssignmentSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective...
def get_activity_search_session(self): """Gets the OsidSession associated with the activity search service. return: (osid.learning.ActivitySearchSession) - a ActivitySearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_activity_search() is false compliance: optional - This m...
def get_activity_search_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the activity search service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ActivitySearchSession) - an ActivitySearchSession rai...
def get_activity_admin_session(self): """Gets the OsidSession associated with the activity administration service. return: (osid.learning.ActivityAdminSession) - a ActivityAdminSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_activity_admin() is false compliance: optional - Th...
def get_activity_admin_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the activity admin service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.ActivityAdminSession) - an ActivityAdminSession raise: ...
def get_proficiency_lookup_session(self): """Gets the OsidSession associated with the proficiency lookup service. return: (osid.learning.ProficiencyLookupSession) - a ProficiencyLookupSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_proficiency_lookup() is false compliance: op...
def get_proficiency_lookup_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the proficiency lookup service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the obective bank return: (osid.learning.ProficiencyLookupSession) - a ProficiencyLookupS...
def get_proficiency_admin_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the proficiency administration service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the ObjectiveBank return: (osid.learning.ProficiencyAdminSession) - a ProficiencyA...
def get_learning_path_session(self): """Gets the OsidSession associated with the learning path service. return: (osid.learning.LearningPathSession) - a LearningPathSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_learning_path() is false compliance: optional - This method must...
def get_learning_path_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the learning path service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the ObjectiveBank return: (osid.learning.LearningPathSession) - a LearningPathSession raise: NotFou...
def get_objective_bank_lookup_session(self, *args, **kwargs): """Gets the OsidSession associated with the objective bank lookup service. return: (osid.learning.ObjectiveBankLookupSession) - an ObjectiveBankLookupSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective_bank_l...
def get_objective_bank_hierarchy_design_session(self): """Gets the session designing objective bank hierarchies. return: (osid.learning.ObjectiveBankHierarchyDesignSession) - an ObjectiveBankHierarchyDesignSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_objective_bank_hierarc...
def get_objective_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the objective lookup service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveLookupSession`` :rtype: ``osid.learning.ObjectiveLookupSession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`` :rais...
def get_objective_lookup_session_for_objective_bank(self, objective_bank_id, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the objective lookup service for the given objective bank. :param objective_bank_id: the ``Id`` of the objective bank :type objective_bank_id: ``osid.id.Id`` :param proxy: a ...
def get_objective_query_session(self, proxy): """Gets the ``OsidSession`` associated with the objective query service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveQuerySession`` :rtype: ``osid.learning.ObjectiveQuerySession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`` :raise: `...
def get_objective_admin_session(self, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the objective administration service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveAdminSession`` :rtype: ``osid.learning.ObjectiveAdminSession`` :raise: ``NullArgument`` -- ``pro...
def get_objective_admin_session_for_objective_bank(self, objective_bank_id, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the objective admin service for the given objective bank. :param objective_bank_id: the ``Id`` of the objective bank :type objective_bank_id: ``osid.id.Id`` :param proxy: a pr...
def get_objective_hierarchy_session(self, proxy): """Gets the session for traversing objective hierarchies. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveHierarchySession`` :rtype: ``osid.learning.ObjectiveHierarchySession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`` :raise: ``Op...
def get_objective_sequencing_session(self, proxy): """Gets the session for sequencing objectives. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveSequencingSession`` :rtype: ``osid.learning.ObjectiveSequencingSession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`` :raise: ``OperationF...
def get_objective_sequencing_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the objective sequencing service for the given objective bank. :param objective_bank_id: the ``Id`` of the objective bank :type objective_bank_id: ``osid.id.Id`` :param proxy: a proxy :ty...
def get_objective_objective_bank_session(self, proxy): """Gets the session for retrieving objective to objective bank mappings. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveObjectiveBankSession`` :rtype: ``osid.learning.ObjectiveObjectiveBankSession`` :raise: ``NullArgument`` -- ``prox...
def get_objective_objective_bank_assignment_session(self, proxy): """Gets the session for assigning objective to objective bank mappings. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveObjectiveBankAssignmentSession`` :rtype: ``osid.learning.ObjectiveObjectiveBankAssignmentSession`` :rai...
def get_objective_requisite_assignment_session_for_objective_bank(self, objective_bank_id, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the objective sequencing service for the given objective bank. :param objective_bank_id: the ``Id`` of the objective bank :type objective_bank_id: ``osid.id.Id`...
def get_activity_lookup_session(self, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the activity lookup service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ActivityLookupSession`` :rtype: ``osid.learning.ActivityLookupSession`` :raise: ``NullArgument`` -- ``proxy`` is `...
def get_activity_lookup_session_for_objective_bank(self, objective_bank_id, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the activity lookup service for the given objective bank. :param objective_bank_id: the ``Id`` of the objective bank :type objective_bank_id: ``osid.id.Id`` :param proxy: a pr...
def get_activity_query_session(self, proxy): """Gets the ``OsidSession`` associated with the activity query service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ActivityQuerySession`` :rtype: ``osid.learning.ActivityQuerySession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`` :raise: ``Ope...
def get_activity_query_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the activity query service for the given objective bank. :param objective_bank_id: the ``Id`` of the objective bank :type objective_bank_id: ``osid.id.Id`` :param proxy: a proxy :type proxy: ``...
def get_activity_admin_session(self, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the activity administration service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ActivityAdminSession`` :rtype: ``osid.learning.ActivityAdminSession`` :raise: ``NullArgument`` -- ``proxy``...
def get_activity_admin_session_for_objective_bank(self, objective_bank_id, proxy, *args, **kwargs): """Gets the ``OsidSession`` associated with the activity admin service for the given objective bank. :param objective_bank_id: the ``Id`` of the objective bank :type objective_bank_id: ``osid.id.Id`` :param proxy: a prox...
def get_activity_objective_bank_session(self, proxy): """Gets the session for retrieving activity to objective bank mappings. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ActivityObjectiveBankSession`` :rtype: ``osid.learning.ActivityObjectiveBankSession`` :raise: ``NullArgument`` -- ``proxy`` ...
def get_activity_objective_bank_assignment_session(self, proxy): """Gets the session for assigning activity to objective bank mappings. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ActivityObjectiveBankAssignmentSession`` :rtype: ``osid.learning.ActivityObjectiveBankAssignmentSession`` :raise: ...
def get_proficiency_query_session(self, proxy): """Gets the ``OsidSession`` associated with the proficiency query service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``ProficiencyQuerySession`` :rtype: ``osid.learning.ProficiencyQuerySession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`` :r...
def get_proficiency_query_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the proficiency query service for the given objective bank. :param objective_bank_id: the ``Id`` of the obective bank :type objective_bank_id: ``osid.id.Id`` :param proxy: a proxy :type prox...
def get_proficiency_search_session(self, proxy): """Gets the ``OsidSession`` associated with the proficiency search service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``ProficiencySearchSession`` :rtype: ``osid.learning.ProficiencySearchSession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`...
def get_proficiency_search_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the proficiency search service for the given objective bank. :param objective_bank_id: the ``Id`` of the ``ObjectiveBank`` :type objective_bank_id: ``osid.id.Id`` :param proxy: a proxy :typ...
def get_proficiency_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the proficiency administration service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``ProficiencyAdminSession`` :rtype: ``osid.learning.ProficiencyAdminSession`` :raise: ``NullArgument`` -- ``proxy`` is ``...
def get_proficiency_objective_bank_session(self, proxy): """Gets the ``OsidSession`` to lookup proficiency/objective bank mappings. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``ProficiencyObjectiveBankSession`` :rtype: ``osid.learning.ProficiencyObjectiveBankSession`` :raise: ``NullArgument`` --...
def get_proficiency_objective_bank_assignment_session(self, proxy): """Gets the ``OsidSession`` associated with assigning proficiencies to objective banks. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``ProficiencyObjectiveBankAssignmentSession`` :rtype: ``osid.learning.ProficiencyObjectiveBankAss...
def get_my_learning_path_session(self, proxy): """Gets the ``OsidSession`` associated with the my learning path service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``MyLearningPathSession`` :rtype: ``osid.learning.MyLearningPathSession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`` :raise: ...
def get_my_learning_path_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the my learning path service for the given objective bank. :param objective_bank_id: the ``Id`` of the ``ObjectiveBank`` :type objective_bank_id: ``osid.id.Id`` :param proxy: a proxy :type pr...
def get_objective_bank_query_session(self, proxy): """Gets the OsidSession associated with the objective bank query service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveBankQuerySession`` :rtype: ``osid.learning.ObjectiveBankQuerySession`` :raise: ``NullArgument`` -- ``proxy`` is ``nu...
def get_objective_bank_search_session(self, proxy): """Gets the OsidSession associated with the objective bank search service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveBankSearchSession`` :rtype: ``osid.learning.ObjectiveBankSearchSession`` :raise: ``NullArgument`` -- ``proxy`` is ...
def get_objective_bank_admin_session(self, proxy, *args, **kwargs): """Gets the OsidSession associated with the objective bank administration service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveBankAdminSession`` :rtype: ``osid.learning.ObjectiveBankAdminSession`` :raise: ``NullArgum...
def get_objective_bank_hierarchy_session(self, proxy): """Gets the session traversing objective bank hierarchies. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveBankHierarchySession`` :rtype: ``osid.learning.ObjectiveBankHierarchySession`` :raise: ``NullArgument`` -- ``proxy`` is ``null`...
def register_piece(self, from_address, to_address, hash, password, min_confirmations=6, sync=False, ownership=True): """ Register a piece Args: from_address (Tuple[str]): Federation address. All register transactions originate from the the Federation wallet to_address (str): Address registering the edition hash (Tuple[...
id """ file_hash, file_hash_metadata = hash path, from_address = from_address verb = Spoolverb() unsigned_tx = self.simple_spool_transaction(from_address, [file_hash, file_hash_metadata, to_address], op_return=verb.piece, min_confirmations=min_confirmations) signed_tx = self._t.sign_transaction(unsigned_tx, password) t...
def refill_main_wallet(self, from_address, to_address, nfees, ntokens, password, min_confirmations=6, sync=False): """ Refill the Federation wallet with tokens and fees. This keeps the federation wallet clean. Dealing with exact values simplifies the transactions. No need to calculate change. Easier to keep track of th...
Number of confirmations when chosing the inputs of the transaction. Defaults to 6 sync (bool): Perform the transaction in synchronous mode, the call to the function will block until there is at least on confirmation on the blockchain. Defaults to False Returns: str: transaction id """ path, from_address = from_address ...
def refill(self, from_address, to_address, nfees, ntokens, password, min_confirmations=6, sync=False): """ Refill wallets with the necessary fuel to perform spool transactions Args: from_address (Tuple[str]): Federation wallet address. Fuels the wallets with tokens and fees. All transactions to wallets holding a partic...
synchronous mode, the call to the function will block until there is at least on confirmation on the blockchain. Defaults to False Returns: str: transaction id """ path, from_address = from_address verb = Spoolverb() # nfees + 1: nfees to refill plus one fee for the refill transaction itself inputs = self.select_inputs...
def simple_spool_transaction(self, from_address, to, op_return, min_confirmations=6): """ Utililty function to create the spool transactions. Selects the inputs, encodes the op_return and constructs the transaction. Args: from_address (str): Address originating the transaction to (str): list of addresses to receive tok...
def select_inputs(self, address, nfees, ntokens, min_confirmations=6): """ Selects the inputs for the spool transaction. Args: address (str): bitcoin address to select inputs for nfees (int): number of fees ntokens (int): number of tokens min_confirmations (Optional[int]): minimum number of required confirmations; defa...
for fee in fees] [self._spents.put(token) for token in tokens] return fees + tokens
def get_edxml(self): """stub""" if self.has_raw_edxml(): has_python = False my_files = self.my_osid_object.object_map['fileIds'] raw_text = self.get_text('edxml').text soup = BeautifulSoup(raw_text, 'xml') # replace all file listings with an appropriate path... attrs = { 'draggable': 'icon', 'drag_and_drop_input': 'img...
has_python: return str(soup.find('problem')) else: return soup.find('problem').prettify() except Exception: # if the edxml is not valid XML, it will not parse properly in soup # return just the raw edxml return self.get_text('edxml').text else: # have to construct the edxml from various components obj_map = self.my_osi...
soup.new_tag('multiplechoiceresponse') problem.append(multichoice) choicegroup = soup.new_tag('choicegroup') choicegroup['direction'] = 'vertical' multichoice.append(choicegroup) choices = question['choices'] for choice in choices: new_choice = soup.new_tag('choice') # mark the correct choice(s) if choice['id'] in answ...
def get_edxml_with_aws_urls(self): """stub""" edxml = self.get_edxml() soup = BeautifulSoup(edxml, 'xml') attrs = { 'draggable': 'icon', 'drag_and_drop_input': 'img', 'files': 'included_files', 'img': 'src' } # replace all file listings with an appropriate path... if len(self.my_osid_object.object_map['fileIds']) > 0: ...
def get_xproblem(self, parameters=None): """stub""" if not self.get_text('python_script'): return self.get_text('edxml').text if not parameters: parameters = self.get_parameters() return self._get_parameterized_text(parameters)
def get_solution(self, parameters=None): """stub""" if not self.has_solution(): raise IllegalState() try: if not self.get_text('python_script'): return self.get_text('solution').text if not parameters: parameters = self.get_parameters() return self._get_parameterized_text(parameters) except Exception: return self.get_t...
def get_parameters(self): """stub""" if not self.is_parameterized(): raise IllegalState() if not self.get_text('python_script'): return dict() import imp from types import ModuleType, FunctionType script_module = imp.new_module('script_module') exec(self.get_text('python_script').text, script_module.__dict__) params = ...
def _get_parameterized_text(self, parameters): """stub""" text = self.get_text('edxml').text done = False while not done: result = re.search(r'\$\w+', text) if result: replacement = str(parameters[result.group()[1:]]) text = text.replace(result.group(), replacement) else: done = True return text
def _init_map(self): """Have to call these all separately because they are "end" classes, with no super() in them. Non-cooperative.""" ItemTextsFormRecord._init_map(self) ItemFilesFormRecord._init_map(self) edXBaseFormRecord._init_map(self) IRTItemFormRecord._init_map(self) TimeValueFormRecord._init_map(self) Provenanc...
def _init_metadata(self): """Have to call these all separately because they are "end" classes, with no super() in them. Non-cooperative.""" ItemTextsFormRecord._init_metadata(self) ItemFilesFormRecord._init_metadata(self) edXBaseFormRecord._init_metadata(self) IRTItemFormRecord._init_metadata(self) TimeValueFormRecord....
def is_admin(controller, client, actor): """Used to determine whether someone issuing a command is an admin. By default, checks to see if there's a line of the type nick=host that matches the command's actor in the [admins] section of the config file, or a key that matches the entire mask (e.g. "foo@bar" or "foo@bar=1"...
def get_items(self): """Gets the item list resulting from the search. return: (osid.assessment.ItemList) - the item list raise: IllegalState - the item list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retr...
def get_assessments(self): """Gets the assessment list resulting from the search. return: (osid.assessment.AssessmentList) - the assessment list raise: IllegalState - the assessment list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalSta...
def get_assessments_offered(self): """Gets the assessment offered list resulting from the search. return: (osid.assessment.AssessmentOfferedList) - the assessment offered list raise: IllegalState - the assessment offered list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if ...
def get_assessments_taken(self): """Gets the assessment taken list resulting from the search. return: (osid.assessment.AssessmentTakenList) - the assessment taken list raise: IllegalState - the assessment taken list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retri...
def get_banks(self): """Gets the bank list resulting from a search. return: (osid.assessment.BankList) - the bank list raise: IllegalState - the bank list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retrie...
def roots(self): """get the nodes with no children""" return [x for x in self._nodes.values() if x.id not in self._c2p]
def get_root_graph(self,root): """Return back a graph containing just the root and children""" children = self.get_children(root) g = Graph() nodes = [root]+children for node in nodes: g.add_node(node) node_ids = [x.id for x in nodes] edges = [x for x in self._edges.values() if x.node1.id in node_ids and x.node2.id in ...
def merge_cycles(self): """Work on this graph and remove cycles, with nodes containing concatonated lists of payloads""" while True: ### remove any self edges own_edges = self.get_self_edges() if len(own_edges) > 0: for e in own_edges: self.remove_edge(e) c = self.find_cycle() if not c: return keep = c[0] remove_list =...
def remove_node(self,node): """remove the node""" if node.id not in self._nodes: return """find edges to remove""" edges = set() for e in self._edges.values(): if e.node1.id == node.id: edges.add(e.id) if e.node2.id == node.id: edges.add(e.id) edges = [self._edges[x] for x in list(edges)] for e in edges: self.remove_ed...
def remove_edge(self,edge): """Remove the edge""" if edge.id not in self._edges: return # its not in the graph del self._p2c[edge.node1.id][edge.node2.id][edge.id] if len(self._p2c[edge.node1.id][edge.node2.id].keys()) == 0: del self._p2c[edge.node1.id][edge.node2.id] if len(self._p2c[edge.node1.id].keys()) == 0: del s...
def move_edges(self,n1,n2): """Move edges from node 1 to node 2 Not self edges though Overwrites edges """ #Traverse edges to find incoming with n1 incoming = [] for e in self._edges.values(): if e.node2.id == n1.id: incoming.append(e) #Traverse edges to find outgoing from n1 outgoing = [] for e in self._edges.values()...
def find_cycle(self): """greedy search for a cycle""" for node in self.nodes: cyc = self._follow_children(node) if len(cyc) > 0: return [self._nodes[x] for x in cyc] return None
def get_authorizations_by_search(self, authorization_query, authorization_search): """Pass through to provider AuthorizationSearchSession.get_authorizations_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not self._can('search'): raise Perm...