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
cec3475c
Commit
cec3475c
authored
Mar 06, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove references to .definition and .metadata in modules
parent
af3c92c4
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
84 additions
and
91 deletions
+84
-91
cms/djangoapps/models/settings/course_grading.py
+4
-4
common/djangoapps/terrain/factories.py
+10
-9
common/lib/xmodule/xmodule/course_module.py
+3
-0
common/lib/xmodule/xmodule/foldit_module.py
+19
-25
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+4
-4
common/lib/xmodule/xmodule/videoalpha_module.py
+10
-12
lms/djangoapps/courseware/courses.py
+1
-1
lms/djangoapps/courseware/features/courses.py
+4
-4
lms/djangoapps/courseware/tests/test_access.py
+0
-3
lms/djangoapps/courseware/tests/tests.py
+1
-1
lms/djangoapps/courseware/views.py
+1
-1
lms/djangoapps/django_comment_client/base/views.py
+7
-7
lms/djangoapps/django_comment_client/forum/views.py
+8
-8
lms/djangoapps/django_comment_client/tests.py
+1
-1
lms/djangoapps/django_comment_client/utils.py
+2
-2
lms/djangoapps/instructor/views.py
+5
-5
lms/djangoapps/staticbook/views.py
+4
-4
No files found.
cms/djangoapps/models/settings/course_grading.py
View file @
cec3475c
...
@@ -135,7 +135,7 @@ class CourseGradingModel(object):
...
@@ -135,7 +135,7 @@ class CourseGradingModel(object):
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
.
grade_cutoffs
=
cutoffs
descriptor
.
grade_cutoffs
=
cutoffs
get_modulestore
(
course_location
)
.
update_item
(
course_location
,
descriptor
.
definition
[
'data'
]
)
get_modulestore
(
course_location
)
.
update_item
(
course_location
,
descriptor
.
_model_data
.
_kvs
.
_data
)
return
cutoffs
return
cutoffs
...
@@ -203,8 +203,8 @@ class CourseGradingModel(object):
...
@@ -203,8 +203,8 @@ class CourseGradingModel(object):
course_location
=
Location
(
course_location
)
course_location
=
Location
(
course_location
)
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
if
'graceperiod'
in
descriptor
.
metadata
:
del
descriptor
.
metadata
[
'graceperiod'
]
del
descriptor
.
lms
.
graceperiod
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
_model_data
.
_kvs
.
_data
)
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
_model_data
.
_kvs
.
_
meta
data
)
@staticmethod
@staticmethod
def
get_section_grader_type
(
location
):
def
get_section_grader_type
(
location
):
...
@@ -213,7 +213,7 @@ class CourseGradingModel(object):
...
@@ -213,7 +213,7 @@ class CourseGradingModel(object):
descriptor
=
get_modulestore
(
location
)
.
get_item
(
location
)
descriptor
=
get_modulestore
(
location
)
.
get_item
(
location
)
return
{
return
{
"graderType"
:
descriptor
.
metadata
.
get
(
'format'
,
u"Not Graded"
)
,
"graderType"
:
descriptor
.
lms
.
format
or
'Not Graded'
,
"location"
:
location
,
"location"
:
location
,
"id"
:
99
# just an arbitrary value to
"id"
:
99
# just an arbitrary value to
}
}
...
...
common/djangoapps/terrain/factories.py
View file @
cec3475c
...
@@ -7,13 +7,14 @@ from xmodule.modulestore.django import modulestore
...
@@ -7,13 +7,14 @@ from xmodule.modulestore.django import modulestore
from
time
import
gmtime
from
time
import
gmtime
from
uuid
import
uuid4
from
uuid
import
uuid4
from
xmodule.timeparse
import
stringify_time
from
xmodule.timeparse
import
stringify_time
from
xmodule.modulestore.inheritance
import
own_metadata
class
GroupFactory
(
Factory
):
class
GroupFactory
(
Factory
):
FACTORY_FOR
=
Group
FACTORY_FOR
=
Group
name
=
'staff_MITx/999/Robot_Super_Course'
name
=
'staff_MITx/999/Robot_Super_Course'
class
UserProfileFactory
(
Factory
):
class
UserProfileFactory
(
Factory
):
FACTORY_FOR
=
UserProfile
FACTORY_FOR
=
UserProfile
...
@@ -81,18 +82,18 @@ class XModuleCourseFactory(Factory):
...
@@ -81,18 +82,18 @@ class XModuleCourseFactory(Factory):
# This metadata code was copied from cms/djangoapps/contentstore/views.py
# This metadata code was copied from cms/djangoapps/contentstore/views.py
if
display_name
is
not
None
:
if
display_name
is
not
None
:
new_course
.
metadata
[
'display_name'
]
=
display_name
new_course
.
lms
.
display_name
=
display_name
new_course
.
metadata
[
'data_dir'
]
=
uuid4
()
.
hex
new_course
.
data_dir
=
uuid4
()
.
hex
new_course
.
metadata
[
'start'
]
=
stringify_time
(
gmtime
()
)
new_course
.
lms
.
start
=
gmtime
(
)
new_course
.
tabs
=
[{
"type"
:
"courseware"
},
new_course
.
tabs
=
[{
"type"
:
"courseware"
},
{
"type"
:
"course_info"
,
"name"
:
"Course Info"
},
{
"type"
:
"course_info"
,
"name"
:
"Course Info"
},
{
"type"
:
"discussion"
,
"name"
:
"Discussion"
},
{
"type"
:
"discussion"
,
"name"
:
"Discussion"
},
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
},
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
},
{
"type"
:
"progress"
,
"name"
:
"Progress"
}]
{
"type"
:
"progress"
,
"name"
:
"Progress"
}]
# Update the data in the mongo datastore
# Update the data in the mongo datastore
store
.
update_metadata
(
new_course
.
location
.
url
(),
new_course
.
own_metadata
)
store
.
update_metadata
(
new_course
.
location
.
url
(),
own_metadata
(
new_course
)
)
return
new_course
return
new_course
...
@@ -140,16 +141,16 @@ class XModuleItemFactory(Factory):
...
@@ -140,16 +141,16 @@ class XModuleItemFactory(Factory):
new_item
=
store
.
clone_item
(
template
,
dest_location
)
new_item
=
store
.
clone_item
(
template
,
dest_location
)
# TODO: This needs to be deleted when we have proper storage for static content
# TODO: This needs to be deleted when we have proper storage for static content
new_item
.
metadata
[
'data_dir'
]
=
parent
.
metadata
[
'data_dir'
]
new_item
.
data_dir
=
parent
.
data_dir
# replace the display name with an optional parameter passed in from the caller
# replace the display name with an optional parameter passed in from the caller
if
display_name
is
not
None
:
if
display_name
is
not
None
:
new_item
.
metadata
[
'display_name'
]
=
display_name
new_item
.
lms
.
display_name
=
display_name
store
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
store
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
if
new_item
.
location
.
category
not
in
DETACHED_CATEGORIES
:
if
new_item
.
location
.
category
not
in
DETACHED_CATEGORIES
:
store
.
update_children
(
parent_location
,
parent
.
definition
.
get
(
'children'
,
[])
+
[
new_item
.
location
.
url
()])
store
.
update_children
(
parent_location
,
parent
.
children
+
[
new_item
.
location
.
url
()])
return
new_item
return
new_item
...
...
common/lib/xmodule/xmodule/course_module.py
View file @
cec3475c
...
@@ -175,6 +175,9 @@ class CourseDescriptor(SequenceDescriptor):
...
@@ -175,6 +175,9 @@ class CourseDescriptor(SequenceDescriptor):
no_grade
=
Boolean
(
help
=
"True if this course isn't graded"
,
default
=
False
,
scope
=
Scope
.
settings
)
no_grade
=
Boolean
(
help
=
"True if this course isn't graded"
,
default
=
False
,
scope
=
Scope
.
settings
)
disable_progress_graph
=
Boolean
(
help
=
"True if this course shouldn't display the progress graph"
,
default
=
False
,
scope
=
Scope
.
settings
)
disable_progress_graph
=
Boolean
(
help
=
"True if this course shouldn't display the progress graph"
,
default
=
False
,
scope
=
Scope
.
settings
)
pdf_textbooks
=
List
(
help
=
"List of dictionaries containing pdf_textbook configuration"
,
default
=
None
,
scope
=
Scope
.
settings
)
pdf_textbooks
=
List
(
help
=
"List of dictionaries containing pdf_textbook configuration"
,
default
=
None
,
scope
=
Scope
.
settings
)
remote_gradebook
=
String
(
scope
=
Scope
.
settings
,
default
=
''
)
allow_anonymous
=
Boolean
(
scope
=
Scope
.
settings
,
default
=
True
)
allow_anonymous_to_peers
=
Boolean
(
scope
=
Scope
.
settings
,
default
=
False
)
has_children
=
True
has_children
=
True
info_sidebar_name
=
String
(
scope
=
Scope
.
settings
,
default
=
'Course Handouts'
)
info_sidebar_name
=
String
(
scope
=
Scope
.
settings
,
default
=
'Course Handouts'
)
...
...
common/lib/xmodule/xmodule/foldit_module.py
View file @
cec3475c
...
@@ -7,6 +7,7 @@ from pkg_resources import resource_string
...
@@ -7,6 +7,7 @@ from pkg_resources import resource_string
from
xmodule.editing_module
import
EditingDescriptor
from
xmodule.editing_module
import
EditingDescriptor
from
xmodule.x_module
import
XModule
from
xmodule.x_module
import
XModule
from
xmodule.xml_module
import
XmlDescriptor
from
xmodule.xml_module
import
XmlDescriptor
from
xblock.core
import
Scope
,
Integer
,
String
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -14,10 +15,16 @@ class FolditModule(XModule):
...
@@ -14,10 +15,16 @@ class FolditModule(XModule):
css
=
{
'scss'
:
[
resource_string
(
__name__
,
'css/foldit/leaderboard.scss'
)]}
css
=
{
'scss'
:
[
resource_string
(
__name__
,
'css/foldit/leaderboard.scss'
)]}
def
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
# default to what Spring_7012x uses
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
required_level
=
Integer
(
default
=
4
,
scope
=
Scope
.
settings
)
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
required_sublevel
=
Integer
(
default
=
5
,
scope
=
Scope
.
settings
)
instance_state
,
shared_state
,
**
kwargs
)
due
=
String
(
help
=
"Date that this problem is due by"
,
scope
=
Scope
.
settings
,
default
=
''
)
show_basic_score
=
String
(
scope
=
Scope
.
settings
,
default
=
'false'
)
show_leaderboard
=
String
(
scope
=
Scope
.
settings
,
default
=
'false'
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
XModule
.
__init__
(
self
,
*
args
,
**
kwargs
)
"""
"""
Example:
Example:
...
@@ -26,25 +33,17 @@ class FolditModule(XModule):
...
@@ -26,25 +33,17 @@ class FolditModule(XModule):
required_sublevel="3"
required_sublevel="3"
show_leaderboard="false"/>
show_leaderboard="false"/>
"""
"""
req_level
=
self
.
metadata
.
get
(
"required_level"
)
req_sublevel
=
self
.
metadata
.
get
(
"required_sublevel"
)
# default to what Spring_7012x uses
self
.
required_level
=
req_level
if
req_level
else
4
self
.
required_sublevel
=
req_sublevel
if
req_sublevel
else
5
def
parse_due_date
():
def
parse_due_date
():
"""
"""
Pull out the date, or None
Pull out the date, or None
"""
"""
s
=
self
.
metadata
.
get
(
"due"
)
s
=
self
.
due
if
s
:
if
s
:
return
parser
.
parse
(
s
)
return
parser
.
parse
(
s
)
else
:
else
:
return
None
return
None
self
.
due_str
=
self
.
metadata
.
get
(
"due"
,
"None"
)
self
.
due_time
=
parse_due_date
()
self
.
due
=
parse_due_date
()
def
is_complete
(
self
):
def
is_complete
(
self
):
"""
"""
...
@@ -59,7 +58,7 @@ class FolditModule(XModule):
...
@@ -59,7 +58,7 @@ class FolditModule(XModule):
self
.
system
.
anonymous_student_id
,
self
.
system
.
anonymous_student_id
,
self
.
required_level
,
self
.
required_level
,
self
.
required_sublevel
,
self
.
required_sublevel
,
self
.
due
)
self
.
due
_time
)
return
complete
return
complete
def
completed_puzzles
(
self
):
def
completed_puzzles
(
self
):
...
@@ -96,10 +95,10 @@ class FolditModule(XModule):
...
@@ -96,10 +95,10 @@ class FolditModule(XModule):
self
.
required_level
,
self
.
required_level
,
self
.
required_sublevel
)
self
.
required_sublevel
)
showbasic
=
(
self
.
metadata
.
get
(
"show_basic_score"
)
.
lower
()
==
"true"
)
showbasic
=
(
self
.
show_basic_score
.
lower
()
==
"true"
)
showleader
=
(
self
.
metadata
.
get
(
"show_leaderboard"
)
.
lower
()
==
"true"
)
showleader
=
(
self
.
show_leaderboard
.
lower
()
==
"true"
)
context
=
{
context
=
{
'due'
:
self
.
due
_str
,
'due'
:
self
.
due
,
'success'
:
self
.
is_complete
(),
'success'
:
self
.
is_complete
(),
'goal_level'
:
goal_level
,
'goal_level'
:
goal_level
,
'completed'
:
self
.
completed_puzzles
(),
'completed'
:
self
.
completed_puzzles
(),
...
@@ -121,7 +120,7 @@ class FolditModule(XModule):
...
@@ -121,7 +120,7 @@ class FolditModule(XModule):
self
.
required_sublevel
)
self
.
required_sublevel
)
context
=
{
context
=
{
'due'
:
self
.
due
_str
,
'due'
:
self
.
due
,
'success'
:
self
.
is_complete
(),
'success'
:
self
.
is_complete
(),
'goal_level'
:
goal_level
,
'goal_level'
:
goal_level
,
'completed'
:
self
.
completed_puzzles
(),
'completed'
:
self
.
completed_puzzles
(),
...
@@ -170,9 +169,4 @@ class FolditDescriptor(XmlDescriptor, EditingDescriptor):
...
@@ -170,9 +169,4 @@ class FolditDescriptor(XmlDescriptor, EditingDescriptor):
# so always need to actually check.
# so always need to actually check.
always_recalculate_grades
=
True
always_recalculate_grades
=
True
@classmethod
metadata_attributes
=
XmlDescriptor
.
metadata_attributes
+
(
'required_level'
,
'required_sublevel'
)
def
definition_from_xml
(
cls
,
xml_object
,
system
):
"""
Get the xml_object's attributes.
"""
return
{
'metadata'
:
xml_object
.
attrib
}
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
cec3475c
...
@@ -109,8 +109,8 @@ def import_module_from_xml(modulestore, static_content_store, course_data_path,
...
@@ -109,8 +109,8 @@ def import_module_from_xml(modulestore, static_content_store, course_data_path,
course
=
target_location_namespace
.
course
,
name
=
target_location_namespace
.
name
)
course
=
target_location_namespace
.
course
,
name
=
target_location_namespace
.
name
)
# then remap children pointers since they too will be re-namespaced
# then remap children pointers since they too will be re-namespaced
children_locs
=
module
.
definition
.
get
(
'children'
)
if
module
.
has_children
:
if
children_locs
is
not
None
:
children_locs
=
module
.
children
new_locs
=
[]
new_locs
=
[]
for
child
in
children_locs
:
for
child
in
children_locs
:
child_loc
=
Location
(
child
)
child_loc
=
Location
(
child
)
...
@@ -119,7 +119,7 @@ def import_module_from_xml(modulestore, static_content_store, course_data_path,
...
@@ -119,7 +119,7 @@ def import_module_from_xml(modulestore, static_content_store, course_data_path,
new_locs
.
append
(
new_child_loc
.
url
())
new_locs
.
append
(
new_child_loc
.
url
())
module
.
definition
[
'children'
]
=
new_locs
module
.
children
=
new_locs
if
hasattr
(
module
,
'data'
):
if
hasattr
(
module
,
'data'
):
# cdodge: now go through any link references to '/static/' and make sure we've imported
# cdodge: now go through any link references to '/static/' and make sure we've imported
...
@@ -237,7 +237,7 @@ def validate_category_hierarchy(module_store, course_id, parent_category, expect
...
@@ -237,7 +237,7 @@ def validate_category_hierarchy(module_store, course_id, parent_category, expect
parents
.
append
(
module
)
parents
.
append
(
module
)
for
parent
in
parents
:
for
parent
in
parents
:
for
child_loc
in
[
Location
(
child
)
for
child
in
parent
.
definition
.
get
(
'children'
,
[])
]:
for
child_loc
in
[
Location
(
child
)
for
child
in
parent
.
children
]:
if
child_loc
.
category
!=
expected_child_category
:
if
child_loc
.
category
!=
expected_child_category
:
err_cnt
+=
1
err_cnt
+=
1
print
'ERROR: child {0} of parent {1} was expected to be category of {2} but was {3}'
.
format
(
print
'ERROR: child {0} of parent {1} was expected to be category of {2} but was {3}'
.
format
(
...
...
common/lib/xmodule/xmodule/videoalpha_module.py
View file @
cec3475c
...
@@ -11,6 +11,7 @@ from xmodule.raw_module import RawDescriptor
...
@@ -11,6 +11,7 @@ from xmodule.raw_module import RawDescriptor
from
xmodule.modulestore.mongo
import
MongoModuleStore
from
xmodule.modulestore.mongo
import
MongoModuleStore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.content
import
StaticContent
from
xblock.core
import
Integer
,
Scope
,
String
import
datetime
import
datetime
import
time
import
time
...
@@ -46,11 +47,13 @@ class VideoAlphaModule(XModule):
...
@@ -46,11 +47,13 @@ class VideoAlphaModule(XModule):
css
=
{
'scss'
:
[
resource_string
(
__name__
,
'css/videoalpha/display.scss'
)]}
css
=
{
'scss'
:
[
resource_string
(
__name__
,
'css/videoalpha/display.scss'
)]}
js_module_name
=
"VideoAlpha"
js_module_name
=
"VideoAlpha"
def
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
data
=
String
(
help
=
"XML data for the problem"
,
scope
=
Scope
.
content
)
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
position
=
Integer
(
help
=
"Current position in the video"
,
scope
=
Scope
.
student_state
,
default
=
0
)
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
display_name
=
String
(
help
=
"Display name for this module"
,
scope
=
Scope
.
settings
)
instance_state
,
shared_state
,
**
kwargs
)
xmltree
=
etree
.
fromstring
(
self
.
definition
[
'data'
])
def
__init__
(
self
,
*
args
,
**
kwargs
):
XModule
.
__init__
(
self
,
*
args
,
**
kwargs
)
xmltree
=
etree
.
fromstring
(
self
.
data
)
self
.
youtube_streams
=
xmltree
.
get
(
'youtube'
)
self
.
youtube_streams
=
xmltree
.
get
(
'youtube'
)
self
.
sub
=
xmltree
.
get
(
'sub'
)
self
.
sub
=
xmltree
.
get
(
'sub'
)
self
.
position
=
0
self
.
position
=
0
...
@@ -64,11 +67,6 @@ class VideoAlphaModule(XModule):
...
@@ -64,11 +67,6 @@ class VideoAlphaModule(XModule):
self
.
track
=
self
.
_get_track
(
xmltree
)
self
.
track
=
self
.
_get_track
(
xmltree
)
self
.
start_time
,
self
.
end_time
=
self
.
_get_timeframe
(
xmltree
)
self
.
start_time
,
self
.
end_time
=
self
.
_get_timeframe
(
xmltree
)
if
instance_state
is
not
None
:
state
=
json
.
loads
(
instance_state
)
if
'position'
in
state
:
self
.
position
=
int
(
float
(
state
[
'position'
]))
def
_get_source
(
self
,
xmltree
,
exts
=
None
):
def
_get_source
(
self
,
xmltree
,
exts
=
None
):
"""Find the first valid source, which ends with one of `exts`."""
"""Find the first valid source, which ends with one of `exts`."""
exts
=
[
'mp4'
,
'ogv'
,
'avi'
,
'webm'
]
if
exts
is
None
else
exts
exts
=
[
'mp4'
,
'ogv'
,
'avi'
,
'webm'
]
if
exts
is
None
else
exts
...
@@ -131,7 +129,7 @@ class VideoAlphaModule(XModule):
...
@@ -131,7 +129,7 @@ class VideoAlphaModule(XModule):
else
:
else
:
# VS[compat]
# VS[compat]
# cdodge: filesystem static content support.
# cdodge: filesystem static content support.
caption_asset_path
=
"/static/{0}/subs/"
.
format
(
self
.
metadata
[
'data_dir'
]
)
caption_asset_path
=
"/static/{0}/subs/"
.
format
(
getattr
(
self
,
'data_dir'
,
None
)
)
return
self
.
system
.
render_template
(
'videoalpha.html'
,
{
return
self
.
system
.
render_template
(
'videoalpha.html'
,
{
'youtube_streams'
:
self
.
youtube_streams
,
'youtube_streams'
:
self
.
youtube_streams
,
...
@@ -141,7 +139,7 @@ class VideoAlphaModule(XModule):
...
@@ -141,7 +139,7 @@ class VideoAlphaModule(XModule):
'track'
:
self
.
track
,
'track'
:
self
.
track
,
'display_name'
:
self
.
display_name
,
'display_name'
:
self
.
display_name
,
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
'data_dir'
:
self
.
metadata
[
'data_dir'
]
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
)
,
'caption_asset_path'
:
caption_asset_path
,
'caption_asset_path'
:
caption_asset_path
,
'show_captions'
:
self
.
show_captions
,
'show_captions'
:
self
.
show_captions
,
'start'
:
self
.
start_time
,
'start'
:
self
.
start_time
,
...
...
lms/djangoapps/courseware/courses.py
View file @
cec3475c
...
@@ -250,7 +250,7 @@ def get_course_syllabus_section(course, section_key):
...
@@ -250,7 +250,7 @@ def get_course_syllabus_section(course, section_key):
with
fs
.
open
(
filepath
)
as
htmlFile
:
with
fs
.
open
(
filepath
)
as
htmlFile
:
return
replace_static_urls
(
return
replace_static_urls
(
htmlFile
.
read
()
.
decode
(
'utf-8'
),
htmlFile
.
read
()
.
decode
(
'utf-8'
),
course
.
metadata
[
'data_dir'
]
,
getattr
(
course
,
'data_dir'
,
None
)
,
course_namespace
=
course
.
location
course_namespace
=
course
.
location
)
)
except
ResourceNotFoundError
:
except
ResourceNotFoundError
:
...
...
lms/djangoapps/courseware/features/courses.py
View file @
cec3475c
...
@@ -26,8 +26,8 @@ def get_courseware_with_tabs(course_id):
...
@@ -26,8 +26,8 @@ def get_courseware_with_tabs(course_id):
top three levels of navigation. Same as get_courseware() except include
top three levels of navigation. Same as get_courseware() except include
the tabs on the right hand main navigation page.
the tabs on the right hand main navigation page.
This hides the appropriate courseware as defined by the
XML flag test
:
This hides the appropriate courseware as defined by the
hide_from_toc field
:
chapter.
metadata.get('hide_from_toc','false').lower() == 'true'
chapter.
lms.hide_from_toc
Example:
Example:
...
@@ -80,14 +80,14 @@ def get_courseware_with_tabs(course_id):
...
@@ -80,14 +80,14 @@ def get_courseware_with_tabs(course_id):
"""
"""
course
=
get_course_by_id
(
course_id
)
course
=
get_course_by_id
(
course_id
)
chapters
=
[
chapter
for
chapter
in
course
.
get_children
()
if
chapter
.
metadata
.
get
(
'hide_from_toc'
,
'false'
)
.
lower
()
!=
'true'
]
chapters
=
[
chapter
for
chapter
in
course
.
get_children
()
if
not
chapter
.
lms
.
hide_from_toc
]
courseware
=
[{
'chapter_name'
:
c
.
display_name
,
courseware
=
[{
'chapter_name'
:
c
.
display_name
,
'sections'
:
[{
'section_name'
:
s
.
display_name
,
'sections'
:
[{
'section_name'
:
s
.
display_name
,
'clickable_tab_count'
:
len
(
s
.
get_children
())
if
(
type
(
s
)
==
seq_module
.
SequenceDescriptor
)
else
0
,
'clickable_tab_count'
:
len
(
s
.
get_children
())
if
(
type
(
s
)
==
seq_module
.
SequenceDescriptor
)
else
0
,
'tabs'
:
[{
'children_count'
:
len
(
t
.
get_children
())
if
(
type
(
t
)
==
vertical_module
.
VerticalDescriptor
)
else
0
,
'tabs'
:
[{
'children_count'
:
len
(
t
.
get_children
())
if
(
type
(
t
)
==
vertical_module
.
VerticalDescriptor
)
else
0
,
'class'
:
t
.
__class__
.
__name__
}
'class'
:
t
.
__class__
.
__name__
}
for
t
in
s
.
get_children
()]}
for
t
in
s
.
get_children
()]}
for
s
in
c
.
get_children
()
if
s
.
metadata
.
get
(
'hide_from_toc'
,
'false'
)
.
lower
()
!=
'true'
]}
for
s
in
c
.
get_children
()
if
not
s
.
lms
.
hide_from_toc
]}
for
c
in
chapters
]
for
c
in
chapters
]
return
courseware
return
courseware
...
...
lms/djangoapps/courseware/tests/test_access.py
View file @
cec3475c
...
@@ -88,7 +88,6 @@ class AccessTestCase(TestCase):
...
@@ -88,7 +88,6 @@ class AccessTestCase(TestCase):
yesterday
=
time
.
gmtime
(
time
.
time
()
-
86400
)
yesterday
=
time
.
gmtime
(
time
.
time
()
-
86400
)
tomorrow
=
time
.
gmtime
(
time
.
time
()
+
86400
)
tomorrow
=
time
.
gmtime
(
time
.
time
()
+
86400
)
c
=
Mock
(
enrollment_start
=
yesterday
,
enrollment_end
=
tomorrow
)
c
=
Mock
(
enrollment_start
=
yesterday
,
enrollment_end
=
tomorrow
)
c
.
metadata
.
get
=
'is_public'
# User can enroll if it is between the start and end dates
# User can enroll if it is between the start and end dates
self
.
assertTrue
(
access
.
_has_access_course_desc
(
u
,
c
,
'enroll'
))
self
.
assertTrue
(
access
.
_has_access_course_desc
(
u
,
c
,
'enroll'
))
...
@@ -99,7 +98,6 @@ class AccessTestCase(TestCase):
...
@@ -99,7 +98,6 @@ class AccessTestCase(TestCase):
u
.
is_authenticated
.
return_value
=
True
u
.
is_authenticated
.
return_value
=
True
c
=
Mock
(
enrollment_start
=
tomorrow
,
enrollment_end
=
tomorrow
,
id
=
'edX/test/2012_Fall'
)
c
=
Mock
(
enrollment_start
=
tomorrow
,
enrollment_end
=
tomorrow
,
id
=
'edX/test/2012_Fall'
)
c
.
metadata
.
get
=
'is_public'
allowed
=
CourseEnrollmentAllowedFactory
(
email
=
u
.
email
,
course_id
=
c
.
id
)
allowed
=
CourseEnrollmentAllowedFactory
(
email
=
u
.
email
,
course_id
=
c
.
id
)
...
@@ -110,7 +108,6 @@ class AccessTestCase(TestCase):
...
@@ -110,7 +108,6 @@ class AccessTestCase(TestCase):
u
.
is_authenticated
.
return_value
=
True
u
.
is_authenticated
.
return_value
=
True
c
=
Mock
(
enrollment_start
=
tomorrow
,
enrollment_end
=
tomorrow
,
id
=
'edX/test/Whenever'
)
c
=
Mock
(
enrollment_start
=
tomorrow
,
enrollment_end
=
tomorrow
,
id
=
'edX/test/Whenever'
)
c
.
metadata
.
get
=
'is_public'
self
.
assertTrue
(
access
.
_has_access_course_desc
(
u
,
c
,
'enroll'
))
self
.
assertTrue
(
access
.
_has_access_course_desc
(
u
,
c
,
'enroll'
))
# TODO:
# TODO:
...
...
lms/djangoapps/courseware/tests/tests.py
View file @
cec3475c
...
@@ -325,7 +325,7 @@ class PageLoader(ActivateLoginTestCase):
...
@@ -325,7 +325,7 @@ class PageLoader(ActivateLoginTestCase):
num_bad
+=
1
num_bad
+=
1
elif
isinstance
(
descriptor
,
ErrorDescriptor
):
elif
isinstance
(
descriptor
,
ErrorDescriptor
):
msg
=
"ERROR error descriptor loaded: "
msg
=
"ERROR error descriptor loaded: "
msg
=
msg
+
descriptor
.
definition
[
'data'
][
'error_msg'
]
msg
=
msg
+
descriptor
.
error_msg
all_ok
=
False
all_ok
=
False
num_bad
+=
1
num_bad
+=
1
...
...
lms/djangoapps/courseware/views.py
View file @
cec3475c
...
@@ -194,7 +194,7 @@ def check_for_active_timelimit_module(request, course_id, course):
...
@@ -194,7 +194,7 @@ def check_for_active_timelimit_module(request, course_id, course):
# This value should be in milliseconds.
# This value should be in milliseconds.
remaining_time
=
timelimit_module
.
get_remaining_time_in_ms
()
remaining_time
=
timelimit_module
.
get_remaining_time_in_ms
()
context
[
'timer_expiration_duration'
]
=
remaining_time
context
[
'timer_expiration_duration'
]
=
remaining_time
context
[
'suppress_toplevel_navigation'
]
=
timelimit_descriptor
.
metadata
.
suppress_toplevel_navigation
context
[
'suppress_toplevel_navigation'
]
=
timelimit_descriptor
.
suppress_toplevel_navigation
return_url
=
reverse
(
'jump_to'
,
kwargs
=
{
'course_id'
:
course_id
,
'location'
:
location
})
return_url
=
reverse
(
'jump_to'
,
kwargs
=
{
'course_id'
:
course_id
,
'location'
:
location
})
context
[
'timer_navigation_return_url'
]
=
return_url
context
[
'timer_navigation_return_url'
]
=
return_url
return
context
return
context
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
cec3475c
...
@@ -72,17 +72,17 @@ def create_thread(request, course_id, commentable_id):
...
@@ -72,17 +72,17 @@ def create_thread(request, course_id, commentable_id):
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
post
=
request
.
POST
post
=
request
.
POST
if
course
.
metadata
.
get
(
"allow_anonymous"
,
True
)
:
if
course
.
allow_anonymous
:
anonymous
=
post
.
get
(
'anonymous'
,
'false'
)
.
lower
()
==
'true'
anonymous
=
post
.
get
(
'anonymous'
,
'false'
)
.
lower
()
==
'true'
else
:
else
:
anonymous
=
False
anonymous
=
False
if
course
.
metadata
.
get
(
"allow_anonymous_to_peers"
,
False
)
:
if
course
.
allow_anonymous_to_peers
:
anonymous_to_peers
=
post
.
get
(
'anonymous_to_peers'
,
'false'
)
.
lower
()
==
'true'
anonymous_to_peers
=
post
.
get
(
'anonymous_to_peers'
,
'false'
)
.
lower
()
==
'true'
else
:
else
:
anonymous_to_peers
=
False
anonymous_to_peers
=
False
thread
=
cc
.
Thread
(
**
extract
(
post
,
[
'body'
,
'title'
,
'tags'
]))
thread
=
cc
.
Thread
(
**
extract
(
post
,
/
[
'body'
,
'title'
,
'tags'
]))
thread
.
update_attributes
(
**
{
thread
.
update_attributes
(
**
{
'anonymous'
:
anonymous
,
'anonymous'
:
anonymous
,
'anonymous_to_peers'
:
anonymous_to_peers
,
'anonymous_to_peers'
:
anonymous_to_peers
,
...
@@ -96,7 +96,7 @@ def create_thread(request, course_id, commentable_id):
...
@@ -96,7 +96,7 @@ def create_thread(request, course_id, commentable_id):
#kevinchugh because the new requirement is that all groups will be determined
#kevinchugh because the new requirement is that all groups will be determined
#by the group id in the request this all goes away
#by the group id in the request this all goes away
#not anymore, only for admins
#not anymore, only for admins
# Cohort the thread if the commentable is cohorted.
# Cohort the thread if the commentable is cohorted.
if
is_commentable_cohorted
(
course_id
,
commentable_id
):
if
is_commentable_cohorted
(
course_id
,
commentable_id
):
user_group_id
=
get_cohort_id
(
user
,
course_id
)
user_group_id
=
get_cohort_id
(
user
,
course_id
)
...
@@ -113,7 +113,7 @@ def create_thread(request, course_id, commentable_id):
...
@@ -113,7 +113,7 @@ def create_thread(request, course_id, commentable_id):
if
group_id
:
if
group_id
:
thread
.
update_attributes
(
group_id
=
group_id
)
thread
.
update_attributes
(
group_id
=
group_id
)
thread
.
save
()
thread
.
save
()
if
post
.
get
(
'auto_subscribe'
,
'false'
)
.
lower
()
==
'true'
:
if
post
.
get
(
'auto_subscribe'
,
'false'
)
.
lower
()
==
'true'
:
...
@@ -147,12 +147,12 @@ def _create_comment(request, course_id, thread_id=None, parent_id=None):
...
@@ -147,12 +147,12 @@ def _create_comment(request, course_id, thread_id=None, parent_id=None):
comment
=
cc
.
Comment
(
**
extract
(
post
,
[
'body'
]))
comment
=
cc
.
Comment
(
**
extract
(
post
,
[
'body'
]))
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
if
course
.
metadata
.
get
(
"allow_anonymous"
,
True
)
:
if
course
.
allow_anonymous
:
anonymous
=
post
.
get
(
'anonymous'
,
'false'
)
.
lower
()
==
'true'
anonymous
=
post
.
get
(
'anonymous'
,
'false'
)
.
lower
()
==
'true'
else
:
else
:
anonymous
=
False
anonymous
=
False
if
course
.
metadata
.
get
(
"allow_anonymous_to_peers"
,
False
)
:
if
course
.
allow_anonymous_to_peers
:
anonymous_to_peers
=
post
.
get
(
'anonymous_to_peers'
,
'false'
)
.
lower
()
==
'true'
anonymous_to_peers
=
post
.
get
(
'anonymous_to_peers'
,
'false'
)
.
lower
()
==
'true'
else
:
else
:
anonymous_to_peers
=
False
anonymous_to_peers
=
False
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
cec3475c
...
@@ -124,31 +124,31 @@ def inline_discussion(request, course_id, discussion_id):
...
@@ -124,31 +124,31 @@ def inline_discussion(request, course_id, discussion_id):
annotated_content_info
=
utils
.
get_metadata_for_threads
(
course_id
,
threads
,
request
.
user
,
user_info
)
annotated_content_info
=
utils
.
get_metadata_for_threads
(
course_id
,
threads
,
request
.
user
,
user_info
)
allow_anonymous
=
course
.
metadata
.
get
(
"allow_anonymous"
,
True
)
allow_anonymous
=
course
.
allow_anonymous
allow_anonymous_to_peers
=
course
.
metadata
.
get
(
"allow_anonymous_to_peers"
,
False
)
allow_anonymous_to_peers
=
course
.
allow_anonymous_to_peers
#since inline is all one commentable, only show or allow the choice of cohorts
#since inline is all one commentable, only show or allow the choice of cohorts
#if the commentable is cohorted, otherwise everything is not cohorted
#if the commentable is cohorted, otherwise everything is not cohorted
#and no one has the option of choosing a cohort
#and no one has the option of choosing a cohort
is_cohorted
=
is_course_cohorted
(
course_id
)
and
is_commentable_cohorted
(
course_id
,
discussion_id
)
is_cohorted
=
is_course_cohorted
(
course_id
)
and
is_commentable_cohorted
(
course_id
,
discussion_id
)
is_moderator
=
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
)
is_moderator
=
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
)
cohorts_list
=
list
()
cohorts_list
=
list
()
if
is_cohorted
:
if
is_cohorted
:
cohorts_list
.
append
({
'name'
:
'All Groups'
,
'id'
:
None
})
cohorts_list
.
append
({
'name'
:
'All Groups'
,
'id'
:
None
})
#if you're a mod, send all cohorts and let you pick
#if you're a mod, send all cohorts and let you pick
if
is_moderator
:
if
is_moderator
:
cohorts
=
get_course_cohorts
(
course_id
)
cohorts
=
get_course_cohorts
(
course_id
)
for
c
in
cohorts
:
for
c
in
cohorts
:
cohorts_list
.
append
({
'name'
:
c
.
name
,
'id'
:
c
.
id
})
cohorts_list
.
append
({
'name'
:
c
.
name
,
'id'
:
c
.
id
})
else
:
else
:
#students don't get to choose
#students don't get to choose
cohorts_list
=
None
cohorts_list
=
None
return
utils
.
JsonResponse
({
return
utils
.
JsonResponse
({
'discussion_data'
:
map
(
utils
.
safe_content
,
threads
),
'discussion_data'
:
map
(
utils
.
safe_content
,
threads
),
'user_info'
:
user_info
,
'user_info'
:
user_info
,
...
...
lms/djangoapps/django_comment_client/tests.py
View file @
cec3475c
...
@@ -62,7 +62,7 @@ from courseware.tests.tests import PageLoader, TEST_DATA_XML_MODULESTORE
...
@@ -62,7 +62,7 @@ from courseware.tests.tests import PageLoader, TEST_DATA_XML_MODULESTORE
# #self.assertEqual(resp.status_code, 200)
# #self.assertEqual(resp.status_code, 200)
# #self.assertEqual(my_save.something, "expected", "complaint if not true")
# #self.assertEqual(my_save.something, "expected", "complaint if not true")
#
#
# self.toy.
metadata["cohort_config"]
= {"cohorted": True}
# self.toy.
cohort_config
= {"cohorted": True}
#
#
# # call the view again ...
# # call the view again ...
#
#
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
cec3475c
...
@@ -173,8 +173,8 @@ def initialize_discussion_info(course):
...
@@ -173,8 +173,8 @@ def initialize_discussion_info(course):
path_to_locations
=
{}
path_to_locations
=
{}
for
module
in
all_modules
:
for
module
in
all_modules
:
skip_module
=
False
skip_module
=
False
for
key
in
(
'
id'
,
'discussion_category'
,
'for
'
):
for
key
in
(
'
discussion_id'
,
'discussion_category'
,
'discussion_target
'
):
if
key
not
in
module
.
metadata
:
if
getattr
(
module
,
key
)
is
None
:
log
.
warning
(
"Required key '
%
s' not in discussion
%
s, leaving out of category map"
%
(
key
,
module
.
location
))
log
.
warning
(
"Required key '
%
s' not in discussion
%
s, leaving out of category map"
%
(
key
,
module
.
location
))
skip_module
=
True
skip_module
=
True
...
...
lms/djangoapps/instructor/views.py
View file @
cec3475c
...
@@ -136,7 +136,7 @@ def instructor_dashboard(request, course_id):
...
@@ -136,7 +136,7 @@ def instructor_dashboard(request, course_id):
if
settings
.
MITX_FEATURES
[
'ENABLE_MANUAL_GIT_RELOAD'
]:
if
settings
.
MITX_FEATURES
[
'ENABLE_MANUAL_GIT_RELOAD'
]:
if
'GIT pull'
in
action
:
if
'GIT pull'
in
action
:
data_dir
=
course
.
metadata
[
'data_dir'
]
data_dir
=
getattr
(
course
,
'data_dir'
)
log
.
debug
(
'git pull {0}'
.
format
(
data_dir
))
log
.
debug
(
'git pull {0}'
.
format
(
data_dir
))
gdir
=
settings
.
DATA_DIR
/
data_dir
gdir
=
settings
.
DATA_DIR
/
data_dir
if
not
os
.
path
.
exists
(
gdir
):
if
not
os
.
path
.
exists
(
gdir
):
...
@@ -150,7 +150,7 @@ def instructor_dashboard(request, course_id):
...
@@ -150,7 +150,7 @@ def instructor_dashboard(request, course_id):
if
'Reload course'
in
action
:
if
'Reload course'
in
action
:
log
.
debug
(
'reloading {0} ({1})'
.
format
(
course_id
,
course
))
log
.
debug
(
'reloading {0} ({1})'
.
format
(
course_id
,
course
))
try
:
try
:
data_dir
=
course
.
metadata
[
'data_dir'
]
data_dir
=
getattr
(
course
,
'data_dir'
)
modulestore
()
.
try_load_course
(
data_dir
)
modulestore
()
.
try_load_course
(
data_dir
)
msg
+=
"<br/><p>Course reloaded from {0}</p>"
.
format
(
data_dir
)
msg
+=
"<br/><p>Course reloaded from {0}</p>"
.
format
(
data_dir
)
track
.
views
.
server_track
(
request
,
'reload {0}'
.
format
(
data_dir
),
{},
page
=
'idashboard'
)
track
.
views
.
server_track
(
request
,
'reload {0}'
.
format
(
data_dir
),
{},
page
=
'idashboard'
)
...
@@ -404,7 +404,7 @@ def instructor_dashboard(request, course_id):
...
@@ -404,7 +404,7 @@ def instructor_dashboard(request, course_id):
def
getdat
(
u
):
def
getdat
(
u
):
p
=
u
.
profile
p
=
u
.
profile
return
[
u
.
username
,
u
.
email
]
+
[
getattr
(
p
,
x
,
''
)
for
x
in
profkeys
]
return
[
u
.
username
,
u
.
email
]
+
[
getattr
(
p
,
x
,
''
)
for
x
in
profkeys
]
datatable
[
'data'
]
=
[
getdat
(
u
)
for
u
in
enrolled_students
]
datatable
[
'data'
]
=
[
getdat
(
u
)
for
u
in
enrolled_students
]
datatable
[
'title'
]
=
'Student profile data for course
%
s'
%
course_id
datatable
[
'title'
]
=
'Student profile data for course
%
s'
%
course_id
return
return_csv
(
'profiledata_
%
s.csv'
%
course_id
,
datatable
)
return
return_csv
(
'profiledata_
%
s.csv'
%
course_id
,
datatable
)
...
@@ -426,7 +426,7 @@ def instructor_dashboard(request, course_id):
...
@@ -426,7 +426,7 @@ def instructor_dashboard(request, course_id):
msg
+=
"<font color='red'>Couldn't find module with that urlname. </font>"
msg
+=
"<font color='red'>Couldn't find module with that urlname. </font>"
msg
+=
"<pre>
%
s</pre>"
%
escape
(
err
)
msg
+=
"<pre>
%
s</pre>"
%
escape
(
err
)
smdat
=
[]
smdat
=
[]
if
smdat
:
if
smdat
:
datatable
=
{
'header'
:
[
'username'
,
'state'
]}
datatable
=
{
'header'
:
[
'username'
,
'state'
]}
datatable
[
'data'
]
=
[
[
x
.
student
.
username
,
x
.
state
]
for
x
in
smdat
]
datatable
[
'data'
]
=
[
[
x
.
student
.
username
,
x
.
state
]
for
x
in
smdat
]
...
@@ -621,7 +621,7 @@ def _do_remote_gradebook(user, course, action, args=None, files=None):
...
@@ -621,7 +621,7 @@ def _do_remote_gradebook(user, course, action, args=None, files=None):
'''
'''
Perform remote gradebook action. Returns msg, datatable.
Perform remote gradebook action. Returns msg, datatable.
'''
'''
rg
=
course
.
metadata
.
get
(
'remote_gradebook'
,
''
)
rg
=
course
.
remote_gradebook
if
not
rg
:
if
not
rg
:
msg
=
"No remote gradebook defined in course metadata"
msg
=
"No remote gradebook defined in course metadata"
return
msg
,
{}
return
msg
,
{}
...
...
lms/djangoapps/staticbook/views.py
View file @
cec3475c
...
@@ -46,7 +46,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
...
@@ -46,7 +46,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
input_url
=
"'"
+
original_url
+
"'"
input_url
=
"'"
+
original_url
+
"'"
output_url
=
replace_static_urls
(
output_url
=
replace_static_urls
(
input_url
,
input_url
,
course
.
metadata
[
'data_dir'
]
,
getattr
(
course
,
'data_dir'
,
None
)
,
course_namespace
=
course
.
location
course_namespace
=
course
.
location
)
)
# strip off the quotes again...
# strip off the quotes again...
...
@@ -57,12 +57,12 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
...
@@ -57,12 +57,12 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
# then remap all the chapter URLs as well, if they are provided.
# then remap all the chapter URLs as well, if they are provided.
if
'chapters'
in
textbook
:
if
'chapters'
in
textbook
:
for
entry
in
textbook
[
'chapters'
]:
for
entry
in
textbook
[
'chapters'
]:
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
return
render_to_response
(
'static_pdfbook.html'
,
return
render_to_response
(
'static_pdfbook.html'
,
{
'book_index'
:
book_index
,
{
'book_index'
:
book_index
,
'course'
:
course
,
'course'
:
course
,
'textbook'
:
textbook
,
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'chapter'
:
chapter
,
'page'
:
page
,
'page'
:
page
,
...
...
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