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
a077249a
Commit
a077249a
authored
Dec 09, 2011
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AJAX problems work
parent
7c2743d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
courseware/capa_module.py
+20
-7
courseware/capa_problem.py
+1
-0
No files found.
courseware/capa_module.py
View file @
a077249a
...
...
@@ -13,6 +13,11 @@ from django.conf import settings
from
djangomako.shortcuts
import
render_to_response
,
render_to_string
class
LoncapaModule
(
XModule
):
''' Interface between capa_problem and x_module. Originally a hack
meant to be refactored out, but it seems to be serving a useful
prupose now. We can e.g .destroy and create the capa_problem on a
reset.
'''
xml_tags
=
[
"problem"
]
id_attribute
=
"filename"
...
...
@@ -25,12 +30,15 @@ class LoncapaModule(XModule):
def
max_score
(
self
):
return
len
(
lcp
.
questions
)
def
get_html
(
self
):
inner_html
=
self
.
lcp
.
get_html
()
def
get_html
(
self
,
encapsulate
=
True
):
html
=
self
.
lcp
.
get_html
()
content
=
{
'name'
:
self
.
name
,
'html'
:
inner_html
}
return
render_to_string
(
'problem.html'
,
{
'problem'
:
content
,
'id'
:
self
.
filename
,
'done'
:
self
.
lcp
.
done
})
'html'
:
html
}
html
=
render_to_string
(
'problem.html'
,
{
'problem'
:
content
,
'id'
:
self
.
filename
,
'done'
:
self
.
lcp
.
done
})
if
encapsulate
:
html
=
'<div id="main_{id}">'
.
format
(
id
=
self
.
item_id
)
+
html
+
"</div>"
return
html
def
__init__
(
self
,
xml
,
item_id
,
ajax_url
=
None
,
track_url
=
None
,
state
=
None
):
XModule
.
__init__
(
self
,
xml
,
item_id
,
ajax_url
,
track_url
,
state
)
...
...
@@ -39,7 +47,7 @@ class LoncapaModule(XModule):
self
.
filename
=
node
.
getAttribute
(
"filename"
)
filename
=
settings
.
DATA_DIR
+
self
.
filename
+
".xml"
self
.
name
=
node
.
getAttribute
(
"name"
)
self
.
lcp
=
LoncapaProblem
(
filename
,
item_id
,
state
)
self
.
lcp
=
LoncapaProblem
(
filename
,
self
.
item_id
,
state
)
def
handle_ajax
(
self
,
dispatch
,
get
):
if
dispatch
==
'problem_check'
:
...
...
@@ -72,4 +80,9 @@ class LoncapaModule(XModule):
self
.
lcp
.
answers
=
dict
()
# Student answers
self
.
lcp
.
correct_map
=
dict
()
self
.
lcp
.
seed
=
None
return
"{}"
# Minor cleanup would be nice
# We recreate the capa_problem on a reset
filename
=
settings
.
DATA_DIR
+
self
.
filename
+
".xml"
self
.
lcp
=
LoncapaProblem
(
filename
,
self
.
item_id
,
self
.
lcp
.
get_state
())
# self.lcp.__init__(filename, self.item_id, self.lcp.get_state())
return
json
.
dumps
(
self
.
get_html
(
encapsulate
=
False
))
courseware/capa_problem.py
View file @
a077249a
...
...
@@ -37,6 +37,7 @@ class LoncapaProblem():
seed will provide the random seed. Alternatively, passing
context will bypass all script execution, and use the
given execution context. '''
print
"!!"
,
filename
,
id
if
state
!=
None
:
state
=
json
.
loads
(
state
)
else
:
...
...
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