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
3aa5df6a
Commit
3aa5df6a
authored
Jan 09, 2012
by
Ernie Park
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Piotr added comments
parent
138ff04f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
courseware/models.py
+7
-5
courseware/module_render.py
+8
-2
No files found.
courseware/models.py
View file @
3aa5df6a
...
...
@@ -41,19 +41,21 @@ from django.contrib.auth.models import User
class
StudentModule
(
models
.
Model
):
# For a homework problem, contains a JSON
# object consisting of state
module_type
=
models
.
CharField
(
max_length
=
32
,
choices
=
MODULE_TYPES
,
default
=
'problem'
)
module_id
=
models
.
CharField
(
max_length
=
255
)
# Filename for homeworks, etc.
student
=
models
.
ForeignKey
(
User
)
class
Meta
:
unique_together
=
((
'student'
,
'module_id'
,
'module_type'
),)
state
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
grade
=
models
.
FloatField
(
null
=
True
,
blank
=
True
)
student
=
models
.
ForeignKey
(
User
)
MODULE_TYPES
=
((
'problem'
,
'problem'
),
(
'video'
,
'video'
),
(
'html'
,
'html'
),
)
module_type
=
models
.
CharField
(
max_length
=
32
,
choices
=
MODULE_TYPES
,
default
=
'problem'
)
module_id
=
models
.
CharField
(
max_length
=
255
)
# Filename for homeworks, etc.
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
)
class
Meta
:
unique_together
=
((
'student'
,
'module_id'
,
'module_type'
),)
def
__unicode__
(
self
):
return
self
.
module_type
+
'/'
+
self
.
student
.
username
+
"/"
+
self
.
module_id
+
'/'
+
str
(
self
.
state
)[:
20
]
courseware/module_render.py
View file @
3aa5df6a
...
...
@@ -37,6 +37,7 @@ modx_modules={'problem':capa_module.LoncapaModule,
def
modx_dispatch
(
request
,
module
=
None
,
dispatch
=
None
,
id
=
None
):
''' Generic view for extensions. '''
# Grab the student information for the module from the database
s
=
StudentModule
.
objects
.
filter
(
module_type
=
module
,
student
=
request
.
user
,
module_id
=
id
)
...
...
@@ -52,17 +53,22 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
id_tag
=
modx_modules
[
module
]
.
id_attribute
# Grab the XML corresponding to the request from course.xml
xml
=
content_parser
.
module_xml
(
content_parser
.
course_file
(
request
.
user
),
module
,
id_tag
,
id
)
# Create the module
instance
=
modx_modules
[
module
](
xml
,
s
.
module_id
,
ajax_url
=
ajax_url
,
state
=
s
.
state
)
html
=
instance
.
handle_ajax
(
dispatch
,
request
.
POST
)
# Let the module handle the AJAX
ajax_return
=
instance
.
handle_ajax
(
dispatch
,
request
.
POST
)
# Save the state back to the database
s
.
state
=
instance
.
get_state
()
s
.
grade
=
instance
.
get_score
()[
'score'
]
s
.
save
()
return
HttpResponse
(
html
)
# Return whatever the module wanted to return to the client/caller
return
HttpResponse
(
ajax_return
)
def
vertical_module
(
request
,
module
):
''' Layout module which lays out content vertically.
...
...
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