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
96cbb3d3
Commit
96cbb3d3
authored
Jun 18, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small cleanups in response to Calen + Piotr's comments
parent
e061e864
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
lms/djangoapps/courseware/module_render.py
+10
-12
No files found.
lms/djangoapps/courseware/module_render.py
View file @
96cbb3d3
...
...
@@ -29,6 +29,9 @@ class I4xSystem(object):
I4xSystem objects are passed to x_modules to provide access to system
functionality.
Note that these functions can be closures over e.g. a django request
and user, or other environment-specific info.
'''
def
__init__
(
self
,
ajax_url
,
track_function
,
render_function
,
render_template
,
filestore
=
None
):
...
...
@@ -91,12 +94,9 @@ def smod_cache_lookup(cache, module_type, module_id):
return
None
def
make_track_function
(
request
):
''' We want the capa problem (and other modules) to be able to
track/log what happens inside them without adding dependencies on
Django or the rest of the codebase.
To do this in a clean way, we pass a tracking function to the module,
which calls it to log events.
'''
Make a tracking function that logs what happened.
For use in I4xSystem.
'''
import
track.views
...
...
@@ -162,11 +162,11 @@ def get_module(user, request, module_xml, student_module_cache, position=None):
# Setup system context for module instance
ajax_url
=
settings
.
MITX_ROOT_URL
+
'/modx/'
+
module_type
+
'/'
+
module_id
+
'/'
def
render_
function
(
module_xml
):
def
render_
x_module_wrapper
(
module_xml
):
return
render_x_module
(
user
,
request
,
module_xml
,
student_module_cache
,
position
)
system
=
I4xSystem
(
track_function
=
make_track_function
(
request
),
render_function
=
render_
function
,
render_function
=
render_
x_module_wrapper
,
render_template
=
render_to_string
,
ajax_url
=
ajax_url
,
filestore
=
OSFS
(
data_root
),
...
...
@@ -251,7 +251,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
return
redirect
(
'/'
)
# python concats adjacent strings
error_msg
=
(
"We're sorry, this module is temporarily unavailable."
error_msg
=
(
"We're sorry, this module is temporarily unavailable.
"
"Our staff is working to fix it as soon as possible"
)
...
...
@@ -259,7 +259,6 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
s
=
StudentModule
.
objects
.
filter
(
student
=
request
.
user
,
module_id
=
id
)
# s = StudentModule.get_with_caching(request.user, id)
if
s
is
None
or
len
(
s
)
==
0
:
log
.
debug
(
"Couldn't find module '
%
s' for user '
%
s' and id '
%
s'"
,
module
,
request
.
user
,
id
)
...
...
@@ -270,8 +269,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
oldstate
=
s
.
state
# If there are arguments, get rid of them
if
'?'
in
dispatch
:
dispatch
=
dispatch
.
split
(
'?'
)[
0
]
dispatch
,
_
,
_
=
dispatch
.
partition
(
'?'
)
ajax_url
=
'{root}/modx/{module}/{id}'
.
format
(
root
=
settings
.
MITX_ROOT_URL
,
module
=
module
,
id
=
id
)
...
...
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