def recordPerformance(self, req): try: res = recordUserCognitiveTestPerformanceSrvResponse() userOntologyAlias = CognitiveExerciseHelperFunctions.getUserOntologyAlias( req.username) serv_topic = rospy.get_param( 'rapp_knowrob_wrapper_record_user_cognitive_tests_performance') knowrob_service = rospy.ServiceProxy( serv_topic, recordUserPerformanceCognitiveTestsSrv) userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest( ) userPerformanceEntry.test = req.test userPerformanceEntry.patient_ontology_alias = userOntologyAlias userPerformanceEntry.timestamp = int(time.time()) userPerformanceEntry.score = req.score userPerformanceEntryResponse = knowrob_service( userPerformanceEntry) if (userPerformanceEntryResponse.success != True): error = userPerformanceEntryResponse.error + "Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type" raise AppError(error, error) else: res.success = True res.userCognitiveTestPerformanceEntry = userPerformanceEntryResponse.cognitive_test_performance_entry except IndexError, e: res.trace.append("IndexError: " + str(e)) res.error = "IndexError: " + str(e) res.success = False CognitiveExerciseHelperFunctions.traceError(res.error, res.trace)
def recordPerformance(self, req): try: res = recordUserCognitiveTestPerformanceSrvResponse() serv_topic = rospy.get_param( 'rapp_knowrob_wrapper_create_ontology_alias') knowrob_service = rospy.ServiceProxy(serv_topic, createOntologyAliasSrv) createOntologyAliasReq = createOntologyAliasSrvRequest() createOntologyAliasReq.username = req.username createOntologyAliasResponse = knowrob_service( createOntologyAliasReq) if (createOntologyAliasResponse.success != True): res.trace = createOntologyAliasResponse.trace res.error = createOntologyAliasResponse.error res.success = False return res serv_topic = rospy.get_param( 'rapp_knowrob_wrapper_record_user_cognitive_tests_performance') knowrob_service = rospy.ServiceProxy( serv_topic, recordUserPerformanceCognitiveTestsSrv) userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest( ) userPerformanceEntry.test = req.test userPerformanceEntry.patient_ontology_alias = createOntologyAliasResponse.ontology_alias userPerformanceEntry.timestamp = int(time.time()) userPerformanceEntry.score = req.score userPerformanceEntryResponse = knowrob_service( userPerformanceEntry) if (userPerformanceEntryResponse.success != True): res.trace = userPerformanceEntryResponse.trace res.trace.append( "Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type" ) res.error = userPerformanceEntryResponse.error + "Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type" res.success = False return res else: res.success = True res.userCognitiveTestPerformanceEntry = userPerformanceEntryResponse.cognitive_test_performance_entry except IndexError: res.trace.append( "Wrong Query Input Format, check for empty required columns list or wrong/incomplete Query data format" ) res.success = False except IOError: print "Error: can\'t find login file or read data" res.success = False res.trace.append("Error: can\'t find login file or read data") return res
def test_record_user_performance_nonexisting_test_and_user(self): subclasses_of_service = rospy.get_param(\ "rapp_knowrob_wrapper_record_user_cognitive_tests_performance") rospy.wait_for_service(subclasses_of_service) test_service = rospy.ServiceProxy(\ subclasses_of_service, recordUserPerformanceCognitiveTestsSrv) req = recordUserPerformanceCognitiveTestsSrvRequest() req.patient_ontology_alias="1Person_vUXiHMJy" req.test="1Arithm1eticCts_qdaDeDZn" req.score=1 req.timestamp=1 response = test_service(req) self.assertEqual(response.success, False) self.assertEqual(response.error, 'Test performance entry insertion into ontology FAILED, either invalid test or patient alias')
def test_record_user_performance_nonexisting_test_and_user(self): subclasses_of_service = rospy.get_param(\ "rapp_knowrob_wrapper_record_user_cognitive_tests_performance") rospy.wait_for_service(subclasses_of_service) test_service = rospy.ServiceProxy(\ subclasses_of_service, recordUserPerformanceCognitiveTestsSrv) req = recordUserPerformanceCognitiveTestsSrvRequest() req.patient_ontology_alias="1Person_vUXiHMJy" req.test="1Arithm1eticCts_qdaDeDZn" req.score=1 req.timestamp=1 response = test_service(req) self.assertEqual(response.success, False) self.assertEqual(response.error, 'Test performance entry insertion into ontology FAILED, either invalid test or patient alias')
def recordPerformance(self,req): try: res = recordUserCognitiveTestPerformanceSrvResponse() serv_topic = rospy.get_param('rapp_knowrob_wrapper_create_ontology_alias') knowrob_service = rospy.ServiceProxy(serv_topic, createOntologyAliasSrv) createOntologyAliasReq = createOntologyAliasSrvRequest() createOntologyAliasReq.username=req.username createOntologyAliasResponse = knowrob_service(createOntologyAliasReq) if(createOntologyAliasResponse.success!=True): res.trace=createOntologyAliasResponse.trace res.error=createOntologyAliasResponse.error res.success=False return res serv_topic = rospy.get_param('rapp_knowrob_wrapper_record_user_cognitive_tests_performance') knowrob_service = rospy.ServiceProxy(serv_topic, recordUserPerformanceCognitiveTestsSrv) userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest() userPerformanceEntry.test=req.test userPerformanceEntry.patient_ontology_alias=createOntologyAliasResponse.ontology_alias userPerformanceEntry.timestamp=int(time.time()) userPerformanceEntry.score=req.score userPerformanceEntryResponse = knowrob_service(userPerformanceEntry) if(userPerformanceEntryResponse.success!=True): res.trace=userPerformanceEntryResponse.trace res.trace.append("Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type") res.error=userPerformanceEntryResponse.error+"Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type" res.success=False return res else: res.success=True res.userCognitiveTestPerformanceEntry=userPerformanceEntryResponse.cognitive_test_performance_entry except IndexError: res.trace.append("Wrong Query Input Format, check for empty required columns list or wrong/incomplete Query data format") res.success=False except IOError: print "Error: can\'t find login file or read data" res.success=False res.trace.append("Error: can\'t find login file or read data") return res
def recordPerformance(self,req): try: res = recordUserCognitiveTestPerformanceSrvResponse() userOntologyAlias=CognitiveExerciseHelperFunctions.getUserOntologyAlias(req.username) serv_topic = rospy.get_param('rapp_knowrob_wrapper_record_user_cognitive_tests_performance') knowrob_service = rospy.ServiceProxy(serv_topic, recordUserPerformanceCognitiveTestsSrv) userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest() userPerformanceEntry.test=req.test userPerformanceEntry.patient_ontology_alias=userOntologyAlias userPerformanceEntry.timestamp=int(time.time()) userPerformanceEntry.score=req.score userPerformanceEntryResponse = knowrob_service(userPerformanceEntry) if(userPerformanceEntryResponse.success!=True): error=userPerformanceEntryResponse.error+"Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type" raise AppError(error,error) else: res.success=True res.userCognitiveTestPerformanceEntry=userPerformanceEntryResponse.cognitive_test_performance_entry except IndexError, e: res.trace.append("IndexError: " +str(e)) res.error="IndexError: "+str(e) res.success=False CognitiveExerciseHelperFunctions.traceError(res.error,res.trace)