How to use the psiturk.amt_services.MTurkHIT function in PsiTurk

To help you get started, we’ve selected a few PsiTurk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NYUCCL / psiTurk / psiturk / amt_services.py View on Github external
def _hit_xml_to_object(hits):
        if not isinstance(hits, list):
            hits = [hits]
        hits_data = [MTurkHIT({
            'hitid': hit['HITId'],
            'title': hit['Title'],
            'status': hit['HITStatus'],
            'max_assignments': hit['MaxAssignments'],
            'number_assignments_completed': hit['NumberOfAssignmentsCompleted'],
            'number_assignments_pending': hit['NumberOfAssignmentsPending'],
            'number_assignments_available': hit['NumberOfAssignmentsAvailable'],
            'creation_time': hit['CreationTime'],
            'expiration': hit['Expiration'],
            'is_expired': datetime.datetime.now(hit['Expiration'].tzinfo) >= hit['Expiration'],
            'duration_in_seconds': hit['AssignmentDurationInSeconds'],
            'reward': hit['Reward'],
            'description': hit['Description'],
            'number_submissions_needing_action': hit['MaxAssignments'] - hit['NumberOfAssignmentsCompleted'] - hit['NumberOfAssignmentsPending'] - hit['NumberOfAssignmentsAvailable']
        }) for hit in hits]
        return hits_data
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
def default(self, obj):
        if isinstance(obj, (PsiturkException, WrapperResponse)):
            return obj.to_dict()
        elif isinstance(obj, Exception):
            return {
                'exception': type(obj).__name__, 
                'message': str(obj)
            }
        elif isinstance(obj, MTurkHIT):
            return obj.__dict__
        return JSONEncoder.default(self, obj)