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
541f5ecd
Commit
541f5ecd
authored
Aug 02, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filesubmission frontend
parent
8a983b3c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
3 deletions
+61
-3
common/lib/capa/capa/capa_problem.py
+1
-1
common/lib/capa/capa/inputtypes.py
+13
-0
common/lib/capa/capa/responsetypes.py
+1
-1
common/lib/capa/capa/templates/filesubmission.html
+3
-0
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+33
-1
lms/djangoapps/courseware/module_render.py
+10
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
541f5ecd
...
...
@@ -39,7 +39,7 @@ import responsetypes
# dict of tagname, Response Class -- this should come from auto-registering
response_tag_dict
=
dict
([(
x
.
response_tag
,
x
)
for
x
in
responsetypes
.
__all__
])
entry_types
=
[
'textline'
,
'schematic'
,
'textbox'
,
'imageinput'
,
'optioninput'
,
'choicegroup'
,
'radiogroup'
,
'checkboxgroup'
]
entry_types
=
[
'textline'
,
'schematic'
,
'textbox'
,
'imageinput'
,
'optioninput'
,
'choicegroup'
,
'radiogroup'
,
'checkboxgroup'
,
'filesubmission'
]
solution_types
=
[
'solution'
]
# extra things displayed after "show answers" is pressed
response_properties
=
[
"responseparam"
,
"answer"
]
# these get captured as student responses
...
...
common/lib/capa/capa/inputtypes.py
View file @
541f5ecd
...
...
@@ -300,6 +300,19 @@ def textline_dynamath(element, value, status, render_template, msg=''):
#-----------------------------------------------------------------------------
@register_render_function
def
filesubmission
(
element
,
value
,
status
,
render_template
,
msg
=
''
):
'''
Upload a single file (e.g. for programming assignments)
'''
eid
=
element
.
get
(
'id'
)
context
=
{
'id'
:
eid
,
}
html
=
render_template
(
"filesubmission.html"
,
context
)
return
etree
.
XML
(
html
)
#-----------------------------------------------------------------------------
## TODO: Make a wrapper for <codeinput>
@register_render_function
def
textbox
(
element
,
value
,
status
,
render_template
,
msg
=
''
):
...
...
common/lib/capa/capa/responsetypes.py
View file @
541f5ecd
...
...
@@ -805,7 +805,7 @@ class CodeResponse(LoncapaResponse):
'''
response_tag
=
'coderesponse'
allowed_inputfields
=
[
'text
line'
,
'textbox
'
]
allowed_inputfields
=
[
'text
box'
,
'filesubmission
'
]
max_inputfields
=
1
def
setup_response
(
self
):
...
...
common/lib/capa/capa/templates/filesubmission.html
0 → 100644
View file @
541f5ecd
<section
id=
"filesubmission_${id}"
class=
"filesubmission"
>
<input
type=
"file"
name=
"input_${id}"
id=
"input_${id}"
/><br
/>
</section>
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
541f5ecd
...
...
@@ -13,7 +13,7 @@ class @Problem
MathJax
.
Hub
.
Queue
[
"Typeset"
,
MathJax
.
Hub
]
window
.
update_schematics
()
@
$
(
'section.action input:button'
).
click
@
refreshAnswers
@
$
(
'section.action input.check'
).
click
@
check
@
$
(
'section.action input.check'
).
click
@
check
_fd
@
$
(
'section.action input.reset'
).
click
@
reset
@
$
(
'section.action input.show'
).
click
@
show
@
$
(
'section.action input.save'
).
click
@
save
...
...
@@ -45,6 +45,38 @@ class @Problem
$
(
'head'
)[
0
].
appendChild
(
s
[
0
])
$
(
placeholder
).
remove
()
check_fd
:
=>
Logger
.
log
'problem_check'
,
@
answers
if
not
window
.
FormData
alert
"Sorry, your browser does not support file uploads. If you can, please use Chrome or Safari which have been verified to support this feature."
return
fd
=
new
FormData
()
# For each file input, allow a single file submission,
# routed to Django 'request.FILES'
@
$
(
'input:file'
).
each
(
index
,
element
)
->
fd
.
append
(
element
.
id
,
element
.
files
[
0
])
# Simple (non-file) answers,
# routed to Django 'request.POST'
fd
.
append
(
'answers'
,
@
answers
)
settings
=
type
:
"POST"
data
:
fd
processData
:
false
contentType
:
false
success
:
(
response
)
->
switch
response
.
success
when
'incorrect'
,
'correct'
@
render
(
response
.
contents
)
@
updateProgress
response
else
alert
(
response
.
success
)
$
.
ajaxWithPrefix
(
"
#{
@
url
}
/problem_check"
,
settings
)
check
:
=>
Logger
.
log
'problem_check'
,
@
answers
$
.
postWithPrefix
"
#{
@
url
}
/problem_check"
,
@
answers
,
(
response
)
=>
...
...
lms/djangoapps/courseware/module_render.py
View file @
541f5ecd
...
...
@@ -270,6 +270,16 @@ def modx_dispatch(request, dispatch=None, id=None):
- id -- the module id. Used to look up the XModule instance
'''
# ''' (fix emacs broken parsing)
print
' THK: module_render.modx_dispatch'
print
dispatch
print
request
.
POST
.
keys
()
print
request
.
FILES
.
keys
()
if
request
.
POST
.
has_key
(
'answers'
):
print
request
.
POST
[
'answers'
]
for
filename
in
request
.
FILES
.
keys
():
uploadedFile
=
request
.
FILES
.
get
(
filename
)
print
uploadedFile
.
read
()
student_module_cache
=
StudentModuleCache
(
request
.
user
,
modulestore
()
.
get_item
(
id
))
instance
,
instance_module
,
shared_module
,
module_type
=
get_module
(
request
.
user
,
request
,
id
,
student_module_cache
)
...
...
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