@utilities.arguments_not_none<EOL><INDENT>def get_assessments_by_query(self, assessment_query):<DEDENT>
"""<STR_LIT>"""<EOL>if '<STR_LIT>' in assessment_query._query_terms:<EOL><INDENT>collection = JSONClientValidated('<STR_LIT>',<EOL>collection='<STR_LIT>',<EOL>runtime=self._runtime)<EOL>match = '<STR_LIT>' in assessment_query._query_terms['<STR_LIT>'].keys()<EOL>if match:<EOL><INDENT>match_identifiers = [ObjectId(Id(i).identifier) for i in assessment_query._query_terms['<STR_LIT>']['<STR_LIT>']]<EOL>query = {'<STR_LIT>': match_identifiers}<EOL><DEDENT>else:<EOL><INDENT>match_identifiers = [ObjectId(Id(i).identifier) for i in assessment_query._query_terms['<STR_LIT>']['<STR_LIT>']]<EOL>query = {'<STR_LIT>': match_identifiers}<EOL><DEDENT>result = collection.find({<EOL>"<STR_LIT>": query<EOL>})<EOL>assessment_ids = [ObjectId(Id(r['<STR_LIT>']).identifier) for r in result]<EOL>collection = JSONClientValidated('<STR_LIT>',<EOL>collection='<STR_LIT>',<EOL>runtime=self._runtime)<EOL>result = collection.find({<EOL>"<STR_LIT>": {"<STR_LIT>": assessment_ids}<EOL>})<EOL>return objects.AssessmentList(result, runtime=self._runtime, proxy=self._proxy)<EOL><DEDENT>else:<EOL><INDENT>and_list = list()<EOL>or_list = list()<EOL>for term in assessment_query._query_terms:<EOL><INDENT>if '<STR_LIT>' in assessment_query._query_terms[term] and '<STR_LIT>' in assessment_query._query_terms[term]:<EOL><INDENT>and_list.append(<EOL>{'<STR_LIT>': [{term: {'<STR_LIT>': assessment_query._query_terms[term]['<STR_LIT>']}},<EOL>{term: {'<STR_LIT>': assessment_query._query_terms[term]['<STR_LIT>']}}]})<EOL><DEDENT>else:<EOL><INDENT>and_list.append({term: assessment_query._query_terms[term]})<EOL><DEDENT><DEDENT>for term in assessment_query._keyword_terms:<EOL><INDENT>or_list.append({term: assessment_query._keyword_terms[term]})<EOL><DEDENT>if or_list:<EOL><INDENT>and_list.append({'<STR_LIT>': or_list})<EOL><DEDENT>view_filter = self._view_filter()<EOL>if view_filter:<EOL><INDENT>and_list.append(view_filter)<EOL><DEDENT>if and_list:<EOL><INDENT>query_terms = {'<STR_LIT>': and_list}<EOL>collection = JSONClientValidated('<STR_LIT>',<EOL>collection='<STR_LIT>',<EOL>runtime=self._runtime)<EOL>result = collection.find(query_terms).sort('<STR_LIT>', DESCENDING)<EOL><DEDENT>else:<EOL><INDENT>result = []<EOL><DEDENT>return objects.AssessmentList(result, runtime=self._runtime, proxy=self._proxy)<EOL><DEDENT>
Gets a list of ``Assessments`` matching the given assessment query.

        arg:    assessment_query (osid.assessment.AssessmentQuery): the
                assessment query
        return: (osid.assessment.AssessmentList) - the returned
                ``AssessmentList``
        raise:  NullArgument - ``assessment_query`` is ``null``
        raise:  OperationFailed - unable to complete request
        raise:  PermissionDenied - authorization failure occurred
        raise:  Unsupported - ``assessment_query`` is not of this
                service
        *compliance: mandatory -- This method must be implemented.*