Commit d06f5f77 by Vik Paruchuri

Fix file upload stuff, debug some image check routines

parent 0622dc99
...@@ -178,13 +178,27 @@ class @CombinedOpenEnded ...@@ -178,13 +178,27 @@ class @CombinedOpenEnded
save_answer: (event) => save_answer: (event) =>
event.preventDefault() event.preventDefault()
max_filesize = 2*1000*1000 #2MB
if @child_state == 'initial' if @child_state == 'initial'
file_data = "" files = ""
if @can_upload_files == true if @can_upload_files == true
files = $('.file-upload-box')[0].files[0] files = $('.file-upload-box')[0].files[0]
file_data = files if files.size > max_filesize
data = {'student_answer' : @answer_area.val(), 'file_data' : file_data} @can_upload_files = false
$.postWithPrefix "#{@ajax_url}/save_answer", data, (response) => files = ""
fd = new FormData()
fd.append('student_answer', @answer_area.val())
fd.append('student_file', files)
fd.append('can_upload_files', files)
#data = {'student_answer' : @answer_area.val(), 'file_value' : file_value, 'file_id' : file_id}
settings =
type: "POST"
data: fd
processData: false
contentType: false
success: (response) =>
if response.success if response.success
@rubric_wrapper.html(response.rubric_html) @rubric_wrapper.html(response.rubric_html)
@rubric_wrapper.show() @rubric_wrapper.show()
...@@ -193,6 +207,9 @@ class @CombinedOpenEnded ...@@ -193,6 +207,9 @@ class @CombinedOpenEnded
@rebind() @rebind()
else else
@errors_area.html(response.error) @errors_area.html(response.error)
$.ajaxWithPrefix("#{@ajax_url}/save_answer",settings)
else else
@errors_area.html('Problem state got out of sync. Try reloading the page.') @errors_area.html('Problem state got out of sync. Try reloading the page.')
......
...@@ -70,7 +70,7 @@ class URLProperties(object): ...@@ -70,7 +70,7 @@ class URLProperties(object):
def check_suffix(self): def check_suffix(self):
good_suffix = False good_suffix = False
for suffix in ALLOWABLE_IMAGE_SUFFIXES: for suffix in ALLOWABLE_IMAGE_SUFFIXES:
if self.url_string.endswith(suffix) if self.url_string.endswith(suffix):
good_suffix = True good_suffix = True
break break
return good_suffix return good_suffix
......
...@@ -23,6 +23,7 @@ from .stringify import stringify_children ...@@ -23,6 +23,7 @@ from .stringify import stringify_children
from .xml_module import XmlDescriptor from .xml_module import XmlDescriptor
from xmodule.modulestore import Location from xmodule.modulestore import Location
from capa.util import * from capa.util import *
import open_ended_image_submission
from datetime import datetime from datetime import datetime
...@@ -274,12 +275,13 @@ class OpenEndedChild(object): ...@@ -274,12 +275,13 @@ class OpenEndedChild(object):
correctness = 'correct' if self.is_submission_correct(score) else 'incorrect' correctness = 'correct' if self.is_submission_correct(score) else 'incorrect'
return correctness return correctness
def should_request_image(self): def upload_image_to_s3(self, image_data):
""" """
@return: @return:
""" """
pass success = False
image_ok = run_image_checks(image)
......
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