code
stringlengths
1
18.2k
in six.iteritems(kwargs): self.set(key, value)
def get_resources_by_search(self, resource_query, resource_search): """Pass through to provider ResourceSearchSession.get_resources_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not self._can('search'): raise PermissionDenied() return sel...
def get_resource_relationships_for_source_resource_on_date(self, source_resource_id, from_, to): """Pass through to provider ResourceRelationshipLookupSession.get_resource_relationships_for_source_resource_on_date""" # Implemented from azosid template for - # osid.relationship.RelationshipLookupSession.get_relationship...
def get_resource_relationships_by_search(self, resource_relationship_query, resource_relationship_search): """Pass through to provider ResourceRelationshipSearchSession.get_resource_relationships_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template...
def FlowManager(start_string, end_string): """ A factory for creating context managers for standard code constructions, such as if statements and functions. :param str start_string: A format string for the beginning of this code structure :param str end_string: A format string for the end of this code structure The con...
def writeln(self, data): """ Write a line of text to the file :param data: The text to write """ self.f.write(" "*self.indent_level) self.f.write(data + "\n")
def _function(self, type, name, args=""): """ Returns a context manager for writing a function. :param str type: The return type of the function :param str name: The name of the functino :param str args: The argument specification for the function """ return FunctionManager(self, type=type, name=name, args=args)
def write_to(self, f): """ Generates code based on the given module configuration and writes it to the file object `f`. """ f = CodeWriter(f) # Write all header files headers = set() for plugin in self.plugins: headers = headers.union(plugin.header_files()) for header in headers: f.writeln("#include <{}>".format(header...
in self.modules.items(): for plugin in self.plugins: plugin.update_module(mod_name, f) # Read all module outputs for output_name in mod_info["outputs"]: cond = "{mod_name}.get_{output_name}({msg_name})".format( mod_name=mod_name, output_name=output_name, msg_name=self.msg_name(mod_name, output_name) ) with f._if(cond):...
def _record_extension(self, key, value): """ To structure a record extension property bean """ record_bean = { 'value': value, 'displayName': self._text_bean(key), 'description': self._text_bean(key), 'displayLabel': self._text_bean(key), 'associatedId': str(self.ident) } return record_bean
def get_genus_type(self): """Gets the genus type of this object. return: (osid.type.Type) - the genus type of this object compliance: mandatory - This method must be implemented. """ if self._my_genus_type_map is None: url_path = '/handcar/services/learning/types/' + self._my_map['genusTypeId'] # url_str = self._base_u...
def is_of_genus_type(self, genus_type=None): """Tests if this object is of the given genus Type. The given genus type may be supported by the object through the type hierarchy. | arg: ``genus_type`` (``osid.type.Type``): a genus type | return: (``boolean``) - true if this object is of the given genus Type, false otherw...
def set_journal_comment(self, comment=None): """Sets a comment. arg: comment (string): the new comment raise: InvalidArgument - comment is invalid raise: NoAccess - metadata.is_readonly() is true raise: NullArgument - comment is null compliance: mandatory - This method must be implemented. """ if comment is None: raise...
def is_valid(self): """Tests if ths form is in a valid state for submission. A form is valid if all required data has been supplied compliant with any constraints. return: (boolean) - false if there is a known error in this form, true otherwise raise: OperationFailed - attempt to perform validation failed compliance: m...
def set_display_name(self, display_name=None): """Sets a display name. A display name is required and if not set, will be set by the provider. arg: displayName (string): the new display name raise: InvalidArgument - displayName is invalid raise: NoAccess - metadata.is_readonly() is true raise: NullArgument - displayNam...
def set_description(self, description=None): """Sets a description. arg: description (string): the new description raise: InvalidArgument - description is invalid raise: NoAccess - metadata.is_readonly() is true raise: NullArgument - description is null compliance: mandatory - This method must be implemented. """ if de...
def set_genus_type(self, genus_type=None): """Sets a genus. A genus cannot be cleared because all objects have at minimum a root genus. arg: genusType (osid.type.Type): the new genus raise: InvalidArgument - genusType is invalid raise: NoAccess - metadata.is_readonly() is true raise: NullArgument - genusType is null co...
def derive_toctree_rst(self, current_file): """ Generate the rst content:: .. toctree:: args ... example.rst ... :param current_file: :return: """ TAB = " " * 4 lines = list() lines.append(".. toctree::") for opt in TocTree.option_spec: value = self.options.get(opt) if value is not None: lines.append(("{}:{}: {}".forma...
def confirm(prompt, default=None, show_default=True, abort=False, input_function=None): '''Prompts for confirmation from the user. ''' valid = { 'yes': True, 'y': True, 'no': False, 'n': False } input_function = get_input_fn(input_function) if default not in ['yes', 'no', None]: default = None if show_default: prompt =...
def prompt(text, default=None, show_default=True, invisible=False, confirm=False, skip=False, type=None, input_function=None): '''Prompts for input from the user. ''' t = determine_type(type, default) input_function = get_input_fn(input_function, invisible) if default is not None and show_default: text = '{} [{}]: '.fo...
def consume(self, tokens): '''Have this parameter consume some tokens. This stores the consumed value for later use and returns the modified tokens array for further processing. ''' n = len(tokens) if self._nargs == -1 else self._nargs if n > len(tokens): exit('Error: Not enough arguments for "{}".'.format(self._name),...
def parse(self, tokens): '''Parses a list of tokens into a JSON-serializable object. The parsing proceeds from left to right and is greedy. Precedence order: 1. Parameters with active context. For example, an Option with nargs=-1 will gobble all the remaining tokens. 2. Subcommands. 3. Parameters. The keys of the retur...
pass off to main command after flattening expanded tokens list return self._main.parse(list(itertools.chain.from_iterable(expanded)))
def get_resource_mdata(): """Return default mdata map for Resource""" return { 'group': { 'element_label': { 'text': 'group', 'languageTypeId': str(DEFAULT_LANGUAGE_TYPE), 'scriptTypeId': str(DEFAULT_SCRIPT_TYPE), 'formatTypeId': str(DEFAULT_FORMAT_TYPE), }, 'instructions': { 'text': 'enter either true or false.', 'lan...
def calculate_affinity(user1, user2, round=False): # pragma: no cover """ Quick one-off affinity calculations. Creates an instance of the ``MALAffinity`` class with ``user1``, then calculates affinity with ``user2``. :param str user1: First user :param str user2: Second user :param round: Decimal places to round affini...
def s2time(secs, show_secs=True, show_fracs=True): """Converts seconds to time""" try: secs = float(secs) except: return "--:--:--.--" wholesecs = int(secs) centisecs = int((secs - wholesecs) * 100) hh = int(wholesecs / 3600) hd = int(hh % 24) mm = int((wholesecs / 60) - (hh*60)) ss = int(wholesecs - (hh*3600) - (mm*60...
def f2tc(f,base=25): """Converts frames to timecode""" try: f = int(f) except: return "--:--:--:--" hh = int((f / base) / 3600) mm = int(((f / base) / 60) - (hh*60)) ss = int((f/base) - (hh*3600) - (mm*60)) ff = int(f - (hh*3600*base) - (mm*60*base) - (ss*base)) return "{:02d}:{:02d}:{:02d}:{:02d}".format(hh, mm, ss, f...
def s2tc(s,base=25): """Converts seconds to timecode""" try: f = int(s*base) except: return "--:--:--:--" hh = int((f / base) / 3600) hhd = int((hh % 24)) mm = int(((f / base) / 60) - (hh*60)) ss = int((f/base) - (hh*3600) - (mm*60)) ff = int(f - (hh*3600*base) - (mm*60*base) - (ss*base)) return "{:02d}:{:02d}:{:02d}:{...
def format_time(timestamp, time_format="%Y-%m-%d %H:%M:%S", never_placeholder="never", gmt=False): """strftime/localtime shortcut""" if not timestamp: return never_placeholder return time.strftime(time_format, time.gmtime(timestamp) if gmt else time.localtime(timestamp))
def main(args): """ First read the genome """ sys.stderr.write("reading reference genome\n") ref = FASTAData(open(args.genome).read()) sys.stderr.write("read in "+str(len(ref.keys()))+" chromosomes\n") """ Next make the transcriptome """ txome = {} sys.stderr.write("write the transcriptome\n") inf = None if args.gpd[-3...
else: reads = '-1 '+args.r1+' -2 '+args.r2 cmd = 'salmon quant -p '+str(args.numThreads)+' -i '+args.tempdir+'/salmon_index -l A '+reads+' -o '+args.tempdir+'/output_quant' p = Popen(cmd.split()) p.communicate() sys.stderr.write("finished quanitfying\n") """Now parse the salmon output to add gene name""" salmon = {} wi...
for gene in ordered_gene_names: txs = sorted(genes[gene],key=lambda x: x['TPM'],reverse=True) for tx in txs: of.write(gene+"\t"+tx['name']+"\t"+str(tx['length'])+"\t"+str(tx['EffectiveLength'])+"\t"+str(tx['TPM'])+"\t"+str(tx['NumReads'])+"\t"+str(genetot[gene])+"\n") of.close() # Temporary working directory step 3 of ...
def clone_with_new_dockerfile(self, conf, docker_file): """Clone this tarfile and add in another filename before closing the new tar and returning""" log.info("Copying context to add a different dockerfile") self.close() with a_temp_file() as tmpfile: old_t = os.stat(self.tmpfile.name).st_size > 0 if old_t: shutil.copy...
def make_context(self, context, silent_build=False, extra_context=None): """ Context manager for creating the context of the image Arguments: context - ``harpoon.option_spec.image_objs.Context`` Knows all the context related options silent_build - boolean If True, then suppress printing out information extra_context - ...
def the_context(self, content, silent_build=False): """Return either a file with the content written to it, or a whole new context tar""" if isinstance(content, six.string_types): with a_temp_file() as fle: fle.write(content.encode('utf-8')) fle.seek(0) yield fle elif "context" in content: with ContextBuilder().make_co...
tf.firstmember.isdir(): tf2 = tarfile.TarFile(fileobj=fle, mode='w') name = tf.firstmember.name for member in tf.getmembers()[1:]: member.name = member.name[len(name)+1:] if member.issym(): with tempfile.NamedTemporaryFile() as symfle: os.remove(symfle.name) os.symlink(member.linkpath, symfle.name) tf2.addfile(member, ...
def find_files_for_tar(self, context, silent_build): """ Return [(filename, arcname), ...] for all the files. """ if not context.enabled: return files = self.find_files(context, silent_build) for path in files: relname = os.path.relpath(path, context.parent_dir) arcname = "./{0}".format(relname.encode('utf-8').decode('...
def find_files(self, context, silent_build): """ Find the set of files from our parent_dir that we care about """ first_layer = ["'{0}'".format(thing) for thing in os.listdir(context.parent_dir)] output, status = command_output("find {0} -type l -or -type f {1} -follow -print".format(' '.join(first_layer), context.find...
context.exclude: excluded = set() for filename in combined: for excluder in context.exclude: if fnmatch.fnmatch(filename, excluder): excluded.add(filename) break if not silent_build: log.info("Filtering %s/%s items\texcluding=%s", len(excluded), len(combined), context.exclude) combined -= excluded if context.include: e...
def convert_nonascii(self, lst): """Convert the strange outputs from git commands""" for item in lst: if item.startswith('"') and item.endswith('"'): item = item[1:-1] yield item.encode('utf-8').decode('unicode-escape') else: yield item.encode('utf-8').decode('unicode-escape')
def find_notignored_git_files(self, context, silent_build): """ Return a list of files that are not ignored by git """ def git(args, error_message, cwd=context.parent_dir, **error_kwargs): output, status = command_output("git {0}".format(args), cwd=cwd) if status != 0: error_kwargs['output'] = output error_kwargs['dire...
matched: continue location = os.path.join(context.parent_dir, filename) if os.path.islink(location) and os.path.isdir(location): actual_path = os.path.abspath(os.path.realpath(location)) parent_dir = os.path.abspath(os.path.realpath(context.parent_dir)) include_from = os.path.relpath(actual_path, parent_dir) to_include...
def ask(question, default=None): """ @question: str @default: Any value which can be converted to string. Asks a user for a input. If default parameter is passed it will be appended to the end of the message in square brackets. """ question = str(question) if default: question += ' [' + str(default) + ']' question += '...
def to_bool(answer, default): """ Converts user answer to boolean """ answer = str(answer).lower() default = str(default).lower() if answer and answer in "yes": return True return False
def out(*args): """ Outputs its parameters to users stdout. """ for value in args: sys.stdout.write(value) sys.stdout.write(os.linesep)
def err(*args): """ Outputs its parameters to users stderr. """ for value in args: sys.stderr.write(value) sys.stderr.write(os.linesep)
def has_next_assessment_section(self, assessment_section_id): """Tests if there is a next assessment section in the assessment following the given assessment section ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` return: (boolean) - ``true`` if there is a next section, ``false`` ot...
def get_next_assessment_section(self, assessment_section_id): """Gets the next assessemnt section following the given assesment section. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` return: (osid.assessment.AssessmentSection) - the next section raise: IllegalState - ``has_next_assessment...
def has_previous_assessment_section(self, assessment_section_id): """Tests if there is a previous assessment section in the assessment following the given assessment section ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` return: (boolean) - ``true`` if there is a previous assessmen...
def get_previous_assessment_section(self, assessment_section_id): """Gets the next assessemnt section following the given assesment section. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` return: (osid.assessment.AssessmentSection) - the previous assessment section raise: IllegalState - ``...
def get_assessment_section(self, assessment_section_id): """Gets an assessemnts section by ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` return: (osid.assessment.AssessmentSection) - the assessment section raise: IllegalState - ``has_assessment_begun()`` is ``false`` raise: NotFou...
def get_incomplete_assessment_sections(self, assessment_taken_id): """Gets the incomplete assessment sections of this assessment. arg: assessment_taken_id (osid.id.Id): ``Id`` of the ``AssessmentTaken`` return: (osid.assessment.AssessmentSectionList) - the list of incomplete assessment sections raise: IllegalState - ``...
def has_assessment_section_begun(self, assessment_section_id): """Tests if this assessment section has started. A section begins from the designated start time if a start time is defined. If no start time is defined the section may begin at any time. Assessment items cannot be accessed or submitted if the return for th...
def has_next_question(self, assessment_section_id, item_id): """Tests if there is a next question following the given question ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (boolean) - ``true`` if there is a next question, ...
def get_next_question(self, assessment_section_id, item_id): """Gets the next question in this assesment section. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.Question) - the next question raise: IllegalState - ``...
def has_previous_question(self, assessment_section_id, item_id): """Tests if there is a previous question preceeding the given question ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (boolean) - ``true`` if there is a previo...
def get_previous_question(self, assessment_section_id, item_id): """Gets the previous question in this assesment section. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.Question) - the previous question raise: Illeg...
def get_question(self, assessment_section_id, item_id): """Gets the ``Question`` specified by its ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.Question) - the returned ``Question`` raise: IllegalState - ``...
def get_response_form(self, assessment_section_id, item_id): """Gets the response form for submitting an answer. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.AnswerForm) - an answer form raise: IllegalState - ``ha...
record_type_data_sets = get_registry('ANSWER_RECORD_TYPES', self._runtime) section = self.get_assessment_section(assessment_section_id) # because we're now giving session-unique question IDs question = section.get_question(item_id) ils = section._get_item_lookup_session() real_item_id = Id(question._my_map['itemId']) i...
def submit_response(self, assessment_section_id, item_id, answer_form): """Submits an answer to an item. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` arg: answer_form (osid.assessment.AnswerForm): the response raise: IllegalState - ``has_...
true. Remove it? if answer_form.is_for_update(): raise errors.InvalidArgument('the AnswerForm is for update only, not submit') # try: if self._forms[answer_form.get_id().get_identifier()] == SUBMITTED: raise errors.IllegalState('answer_form already used in a submit transaction') except KeyError: raise errors.Unsupporte...
def get_first_unanswered_question(self, assessment_section_id): """Gets the first unanswered question in this assesment section. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` return: (osid.assessment.Question) - the first unanswered question raise: IllegalState - ``has_unanswered_question...
def has_next_unanswered_question(self, assessment_section_id, item_id): """Tests if there is a next unanswered question following the given question ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (boolean) - ``true`` if ther...
def get_next_unanswered_question(self, assessment_section_id, item_id): """Gets the next unanswered question in this assesment section. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.Question) - the next unanswered ...
def has_previous_unanswered_question(self, assessment_section_id, item_id): """Tests if there is a previous unanswered question preceeding the given question ``Id``. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (boolean) - ``true`...
def get_previous_unanswered_question(self, assessment_section_id, item_id): """Gets the previous unanswered question in this assesment section. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.Question) - the previous...
question raise errors.NotFound('item_id is not found in Section')
def get_response(self, assessment_section_id, item_id): """Gets the submitted response to the associated item. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.Response) - the response raise: IllegalState - ``has_asse...
def clear_response(self, assessment_section_id, item_id): """Clears the response to an item The item appears as unanswered. If no response exists, the method simply returns. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` raise: IllegalState...
def finish_assessment_section(self, assessment_section_id): """Indicates an assessment section is complete. Finished sections may or may not allow new or updated responses. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` raise: IllegalState - ``has_assessment_section_begun()`` is ``false or...
def is_answer_available(self, assessment_section_id, item_id): """Tests if an answer is available for the given item. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (boolean) - ``true`` if an answer are available, ``false`` otherwis...
before # a "null" response throws IllegalState response.object_map except errors.IllegalState: return False else: return True
def get_answers(self, assessment_section_id, item_id): """Gets the acceptable answers to the associated item. arg: assessment_section_id (osid.id.Id): ``Id`` of the ``AssessmentSection`` arg: item_id (osid.id.Id): ``Id`` of the ``Item`` return: (osid.assessment.AnswerList) - the answers raise: IllegalState - ``is_answe...
def finish_assessment(self, assessment_taken_id): """Indicates the entire assessment is complete. arg: assessment_taken_id (osid.id.Id): ``Id`` of the ``AssessmentTaken`` raise: IllegalState - ``has_begun()`` is ``false or is_over()`` is ``true`` raise: NotFound - ``assessment_taken_id`` is not found raise: NullArgumen...
def _get_assessment_taken(self, assessment_taken_id): """Helper method for getting an AssessmentTaken objects given an Id.""" if assessment_taken_id not in self._assessments_taken: mgr = self._get_provider_manager('ASSESSMENT') lookup_session = mgr.get_assessment_taken_lookup_session(proxy=self._proxy) # Should this be...
def get_items(self, assessment_taken_id): """Gets the items questioned in a assessment. arg: assessment_taken_id (osid.id.Id): ``Id`` of the ``AssessmentTaken`` return: (osid.assessment.ItemList) - the list of assessment questions raise: NotFound - ``assessment_taken_id`` is not found raise: NullArgument - ``assessment...
def get_responses(self, assessment_taken_id): """Gets the submitted responses. arg: assessment_taken_id (osid.id.Id): ``Id`` of the ``AssessmentTaken`` return: (osid.assessment.ResponseList) - the submitted answers raise: NotFound - ``assessment_taken_id`` is not found raise: NullArgument - ``assessment_taken_id`` is `...
def get_item(self, item_id): """Gets the ``Item`` specified by its ``Id``. In plenary mode, the exact ``Id`` is found or a ``NotFound`` results. Otherwise, the returned ``Item`` may have a different ``Id`` than requested, such as the case where a duplicate ``Id`` was assigned to an ``Item`` and retained for compatibili...
ObjectId(self._get_id(item_id, 'assessment').get_identifier())}, **self._view_filter())) return objects.Item(osid_object_map=result, runtime=self._runtime, proxy=self._proxy)
def get_items_by_ids(self, item_ids): """Gets an ``ItemList`` corresponding to the given ``IdList``. In plenary mode, the returned list contains all of the items specified in the ``Id`` list, in the order of the list, including duplicates, or an error results if an ``Id`` in the supplied list is not found or inaccessib...
template for # osid.resource.ResourceLookupSession.get_resources_by_ids # NOTE: This implementation currently ignores plenary view collection = JSONClientValidated('assessment', collection='Item', runtime=self._runtime) object_id_list = [] for i in item_ids: object_id_list.append(ObjectId(self._get_id(i, 'assessment')....
def get_items_by_genus_type(self, item_genus_type): """Gets an ``ItemList`` corresponding to the given assessment item genus ``Type`` which does not include assessment items of genus types derived from the specified ``Type``. In plenary mode, the returned list contains all known assessment items or an error results. Ot...
DESCENDING) return objects.ItemList(result, runtime=self._runtime, proxy=self._proxy)
def get_items(self): """Gets all ``Items``. In plenary mode, the returned list contains all known items or an error results. Otherwise, the returned list may contain only those items that are accessible through this session. return: (osid.assessment.ItemList) - a list of ``Items`` raise: OperationFailed - unable to com...
def get_items_by_query(self, item_query): """Gets a list of ``Items`` matching the given item query. arg: item_query (osid.assessment.ItemQuery): the item query return: (osid.assessment.ItemList) - the returned ``ItemList`` raise: NullArgument - ``item_query`` is ``null`` raise: OperationFailed - unable to complete req...
DESCENDING) else: result = [] return objects.ItemList(result, runtime=self._runtime, proxy=self._proxy)
def get_items_by_search(self, item_query, item_search): """Gets the search results matching the given search query using the given search. arg: item_query (osid.assessment.ItemQuery): the item query arg: item_search (osid.assessment.ItemSearch): the item search return: (osid.assessment.ItemSearchResults) - the returned...
if view_filter: and_list.append(view_filter) if and_list: query_terms = {'$and': and_list} collection = JSONClientValidated('assessment', collection='Item', runtime=self._runtime) if item_search.start is not None and item_search.end is not None: result = collection.find(query_terms)[item_search.start:item_search.end] e...
def get_item_form_for_create(self, item_record_types): """Gets the assessment item form for creating new assessment items. A new form should be requested for each create transaction. arg: item_record_types (osid.type.Type[]): array of item record types to be included in the create operation or an empty list if none ret...
proxy=self._proxy) else: obj_form = objects.ItemForm( bank_id=self._catalog_id, record_types=item_record_types, runtime=self._runtime, effective_agent_id=self.get_effective_agent_id(), proxy=self._proxy) self._forms[obj_form.get_id().get_identifier()] = not CREATED return obj_form
def create_item(self, item_form): """Creates a new ``Item``. arg: item_form (osid.assessment.ItemForm): the form for this ``Item`` return: (osid.assessment.Item) - the new ``Item`` raise: IllegalState - ``item_form`` already used in a create transaction raise: InvalidArgument - one or more of the form elements is inval...
KeyError: raise errors.Unsupported('item_form did not originate from this session') if not item_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') insert_result = collection.insert_one(item_form._my_map) self._forms[item_form.get_id().get_identifier()] = CREATED result = object...
def update_item(self, item_form): """Updates an existing item. arg: item_form (osid.assessment.ItemForm): the form containing the elements to be updated raise: IllegalState - ``item_form`` already used in an update transaction raise: InvalidArgument - the form contains an invalid value raise: NullArgument - ``item_form...
originate from this session') if not item_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(item_form._my_map) self._forms[item_form.get_id().get_identifier()] = UPDATED # Note: this is out of spec. The OSIDs don't require an object to be returned: return objec...
def delete_item(self, item_id): """Deletes the ``Item`` identified by the given ``Id``. arg: item_id (osid.id.Id): the ``Id`` of the ``Item`` to delete raise: NotFound - an ``Item`` was not found identified by the given ``Id`` raise: NullArgument - ``item_id`` is ``null`` raise: OperationFailed - unable to complete req...
def alias_item(self, item_id, alias_id): """Adds an ``Id`` to an ``Item`` for the purpose of creating compatibility. The primary ``Id`` of the ``Item`` is determined by the provider. The new ``Id`` is an alias to the primary ``Id``. If the alias is a pointer to another item, it is reassigned to the given item ``Id``. a...
def get_question_form_for_create(self, item_id, question_record_types): """Gets the question form for creating new questions. A new form should be requested for each create transaction. arg: item_id (osid.id.Id): an assessment item ``Id`` arg: question_record_types (osid.type.Type[]): array of question record types to ...
elements is not a valid OSID Type') if question_record_types == []: # WHY are we passing bank_id = self._catalog_id below, seems redundant: obj_form = objects.QuestionForm( bank_id=self._catalog_id, item_id=item_id, catalog_id=self._catalog_id, runtime=self._runtime, proxy=self._proxy) else: obj_form = objects.Question...
def get_question_form_for_update(self, question_id): """Gets the question form for updating an existing question. A new question form should be requested for each update transaction. arg: question_id (osid.id.Id): the ``Id`` of the ``Question`` return: (osid.assessment.QuestionForm) - the question form raise: NotFound ...