Commit efe250f9 by Vik Paruchuri

Fix logic, make better error messages

parent 9fd36056
...@@ -562,7 +562,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): ...@@ -562,7 +562,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
self.send_to_grader(get['student_answer'], system) self.send_to_grader(get['student_answer'], system)
self.change_state(self.ASSESSING) self.change_state(self.ASSESSING)
else: else:
error_message = "There was a problem saving the image in your submission. Please try a different image." error_message = "There was a problem saving the image in your submission. Please try a different image, or try pasting a link to an image into the answer box."
return { return {
'success': True, 'success': True,
......
...@@ -318,7 +318,7 @@ class OpenEndedChild(object): ...@@ -318,7 +318,7 @@ class OpenEndedChild(object):
and the html corresponding to the uploaded image and the html corresponding to the uploaded image
""" """
has_file_to_upload = False has_file_to_upload = False
success = False uploaded_to_s3 = False
image_tag = "" image_tag = ""
if 'can_upload_files' in get_data: if 'can_upload_files' in get_data:
if get_data['can_upload_files'] == 'true': if get_data['can_upload_files'] == 'true':
...@@ -327,8 +327,8 @@ class OpenEndedChild(object): ...@@ -327,8 +327,8 @@ class OpenEndedChild(object):
uploaded_to_s3, s3_public_url = self.upload_image_to_s3(file) uploaded_to_s3, s3_public_url = self.upload_image_to_s3(file)
if uploaded_to_s3: if uploaded_to_s3:
image_tag = self.generate_image_tag_from_url(s3_public_url, file.name) image_tag = self.generate_image_tag_from_url(s3_public_url, file.name)
success = True
return success, has_file_to_upload, uploaded_to_s3, image_tag return has_file_to_upload, uploaded_to_s3, image_tag
def generate_image_tag_from_url(self, s3_public_url, image_name): def generate_image_tag_from_url(self, s3_public_url, image_name):
""" """
...@@ -353,7 +353,7 @@ class OpenEndedChild(object): ...@@ -353,7 +353,7 @@ class OpenEndedChild(object):
#If the question does not accept file uploads, do not do anything #If the question does not accept file uploads, do not do anything
return True, get_data return True, get_data
success, has_file_to_upload, uploaded_to_s3, image_tag = self.check_for_image_and_upload(get_data) has_file_to_upload, uploaded_to_s3, 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:
get_data['student_answer'] += image_tag get_data['student_answer'] += image_tag
overall_success = True overall_success = True
......
...@@ -210,7 +210,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild): ...@@ -210,7 +210,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
self.new_history_entry(get['student_answer']) self.new_history_entry(get['student_answer'])
self.change_state(self.ASSESSING) self.change_state(self.ASSESSING)
else: else:
error_message = "There was a problem saving the image in your submission. Please try a different image." error_message = "There was a problem saving the image in your submission. Please try a different image, or try pasting a link to an image into the answer box."
return { return {
'success': success, 'success': success,
......
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