def post(self, data): ''' Process the deserialized data and load it into the session object. ''' logger.debug('Processing SessionWordRecongitionTest POST data') print("Hello. Am I completed %s" % self.completed) try: responses = json.loads(data['responses']) logger.debug('Processing data: %s' % repr(responses)) for datum in responses: stimulus_onset_datetime\ = datetime.fromtimestamp(datum['onset']) if datum['responseTime'] is None: response_datetime = None logger.debug('No responseTime. Missed trial?') else: response_datetime\ = datetime.fromtimestamp(datum['responseTime']) stimulus\ = self.widget.wordliststimulus.get_item(datum['word']) try: if datum['response'] == 'present': response = True elif datum['response'] == 'absent': response = False else: response = None try: assert datum['response'] in ('absent', 'present', None) except AssertionError as e: logger.error( 'Response should be "absent" or "present" or None') BinaryChoiceModel.new(self, stimulus, response = response, order = datum['order'], stimulus_onset_datetime = stimulus_onset_datetime, response_datetime = response_datetime) except Exception as e: logger.warning( 'Could not process binary response datum: %s' % e.message) self.set_completed() except Exception as e: logger.warning('Could not process data. %s ' % e.message)
def post(self, data): reading_data = json.loads(data["responses"])[0] print(reading_data) self.text_display_start = datetime.fromtimestamp(reading_data["onset"]) self.text_display_stop = datetime.fromtimestamp(reading_data["offset"]) self.set_completed() self.save()