From afd42fc1dcbfb7db53fc11d8a8e6ce226099d75d Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Wed, 30 Jan 2013 16:22:35 -0500 Subject: [PATCH] Fix some image okay problems --- .../xmodule/combined_open_ended_module.py | 2 +- .../xmodule/open_ended_image_submission.py | 19 +++++++++++++------ common/lib/xmodule/xmodule/openendedchild.py | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index c9702ebd60..426818861d 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -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"] diff --git a/common/lib/xmodule/xmodule/open_ended_image_submission.py b/common/lib/xmodule/xmodule/open_ended_image_submission.py index 97244ceb33..cda6cb062a 100644 --- a/common/lib/xmodule/xmodule/open_ended_image_submission.py +++ b/common/lib/xmodule/xmodule/open_ended_image_submission.py @@ -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 diff --git a/common/lib/xmodule/xmodule/openendedchild.py b/common/lib/xmodule/xmodule/openendedchild.py index 86c9280b43..9db3388371 100644 --- a/common/lib/xmodule/xmodule/openendedchild.py +++ b/common/lib/xmodule/xmodule/openendedchild.py @@ -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: