Commit d06f5f77 by Vik Paruchuri

Fix file upload stuff, debug some image check routines

parent 0622dc99
...@@ -178,21 +178,38 @@ class @CombinedOpenEnded ...@@ -178,21 +178,38 @@ 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 = ""
if response.success
@rubric_wrapper.html(response.rubric_html) fd = new FormData()
@rubric_wrapper.show() fd.append('student_answer', @answer_area.val())
@child_state = 'assessing' fd.append('student_file', files)
@find_assessment_elements() fd.append('can_upload_files', files)
@rebind()
else #data = {'student_answer' : @answer_area.val(), 'file_value' : file_value, 'file_id' : file_id}
@errors_area.html(response.error) settings =
type: "POST"
data: fd
processData: false
contentType: false
success: (response) =>
if response.success
@rubric_wrapper.html(response.rubric_html)
@rubric_wrapper.show()
@child_state = 'assessing'
@find_assessment_elements()
@rebind()
else
@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,9 +70,9 @@ class URLProperties(object): ...@@ -70,9 +70,9 @@ 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
def run_tests(self): def run_tests(self):
......
...@@ -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