Beispiel #1
0
def evaluate_test(ans, att):
	ans = ans.strip("\[")
	ans = ans.strip("\]")
	ans = ans.replace("{","")
	ans = ans.replace("}","")
	att = att.strip("'")
	try:
		update_sql = """UPDATE eval_info 
						SET attempt = %s
						SET answer = %s"""
		db_cursor.execute(update_sql,(att,ans))
		db.commit()
	except:
		db.rollback()
		print "Database has been rolled back because of an Exception !!!"
		#print(traceback.format_exc())  

	p = make_params(ans, att)
	if p == {}:
		#logger.info("param empty from evaluate")
		return False
	att_value = get_numerical_answer(p['att_tree'])
	ans_value = get_numerical_answer(p['ans_tree'])
	final_pairs = find_matches(p)
	#logger.info("output matching: {0}.".format(final_pairs))

	if len(final_pairs) == 1 and final_pairs[0][0] == 'R':
		return True
	elif check_w_tol(ans_value, att_value):
		return True
	else:
		return False
Beispiel #2
0
def evaluate(ans, att):
	ans = ans.strip("\[")
  	ans = ans.strip("\]")
  	ans = ans.replace("{","")
  	ans = ans.replace("}","")
  	att = att.strip("'")
  	#logger.info("evaluating attempt: {0}, answer: {1}.".format(att, ans))
	p = make_params(ans, att)
	if p == {}:
		#logger.info("param empty from evaluate")
		return False
	att_value = get_numerical_answer(p['att_tree'])
	ans_value = get_numerical_answer(p['ans_tree'])
	final_pairs = find_matches(p)
	#logger.info("output matching: {0}.".format(final_pairs))

	if len(final_pairs) == 1 and final_pairs[0][0] == 'R':
		return True
	elif check_w_tol(ans_value, att_value):
		return True
	else:
		return False