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
9b640aa0
Commit
9b640aa0
authored
Mar 05, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more documentation and fix naming.
parent
385a62d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
13 deletions
+22
-13
common/lib/capa/capa/capa_problem.py
+10
-10
common/lib/capa/capa/inputtypes.py
+1
-1
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+11
-2
No files found.
common/lib/capa/capa/capa_problem.py
View file @
9b640aa0
...
...
@@ -335,16 +335,16 @@ class LoncapaProblem(object):
def
handle_input_ajax
(
self
,
get
):
'''
This passes any specialized input ajax onto the input class
InputTypes can support specialized AJAX calls. Find the correct input and pass along the correct data
It also parses
out the dispatch from the get so that it can be passed onto the input type nicely
Also, parse
out the dispatch from the get so that it can be passed onto the input type nicely
'''
# pull out the id
problem_id
=
get
[
'problem
_id'
]
if
self
.
inputs
[
problem
_id
]:
input_id
=
get
[
'input
_id'
]
if
self
.
inputs
[
input
_id
]:
dispatch
=
get
[
'dispatch'
]
return
self
.
inputs
[
problem
_id
]
.
handle_ajax
(
dispatch
,
get
)
return
self
.
inputs
[
input
_id
]
.
handle_ajax
(
dispatch
,
get
)
else
:
log
.
warning
(
"Could not find matching input for id:
%
s"
%
problem_id
)
return
{}
...
...
@@ -512,8 +512,9 @@ class LoncapaProblem(object):
msg
=
''
hint
=
''
hintmode
=
None
input_id
=
problemtree
.
get
(
'id'
)
if
problemid
in
self
.
correct_map
:
pid
=
problemtree
.
get
(
'id'
)
pid
=
input_id
status
=
self
.
correct_map
.
get_correctness
(
pid
)
msg
=
self
.
correct_map
.
get_msg
(
pid
)
hint
=
self
.
correct_map
.
get_hint
(
pid
)
...
...
@@ -524,18 +525,17 @@ class LoncapaProblem(object):
value
=
self
.
student_answers
[
problemid
]
# do the rendering
state
=
{
'value'
:
value
,
'status'
:
status
,
'id'
:
problemtree
.
get
(
'id'
)
,
'id'
:
input_id
,
'feedback'
:
{
'message'
:
msg
,
'hint'
:
hint
,
'hintmode'
:
hintmode
,
}}
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
.
inputs
[
problem
id
]
=
input_type_cls
(
self
.
system
,
problemtree
,
state
)
return
self
.
inputs
[
problem
id
]
.
get_html
()
self
.
inputs
[
input_
id
]
=
input_type_cls
(
self
.
system
,
problemtree
,
state
)
return
self
.
inputs
[
input_
id
]
.
get_html
()
# let each Response render itself
if
problemtree
in
self
.
responders
:
...
...
common/lib/capa/capa/inputtypes.py
View file @
9b640aa0
...
...
@@ -224,7 +224,7 @@ class InputTypeBase(object):
get: a dictionary containing the data that was sent with the ajax call
Output:
a dictionary object that
will then get sent back to the Javascript
a dictionary object that
can be serialized into JSON. This will be sent back to the Javascript.
"""
pass
...
...
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
9b640aa0
...
...
@@ -79,9 +79,18 @@ 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
,
problem_id
,
dispatch
,
data
,
callback
)
->
# Input:
# url: the AJAX url of the problem
# input_id: the input_id of the input you would like to make the call on
# NOTE: the id is the ${id} part of "input_${id}" during rendering
# If this function is passed the entire prefixed id, the backend may have trouble
# finding the correct input
# dispatch: string that indicates how this data should be handled by the inputtype
# callback: the function that will be called once the AJAX call has been completed.
# It will be passed a response object
@
inputAjax
:
(
url
,
input_id
,
dispatch
,
data
,
callback
)
->
data
[
'dispatch'
]
=
dispatch
data
[
'
problem_id'
]
=
problem
_id
data
[
'
input_id'
]
=
input
_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