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
2019e672
Commit
2019e672
authored
Jun 27, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get capa problems to display from a keystore
parent
f8dba456
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
41 additions
and
104 deletions
+41
-104
common/lib/xmodule/capa_module.py
+0
-0
common/lib/xmodule/setup.py
+2
-1
common/lib/xmodule/vertical_module.py
+4
-1
lms/djangoapps/courseware/module_render.py
+21
-88
lms/lib/dogfood/views.py
+1
-1
lms/static/coffee/src/courseware.coffee
+2
-2
lms/static/coffee/src/modules/problem.coffee
+8
-8
lms/static/coffee/src/modules/sequence.coffee
+1
-1
lms/templates/problem_ajax.html
+1
-1
lms/urls.py
+1
-1
No files found.
common/lib/xmodule/capa_module.py
View file @
2019e672
This diff is collapsed.
Click to expand it.
common/lib/xmodule/setup.py
View file @
2019e672
...
...
@@ -19,9 +19,10 @@ setup(
"section = xmodule.translation_module:SemanticSectionDescriptor"
,
"sequential = xmodule.seq_module:SequenceDescriptor"
,
"vertical = xmodule.vertical_module:VerticalDescriptor"
,
"problem = xmodule.capa_module:CapaDescriptor"
,
"problemset = xmodule.seq_module:SequenceDescriptor"
,
"videosequence = xmodule.seq_module:SequenceDescriptor"
,
"video = xmodule.video_module:VideoDescriptor"
,
"videosequence = xmodule.seq_module:SequenceDescriptor"
,
]
}
)
common/lib/xmodule/vertical_module.py
View file @
2019e672
...
...
@@ -10,6 +10,9 @@ class_priority = ['video', 'problem']
class
VerticalModule
(
XModule
):
''' Layout module for laying out submodules vertically.'''
def
get_html
(
self
):
if
self
.
contents
is
None
:
self
.
contents
=
[
child
.
get_html
()
for
child
in
self
.
get_display_items
()]
return
self
.
system
.
render_template
(
'vert_module.html'
,
{
'items'
:
self
.
contents
})
...
...
@@ -31,7 +34,7 @@ class VerticalModule(XModule):
def
__init__
(
self
,
system
,
location
,
definition
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
instance_state
,
shared_state
,
**
kwargs
)
self
.
contents
=
[
child
.
get_html
()
for
child
in
self
.
get_display_items
()]
self
.
contents
=
None
class
VerticalDescriptor
(
SequenceDescriptor
):
...
...
lms/djangoapps/courseware/module_render.py
View file @
2019e672
...
...
@@ -60,13 +60,7 @@ class I4xSystem(object):
'''
self
.
ajax_url
=
ajax_url
self
.
track_function
=
track_function
if
not
filestore
:
self
.
filestore
=
OSFS
(
settings
.
DATA_DIR
)
else
:
self
.
filestore
=
filestore
if
settings
.
DEBUG
:
log
.
info
(
"[courseware.module_render.I4xSystem] filestore path =
%
s"
,
filestore
)
self
.
filestore
=
filestore
self
.
get_module
=
get_module
self
.
render_function
=
render_function
self
.
render_template
=
render_template
...
...
@@ -241,7 +235,7 @@ def get_module(user, request, location, student_module_cache, position=None):
shared_state
=
shared_module
.
state
if
shared_module
is
not
None
else
None
# Setup system context for module instance
ajax_url
=
settings
.
MITX_ROOT_URL
+
'/modx/'
+
descriptor
.
type
+
'/'
+
descriptor
.
url
+
'/'
ajax_url
=
settings
.
MITX_ROOT_URL
+
'/modx/'
+
descriptor
.
url
+
'/'
def
_get_module
(
location
):
(
module
,
_
,
_
,
_
)
=
get_module
(
user
,
request
,
location
,
student_module_cache
,
position
)
...
...
@@ -330,94 +324,33 @@ def render_x_module(user, request, module_xml, student_module_cache, position=No
return
context
def
modx_dispatch
(
request
,
module
=
None
,
dispatch
=
None
,
id
=
None
):
def
modx_dispatch
(
request
,
dispatch
=
None
,
id
=
None
):
''' Generic view for extensions. This is where AJAX calls go.
Arguments:
- request -- the django request.
- module -- the type of the module, as used in the course configuration xml.
e.g. 'problem', 'video', etc
- dispatch -- the command string to pass through to the module's handle_ajax call
(e.g. 'problem_reset'). If this string contains '?', only pass
through the part before the first '?'.
- id -- the module id. Used to look up the student module.
e.g. filenamexformularesponse
- id -- the module id. Used to look up the XModule instance
'''
# ''' (fix emacs broken parsing)
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/'
)
# python concats adjacent strings
error_msg
=
(
"We're sorry, this module is temporarily unavailable. "
"Our staff is working to fix it as soon as possible"
)
# If there are arguments, get rid of them
dispatch
,
_
,
_
=
dispatch
.
partition
(
'?'
)
ajax_url
=
'{root}/modx/{module}/{id}'
.
format
(
root
=
settings
.
MITX_ROOT_URL
,
module
=
module
,
id
=
id
)
coursename
=
multicourse_settings
.
get_coursename_from_request
(
request
)
if
coursename
and
settings
.
ENABLE_MULTICOURSE
:
xp
=
multicourse_settings
.
get_course_xmlpath
(
coursename
)
data_root
=
settings
.
DATA_DIR
+
xp
else
:
data_root
=
settings
.
DATA_DIR
student_module_cache
=
StudentModuleCache
(
request
.
user
,
keystore
()
.
get_item
(
id
))
instance
,
instance_module
,
shared_module
,
module_type
=
get_module
(
request
.
user
,
request
,
id
,
student_module_cache
)
# Grab the XML corresponding to the request from course.xml
try
:
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
except
:
log
.
exception
(
"Unable to load module during ajax call. module=
%
s, dispatch=
%
s, id=
%
s"
,
module
,
dispatch
,
id
)
if
accepts
(
request
,
'text/html'
):
return
render_to_response
(
"module-error.html"
,
{})
else
:
response
=
HttpResponse
(
json
.
dumps
({
'success'
:
error_msg
}))
return
response
module_xml
=
etree
.
fromstring
(
xml
)
student_module_cache
=
StudentModuleCache
(
request
.
user
,
module_xml
)
(
instance
,
instance_state
,
shared_state
,
module_type
)
=
get_module
(
request
.
user
,
request
,
module_xml
,
student_module_cache
,
None
)
if
instance_state
is
None
:
log
.
debug
(
"Couldn't find module '
%
s' for user '
%
s' and id '
%
s'"
,
module
,
request
.
user
,
id
)
if
instance_module
is
None
:
log
.
debug
(
"Couldn't find module '
%
s' for user '
%
s'"
,
id
,
request
.
user
)
raise
Http404
oldgrade
=
instance_state
.
grade
old_instance_state
=
instance_state
.
state
old_shared_state
=
shared_state
.
state
if
shared_state
is
not
None
else
None
module_from_xml
=
make_module_from_xml_fn
(
request
.
user
,
request
,
student_module_cache
,
None
)
# Create the module
system
=
I4xSystem
(
track_function
=
make_track_function
(
request
),
render_function
=
None
,
module_from_xml
=
module_from_xml
,
render_template
=
render_to_string
,
ajax_url
=
ajax_url
,
request
=
request
,
filestore
=
OSFS
(
data_root
),
)
try
:
module_class
=
xmodule
.
get_module_class
(
module
)
instance
=
module_class
(
system
,
xml
,
id
,
instance_state
=
old_instance_state
,
shared_state
=
old_shared_state
)
except
:
log
.
exception
(
"Unable to load module instance during ajax call"
)
if
accepts
(
request
,
'text/html'
):
return
render_to_response
(
"module-error.html"
,
{})
else
:
response
=
HttpResponse
(
json
.
dumps
({
'success'
:
error_msg
}))
return
response
oldgrade
=
instance_module
.
grade
old_instance_state
=
instance_module
.
state
old_shared_state
=
shared_module
.
state
if
shared_module
is
not
None
else
None
# Let the module handle the AJAX
try
:
...
...
@@ -427,16 +360,16 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
raise
# Save the state back to the database
instance_
stat
e
.
state
=
instance
.
get_instance_state
()
instance_
modul
e
.
state
=
instance
.
get_instance_state
()
if
instance
.
get_score
():
instance_
stat
e
.
grade
=
instance
.
get_score
()[
'score'
]
if
instance_
state
.
grade
!=
oldgrade
or
instance_stat
e
.
state
!=
old_instance_state
:
instance_
stat
e
.
save
()
if
shared_
stat
e
is
not
None
:
shared_
stat
e
.
state
=
instance
.
get_shared_state
()
if
shared_
stat
e
.
state
!=
old_shared_state
:
shared_
stat
e
.
save
()
instance_
modul
e
.
grade
=
instance
.
get_score
()[
'score'
]
if
instance_
module
.
grade
!=
oldgrade
or
instance_modul
e
.
state
!=
old_instance_state
:
instance_
modul
e
.
save
()
if
shared_
modul
e
is
not
None
:
shared_
modul
e
.
state
=
instance
.
get_shared_state
()
if
shared_
modul
e
.
state
!=
old_shared_state
:
shared_
modul
e
.
save
()
# Return whatever the module wanted to return to the client/caller
return
HttpResponse
(
ajax_return
)
lms/lib/dogfood/views.py
View file @
2019e672
...
...
@@ -174,7 +174,7 @@ def quickedit(request, id=None, qetemplate='quickedit.html',coursename=None):
module
=
'problem'
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
ajax_url
=
settings
.
MITX_ROOT_URL
+
'/modx/'
+
module
+
'/'
+
id
+
'/'
ajax_url
=
settings
.
MITX_ROOT_URL
+
'/modx/'
+
id
+
'/'
# Create the module (instance of capa_module.Module)
system
=
I4xSystem
(
track_function
=
make_track_function
(
request
),
...
...
lms/static/coffee/src/courseware.coffee
View file @
2019e672
...
...
@@ -20,8 +20,8 @@ class @Courseware
id
=
$
(
this
).
attr
(
'id'
).
replace
(
/video_/
,
''
)
new
Video
id
,
$
(
this
).
data
(
'streams'
)
$
(
'.course-content .problems-wrapper'
).
each
->
id
=
$
(
this
).
attr
(
'
id'
).
replace
(
/problem_/
,
'
'
)
new
Problem
id
,
$
(
this
).
data
(
'url'
)
id
=
$
(
this
).
attr
(
'
problem-id
'
)
new
Problem
id
,
$
(
this
).
attr
(
'id'
),
$
(
this
).
data
(
'url'
)
$
(
'.course-content .histogram'
).
each
->
id
=
$
(
this
).
attr
(
'id'
).
replace
(
/histogram_/
,
''
)
new
Histogram
id
,
$
(
this
).
data
(
'histogram'
)
lms/static/coffee/src/modules/problem.coffee
View file @
2019e672
class
@
Problem
constructor
:
(
@
id
,
url
)
->
@
element
=
$
(
"#
problem_
#{
id
}
"
)
constructor
:
(
@
id
,
@
element_id
,
url
)
->
@
element
=
$
(
"#
#{
element_
id
}
"
)
@
render
()
$
:
(
selector
)
->
...
...
@@ -26,13 +26,13 @@ class @Problem
@
element
.
html
(
content
)
@
bind
()
else
$
.
postWithPrefix
"/modx/
problem/
#{
@
id
}
/problem_get"
,
(
response
)
=>
$
.
postWithPrefix
"/modx/
#{
@
id
}
/problem_get"
,
(
response
)
=>
@
element
.
html
(
response
.
html
)
@
bind
()
check
:
=>
Logger
.
log
'problem_check'
,
@
answers
$
.
postWithPrefix
"/modx/
problem/
#{
@
id
}
/problem_check"
,
@
answers
,
(
response
)
=>
$
.
postWithPrefix
"/modx/
#{
@
id
}
/problem_check"
,
@
answers
,
(
response
)
=>
switch
response
.
success
when
'incorrect'
,
'correct'
@
render
(
response
.
contents
)
...
...
@@ -42,14 +42,14 @@ class @Problem
reset
:
=>
Logger
.
log
'problem_reset'
,
@
answers
$
.
postWithPrefix
"/modx/
problem/
#{
@
id
}
/problem_reset"
,
id
:
@
id
,
(
response
)
=>
$
.
postWithPrefix
"/modx/
#{
@
id
}
/problem_reset"
,
id
:
@
id
,
(
response
)
=>
@
render
(
response
.
html
)
@
updateProgress
response
show
:
=>
if
!
@
element
.
hasClass
'showed'
Logger
.
log
'problem_show'
,
problem
:
@
id
$
.
postWithPrefix
"/modx/
problem/
#{
@
id
}
/problem_show"
,
(
response
)
=>
$
.
postWithPrefix
"/modx/
#{
@
id
}
/problem_show"
,
(
response
)
=>
answers
=
response
.
answers
$
.
each
answers
,
(
key
,
value
)
=>
if
$
.
isArray
(
value
)
...
...
@@ -69,7 +69,7 @@ class @Problem
save
:
=>
Logger
.
log
'problem_save'
,
@
answers
$
.
postWithPrefix
"/modx/
problem/
#{
@
id
}
/problem_save"
,
@
answers
,
(
response
)
=>
$
.
postWithPrefix
"/modx/
#{
@
id
}
/problem_save"
,
@
answers
,
(
response
)
=>
if
response
.
success
alert
'Saved'
@
updateProgress
response
...
...
@@ -94,4 +94,4 @@ class @Problem
element
.
schematic
.
update_value
()
@
$
(
".CodeMirror"
).
each
(
index
,
element
)
->
element
.
CodeMirror
.
save
()
if
element
.
CodeMirror
.
save
@
answers
=
@
$
(
"[id^=input_
#{
@
id
}
_]"
).
serialize
()
@
answers
=
@
$
(
"[id^=input_
#{
@
element_
id
}
_]"
).
serialize
()
lms/static/coffee/src/modules/sequence.coffee
View file @
2019e672
...
...
@@ -88,7 +88,7 @@ class @Sequence
if
@
position
!=
new_position
if
@
position
!=
undefined
@
mark_visited
@
position
$
.
postWithPrefix
"/modx/
#{
@
tag
}
/
#{
@
id
}
/goto_position"
,
position
:
new_position
$
.
postWithPrefix
"/modx/
#{
@
id
}
/goto_position"
,
position
:
new_position
@
mark_active
new_position
@
$
(
'#seq_content'
).
html
@
elements
[
new_position
-
1
].
content
...
...
lms/templates/problem_ajax.html
View file @
2019e672
<section
id=
"problem_${
id}"
class=
"problems-wrapper
"
data-url=
"${ajax_url}"
></section>
<section
id=
"problem_${
element_id}"
class=
"problems-wrapper"
problem-id=
"${id}
"
data-url=
"${ajax_url}"
></section>
lms/urls.py
View file @
2019e672
...
...
@@ -57,7 +57,7 @@ if settings.COURSEWARE_ENABLED:
url
(
r'^courseware/(?P<course>[^/]*)/$'
,
'courseware.views.index'
,
name
=
"courseware_course"
),
url
(
r'^jumpto/(?P<probname>[^/]+)/$'
,
'courseware.views.jump_to'
),
url
(
r'^section/(?P<section>[^/]*)/$'
,
'courseware.views.render_section'
),
url
(
r'^modx/(?P<
module>[^/]*)/(?P<id>[^/]*
)/(?P<dispatch>[^/]*)$'
,
'courseware.module_render.modx_dispatch'
),
#reset_problem'),
url
(
r'^modx/(?P<
id>.*?
)/(?P<dispatch>[^/]*)$'
,
'courseware.module_render.modx_dispatch'
),
#reset_problem'),
url
(
r'^profile$'
,
'courseware.views.profile'
),
url
(
r'^profile/(?P<student_id>[^/]*)/$'
,
'courseware.views.profile'
),
url
(
r'^change_setting$'
,
'student.views.change_setting'
),
...
...
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