Fix some image okay problems
This commit is contained in:
@@ -39,7 +39,7 @@ MAX_SCORE = 1
|
||||
MAX_SCORE_ALLOWED = 3
|
||||
|
||||
IS_SCORED = False
|
||||
ACCEPT_FILE_UPLOAD = True
|
||||
ACCEPT_FILE_UPLOAD = False
|
||||
|
||||
#Contains all reasonable bool and case combinations of True
|
||||
TRUE_DICT = ["True", True, "TRUE", "true"]
|
||||
|
||||
@@ -86,12 +86,19 @@ class ImageProperties(object):
|
||||
@param rgb: RGB tuple
|
||||
@return: Boolean true false
|
||||
"""
|
||||
r,g,b = rgb
|
||||
check_r = (r > 60)
|
||||
check_b = (r * 0.4) < b < (r * 0.85)
|
||||
check_g = (r * 0.2) < g < (r * 0.7)
|
||||
colors_okay = False
|
||||
try:
|
||||
r = rgb[0]
|
||||
g = rgb[1]
|
||||
b = rgb[2]
|
||||
check_r = (r > 60)
|
||||
check_g = (r * 0.4) < g < (r * 0.85)
|
||||
check_b = (r * 0.2) < b < (r * 0.7)
|
||||
colors_okay = check_r and check_b and check_g
|
||||
except:
|
||||
pass
|
||||
|
||||
return check_r and check_b and check_g
|
||||
return colors_okay
|
||||
|
||||
def get_skin_ratio(self):
|
||||
"""
|
||||
@@ -118,7 +125,7 @@ class ImageProperties(object):
|
||||
try:
|
||||
image_is_okay = self.count_colors() and self.get_skin_ratio() and not self.image_too_large
|
||||
except:
|
||||
pass
|
||||
log.exception("Could not run image tests.")
|
||||
|
||||
return image_is_okay
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ class OpenEndedChild(object):
|
||||
"""
|
||||
success = False
|
||||
s3_public_url = ""
|
||||
image_ok = False
|
||||
try:
|
||||
image_data.seek(0)
|
||||
image_ok = open_ended_image_submission.run_image_tests(image_data)
|
||||
@@ -348,7 +349,7 @@ class OpenEndedChild(object):
|
||||
return True, get_data
|
||||
|
||||
has_file_to_upload, uploaded_to_s3, image_ok, image_tag = self.check_for_image_and_upload(get_data)
|
||||
if uploaded_to_s3 and has_file_to_upload:
|
||||
if uploaded_to_s3 and has_file_to_upload and image_ok:
|
||||
get_data['student_answer'] += image_tag
|
||||
overall_success = True
|
||||
elif has_file_to_upload and not uploaded_to_s3 and image_ok:
|
||||
|
||||
Reference in New Issue
Block a user