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
385a62d7
Commit
385a62d7
authored
Mar 05, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle multiple inputs properly for ajax handling.
parent
6f535d9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
common/lib/capa/capa/capa_problem.py
+13
-5
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+2
-1
No files found.
common/lib/capa/capa/capa_problem.py
View file @
385a62d7
...
...
@@ -146,6 +146,8 @@ class LoncapaProblem(object):
if
not
self
.
student_answers
:
# True when student_answers is an empty dict
self
.
set_initial_display
()
self
.
inputs
=
{}
self
.
extracted_tree
=
self
.
_extract_html
(
self
.
tree
)
...
...
@@ -337,10 +339,16 @@ class LoncapaProblem(object):
It also parses out the dispatch from the get so that it can be passed onto the input type nicely
'''
if
self
.
input
:
# pull out the id
problem_id
=
get
[
'problem_id'
]
if
self
.
inputs
[
problem_id
]:
dispatch
=
get
[
'dispatch'
]
return
self
.
input
.
handle_ajax
(
dispatch
,
get
)
return
{}
return
self
.
inputs
[
problem_id
]
.
handle_ajax
(
dispatch
,
get
)
else
:
log
.
warning
(
"Could not find matching input for id:
%
s"
%
problem_id
)
return
{}
# ======= Private Methods Below ========
...
...
@@ -526,8 +534,8 @@ class LoncapaProblem(object):
input_type_cls
=
inputtypes
.
registry
.
get_class_for_tag
(
problemtree
.
tag
)
# save the input type so that we can make ajax calls on it if we need to
self
.
input
=
input_type_cls
(
self
.
system
,
problemtree
,
state
)
return
self
.
input
.
get_html
()
self
.
input
s
[
problemid
]
=
input_type_cls
(
self
.
system
,
problemtree
,
state
)
return
self
.
input
s
[
problemid
]
.
get_html
()
# let each Response render itself
if
problemtree
in
self
.
responders
:
...
...
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
385a62d7
...
...
@@ -79,8 +79,9 @@ class @Problem
# Use this if you want to make an ajax call on the input type object
# static method so you don't have to instantiate a Problem in order to use it
@
inputAjax
:
(
url
,
dispatch
,
data
,
callback
)
->
@
inputAjax
:
(
url
,
problem_id
,
dispatch
,
data
,
callback
)
->
data
[
'dispatch'
]
=
dispatch
data
[
'problem_id'
]
=
problem_id
$
.
postWithPrefix
"
#{
url
}
/input_ajax"
,
data
,
callback
...
...
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