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
bc2bba87
Commit
bc2bba87
authored
Aug 16, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of TextbookModule and TextbookDescriptor.
parent
58abdf3c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
40 deletions
+28
-40
common/lib/xmodule/xmodule/course_module.py
+28
-7
common/lib/xmodule/xmodule/textbook_module.py
+0
-33
No files found.
common/lib/xmodule/xmodule/course_module.py
View file @
bc2bba87
from
fs.errors
import
ResourceNotFoundError
from
fs.errors
import
ResourceNotFoundError
import
time
import
time
import
logging
import
logging
from
lxml
import
etree
from
xmodule.util.decorators
import
lazyproperty
from
xmodule.util.decorators
import
lazyproperty
from
xmodule.graders
import
load_grading_policy
from
xmodule.graders
import
load_grading_policy
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
xmodule.seq_module
import
SequenceDescriptor
,
SequenceModule
from
xmodule.seq_module
import
SequenceDescriptor
,
SequenceModule
from
xmodule.timeparse
import
parse_time
,
stringify_time
from
xmodule.timeparse
import
parse_time
,
stringify_time
from
xmodule.textbook_module
import
TextbookDescriptor
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
class
CourseDescriptor
(
SequenceDescriptor
):
class
CourseDescriptor
(
SequenceDescriptor
):
module_class
=
SequenceModule
module_class
=
SequenceModule
class
Textbook
:
def
__init__
(
self
,
title
,
table_of_contents_url
):
self
.
title
=
title
self
.
table_of_contents_url
=
table_of_contents_url
@classmethod
def
from_xml_object
(
cls
,
xml_object
):
return
cls
(
xml_object
.
get
(
'title'
),
xml_object
.
get
(
'table_of_contents_url'
))
@property
def
table_of_contents
(
self
):
raw_table_of_contents
=
open
(
self
.
table_of_contents_url
,
'r'
)
# TODO: This will need to come from S3
table_of_contents
=
etree
.
parse
(
raw_table_of_contents
)
.
getroot
()
return
table_of_contents
def
__init__
(
self
,
system
,
definition
=
None
,
**
kwargs
):
def
__init__
(
self
,
system
,
definition
=
None
,
**
kwargs
):
super
(
CourseDescriptor
,
self
)
.
__init__
(
system
,
definition
,
**
kwargs
)
super
(
CourseDescriptor
,
self
)
.
__init__
(
system
,
definition
,
**
kwargs
)
self
.
textbooks
=
self
.
definition
[
'textbooks'
]
msg
=
None
msg
=
None
if
self
.
start
is
None
:
if
self
.
start
is
None
:
...
@@ -29,6 +45,16 @@ class CourseDescriptor(SequenceDescriptor):
...
@@ -29,6 +45,16 @@ class CourseDescriptor(SequenceDescriptor):
self
.
enrollment_start
=
self
.
_try_parse_time
(
"enrollment_start"
)
self
.
enrollment_start
=
self
.
_try_parse_time
(
"enrollment_start"
)
self
.
enrollment_end
=
self
.
_try_parse_time
(
"enrollment_end"
)
self
.
enrollment_end
=
self
.
_try_parse_time
(
"enrollment_end"
)
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
textbooks
=
[]
for
textbook
in
xml_object
.
findall
(
"textbook"
):
textbooks
.
append
(
cls
.
Textbook
.
from_xml_object
(
textbook
))
xml_object
.
remove
(
textbook
)
definition
=
super
(
CourseDescriptor
,
cls
)
.
definition_from_xml
(
xml_object
,
system
)
definition
[
'textbooks'
]
=
textbooks
return
definition
def
has_started
(
self
):
def
has_started
(
self
):
return
time
.
gmtime
()
>
self
.
start
return
time
.
gmtime
()
>
self
.
start
...
@@ -54,11 +80,6 @@ class CourseDescriptor(SequenceDescriptor):
...
@@ -54,11 +80,6 @@ class CourseDescriptor(SequenceDescriptor):
return
grading_policy
return
grading_policy
@property
def
textbooks
(
self
):
return
[
child
for
child
in
self
.
get_children
()
if
type
(
child
)
==
TextbookDescriptor
]
@lazyproperty
@lazyproperty
def
grading_context
(
self
):
def
grading_context
(
self
):
"""
"""
...
...
common/lib/xmodule/xmodule/textbook_module.py
deleted
100644 → 0
View file @
58abdf3c
from
xmodule.x_module
import
XModule
from
xmodule.xml_module
import
XmlDescriptor
from
lxml
import
etree
class
TextbookModule
(
XModule
):
def
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
,
shared_state
,
**
kwargs
)
def
get_display_items
(
self
):
return
[]
def
displayable_items
(
self
):
return
[]
class
TextbookDescriptor
(
XmlDescriptor
):
module_class
=
TextbookModule
def
__init__
(
self
,
system
,
definition
=
None
,
**
kwargs
):
super
(
TextbookDescriptor
,
self
)
.
__init__
(
system
,
definition
,
**
kwargs
)
self
.
title
=
self
.
metadata
[
"title"
]
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
return
{
'children'
:
[]
}
@property
def
table_of_contents
(
self
):
raw_table_of_contents
=
open
(
self
.
metadata
[
'table_of_contents_url'
],
'r'
)
# TODO: This will need to come from S3
table_of_contents
=
etree
.
parse
(
raw_table_of_contents
)
.
getroot
()
return
table_of_contents
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