Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
0622dc99
Commit
0622dc99
authored
Jan 29, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Javascript to handle file uploads
parent
fbdc190a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
10 deletions
+14
-10
common/lib/xmodule/xmodule/combined_open_ended_module.py
+3
-3
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+5
-5
common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee
+5
-2
common/lib/xmodule/xmodule/self_assessment_module.py
+1
-0
No files found.
common/lib/xmodule/xmodule/combined_open_ended_module.py
View file @
0622dc99
...
...
@@ -39,7 +39,7 @@ MAX_SCORE = 1
MAX_SCORE_ALLOWED
=
3
IS_SCORED
=
False
ACCEPT_FILE_UPLOAD
=
Fals
e
ACCEPT_FILE_UPLOAD
=
Tru
e
class
CombinedOpenEndedModule
(
XModule
):
"""
...
...
@@ -141,8 +141,8 @@ class CombinedOpenEndedModule(XModule):
#Allow reset is true if student has failed the criteria to move to the next child task
self
.
allow_reset
=
instance_state
.
get
(
'ready_to_reset'
,
False
)
self
.
max_attempts
=
int
(
self
.
metadata
.
get
(
'attempts'
,
MAX_ATTEMPTS
))
self
.
is_scored
=
(
self
.
metadata
.
get
(
'is_graded'
,
IS_SCORED
)
==
"True"
)
self
.
accept_file_upload
=
(
self
.
metadata
.
get
(
'accept_file_upload'
,
ACCEPT_FILE_UPLOAD
)
==
"True"
)
self
.
is_scored
=
(
self
.
metadata
.
get
(
'is_graded'
,
IS_SCORED
)
in
[
True
,
"True"
]
)
self
.
accept_file_upload
=
(
self
.
metadata
.
get
(
'accept_file_upload'
,
ACCEPT_FILE_UPLOAD
)
in
[
True
,
"True"
]
)
log
.
debug
(
self
.
metadata
.
get
(
'is_graded'
,
IS_SCORED
))
...
...
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
0622dc99
...
...
@@ -140,15 +140,15 @@ class @Problem
allowed_files
=
$
(
element
).
data
(
"allowed_files"
)
for
file
in
element
.
files
if
allowed_files
.
length
!=
0
and
file
.
name
not
in
allowed_files
unallowed_file_submitted
=
true
errors
.
push
"You submitted
#{
file
.
name
}
; only
#{
allowed_files
}
are allowed."
unallowed_file_submitted
=
true
errors
.
push
"You submitted
#{
file
.
name
}
; only
#{
allowed_files
}
are allowed."
if
file
.
name
in
required_files
required_files
.
splice
(
required_files
.
indexOf
(
file
.
name
),
1
)
required_files
.
splice
(
required_files
.
indexOf
(
file
.
name
),
1
)
if
file
.
size
>
max_filesize
file_too_large
=
true
errors
.
push
'Your file "'
+
file
.
name
'" is too large (max size: '
+
max_filesize
/
(
1000
*
1000
)
+
' MB)'
fd
.
append
(
element
.
id
,
file
)
if
element
.
files
.
length
==
0
if
element
.
files
.
length
==
0
file_not_selected
=
true
fd
.
append
(
element
.
id
,
''
)
# In case we want to allow submissions with no file
if
required_files
.
length
!=
0
...
...
@@ -157,7 +157,7 @@ class @Problem
else
fd
.
append
(
element
.
id
,
element
.
value
)
if
file_not_selected
errors
.
push
'You did not select any files to submit'
...
...
common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee
View file @
0622dc99
...
...
@@ -179,7 +179,11 @@ class @CombinedOpenEnded
save_answer
:
(
event
)
=>
event
.
preventDefault
()
if
@
child_state
==
'initial'
data
=
{
'student_answer'
:
@
answer_area
.
val
()}
file_data
=
""
if
@
can_upload_files
==
true
files
=
$
(
'.file-upload-box'
)[
0
].
files
[
0
]
file_data
=
files
data
=
{
'student_answer'
:
@
answer_area
.
val
(),
'file_data'
:
file_data
}
$
.
postWithPrefix
"
#{
@
ajax_url
}
/save_answer"
,
data
,
(
response
)
=>
if
response
.
success
@
rubric_wrapper
.
html
(
response
.
rubric_html
)
...
...
@@ -307,7 +311,6 @@ class @CombinedOpenEnded
setup_file_upload
:
=>
if
window
.
File
and
window
.
FileReader
and
window
.
FileList
and
window
.
Blob
alert
(
'File API supported.'
)
if
@
accept_file_upload
==
"True"
@
can_upload_files
=
true
@
file_upload_area
.
html
(
'<input type="file" class="file-upload-box">'
)
...
...
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
0622dc99
...
...
@@ -107,6 +107,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
if
dispatch
not
in
handlers
:
return
'Error'
log
.
debug
(
get
)
before
=
self
.
get_progress
()
d
=
handlers
[
dispatch
](
get
,
system
)
after
=
self
.
get_progress
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment