#NEWLINE# def get( self , exp_uid , exp_key ) : #NEWLINE# #INDENT# '\n        .. http:get:: /experiment/<exp_uid>/participants\n\n        Get all participant response data associated with a given exp_uid.\n\n        **Example request**:\n\n        .. sourcecode:: http\n\n        GET /experiment/<exp_uid>/participants HTTP/1.1\n        Host: next_backend.next.discovery.wisc.edu\n\n        **Example response**:\n\n        .. sourcecode:: http\n        \n        HTTP/1.1 200 OK\n        Vary: Accept\n        Content-Type: application/json\n\n        {\n        \tparticipant_responses: [participant_responses]\n        \tstatus: {\n        \t\tcode: 200,\n        \t\tstatus: OK,\n       \t\t},\n        }\n        \n        :>json all_participant_responses: list of all participant_responses\n\n        :statuscode 200: Participants responses successfully returned\n        :statuscode 400: Participants responses failed to be generated\n    \t' #NEWLINE# zip_true = False #NEWLINE# if request . args . get ( 'zip' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# zip_true = eval ( request . args . get ( 'zip' ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# if ( not keychain . verify_exp_key ( exp_uid , exp_key ) ) : #NEWLINE# #INDENT# return ( api_util . attach_meta ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , api_util . verification_error ) , 401 ) #NEWLINE# #UNINDENT# participant_uids = resource_manager . get_participant_uids ( exp_uid ) #NEWLINE# participant_responses = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for participant in participant_uids : #NEWLINE# #INDENT# response = resource_manager . get_participant_data ( participant , exp_uid ) #NEWLINE# participant_responses [ participant ] = response #NEWLINE# #UNINDENT# for ( participant , responses ) in participant_responses . iteritems ( ) : #NEWLINE# #INDENT# for response in responses : #NEWLINE# #INDENT# for target_index in response [ 'target_indices' ] : #NEWLINE# #INDENT# target_index [ 'target' ] = targetmapper . get_target_data ( exp_uid , target_index [ 'index' ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# all_responses = { #NEWLINE# #INDENT# 'participant_responses' : participant_responses , #NEWLINE# #UNINDENT# } #NEWLINE# if zip_true : #NEWLINE# #INDENT# zip_responses = BytesIO ( ) #NEWLINE# with zipfile . ZipFile ( zip_responses , 'w' ) as zf : #NEWLINE# #INDENT# zf . writestr ( 'participants.json' , json . dumps ( all_responses ) ) #NEWLINE# #UNINDENT# zip_responses . seek ( 0 ) #NEWLINE# return send_file ( zip_responses , attachment_filename = 'participants.zip' , as_attachment = 'True' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( api_util . attach_meta ( all_responses , meta_success ) , 200 )