Commit bbf37ef9 by Diana Huang

Merge pull request #1446 from MITx/fix/vik/peer-grading-images

Fix/vik/peer grading images
parents c68b0d3c 463f3161
......@@ -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
......@@ -128,10 +128,16 @@ 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 = 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
......@@ -250,7 +256,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):
......
......@@ -339,7 +339,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)
......@@ -378,7 +378,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.")
......@@ -388,6 +388,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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment