From 06499bbafc01260f458bd159ed49c457631824f2 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 5 Feb 2013 17:10:35 -0500 Subject: [PATCH 1/3] Fix some of the tests --- common/lib/xmodule/xmodule/open_ended_image_submission.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/open_ended_image_submission.py b/common/lib/xmodule/xmodule/open_ended_image_submission.py index 8fa4d721d3..fa73feef22 100644 --- a/common/lib/xmodule/xmodule/open_ended_image_submission.py +++ b/common/lib/xmodule/xmodule/open_ended_image_submission.py @@ -127,10 +127,14 @@ class ImageProperties(object): """ image_is_okay = False try: - image_is_okay = self.count_colors() and self.get_skin_ratio() and not self.image_too_large + #image_is_okay = self.count_colors() and self.get_skin_ratio() and not self.image_too_large + image_is_okay = self.image_too_large except: log.exception("Could not run image tests.") + if not ENABLE_PIL: + image_is_okay = True + return image_is_okay From 8bf29c0e1a1934b4d9044aa8e45af6f36d471bfc Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 5 Feb 2013 17:17:58 -0500 Subject: [PATCH 2/3] Alter image test criteria --- common/lib/xmodule/xmodule/open_ended_image_submission.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/open_ended_image_submission.py b/common/lib/xmodule/xmodule/open_ended_image_submission.py index fa73feef22..196f396d65 100644 --- a/common/lib/xmodule/xmodule/open_ended_image_submission.py +++ b/common/lib/xmodule/xmodule/open_ended_image_submission.py @@ -40,7 +40,7 @@ ALLOWABLE_IMAGE_SUFFIXES = [ ] #Maximum allowed dimensions (x and y) for an uploaded image -MAX_ALLOWED_IMAGE_DIM = 1000 +MAX_ALLOWED_IMAGE_DIM = 1500 #Dimensions to which image is resized before it is evaluated for color count, etc MAX_IMAGE_DIM = 150 From 4614687e7fe69b29972bfe77f53338c808bed877 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 5 Feb 2013 18:24:18 -0500 Subject: [PATCH 3/3] Debug image submissions --- common/lib/xmodule/xmodule/open_ended_image_submission.py | 8 ++++++-- common/lib/xmodule/xmodule/openendedchild.py | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/open_ended_image_submission.py b/common/lib/xmodule/xmodule/open_ended_image_submission.py index 196f396d65..0dba335d08 100644 --- a/common/lib/xmodule/xmodule/open_ended_image_submission.py +++ b/common/lib/xmodule/xmodule/open_ended_image_submission.py @@ -128,13 +128,15 @@ class ImageProperties(object): image_is_okay = False try: #image_is_okay = self.count_colors() and self.get_skin_ratio() and not self.image_too_large - image_is_okay = self.image_too_large + image_is_okay = not self.image_too_large except: log.exception("Could not run image tests.") if not ENABLE_PIL: image_is_okay = True + #log.debug("Image OK: {0}".format(image_is_okay)) + return image_is_okay @@ -252,7 +254,9 @@ def upload_to_s3(file_to_upload, keyname): return True, public_url except: - return False, "Could not connect to S3." + error_message = "Could not connect to S3." + log.exception(error_message) + return False, error_message def get_from_s3(s3_public_url): diff --git a/common/lib/xmodule/xmodule/openendedchild.py b/common/lib/xmodule/xmodule/openendedchild.py index 7151ac0723..88dfb83f58 100644 --- a/common/lib/xmodule/xmodule/openendedchild.py +++ b/common/lib/xmodule/xmodule/openendedchild.py @@ -316,7 +316,7 @@ class OpenEndedChild(object): image_tag = "" image_ok = False if 'can_upload_files' in get_data: - if get_data['can_upload_files'] == 'true': + if get_data['can_upload_files'] in ['true', '1']: has_file_to_upload = True file = get_data['student_file'][0] uploaded_to_s3, image_ok, s3_public_url = self.upload_image_to_s3(file) @@ -355,7 +355,7 @@ class OpenEndedChild(object): elif has_file_to_upload and not uploaded_to_s3 and image_ok: #In this case, an image was submitted by the student, but the image could not be uploaded to S3. Likely #a config issue (development vs deployment). For now, just treat this as a "success" - log.warning("Student AJAX post to combined open ended xmodule indicated that it contained an image, " + log.exception("Student AJAX post to combined open ended xmodule indicated that it contained an image, " "but the image was not able to be uploaded to S3. This could indicate a config" "issue with this deployment, but it could also indicate a problem with S3 or with the" "student image itself.") @@ -365,6 +365,8 @@ class OpenEndedChild(object): success, get_data['student_answer'] = self.check_for_url_in_text(get_data['student_answer']) overall_success = success + #log.debug("Has file: {0} Uploaded: {1} Image Ok: {2}".format(has_file_to_upload, uploaded_to_s3, image_ok)) + return overall_success, get_data def check_for_url_in_text(self, string):