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
fa63a17a
Commit
fa63a17a
authored
Jan 26, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added due date pre-processor
--HG-- branch : profiledev
parent
978752ad
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
courseware/content_parser.py
+36
-0
No files found.
courseware/content_parser.py
View file @
fa63a17a
...
...
@@ -8,6 +8,7 @@ from lxml import etree
import
json
import
hashlib
import
logging
''' This file will eventually form an abstraction layer between the
course XML file and the rest of the system.
...
...
@@ -15,6 +16,8 @@ course XML file and the rest of the system.
TODO: Shift everything from xml.dom.minidom to XPath (or XQuery)
'''
log
=
logging
.
getLogger
(
"mitx.courseware"
)
def
fasthash
(
string
):
m
=
hashlib
.
new
(
"md4"
)
m
.
update
(
string
)
...
...
@@ -85,10 +88,43 @@ def id_tag(course):
else
:
elem
.
set
(
'id'
,
fasthash
(
etree
.
tostring
(
elem
)))
def
due_tag
(
course
):
# The primary purpose of this tagging is to make sure that each problem
# inherits the due date from the section that it is in. We also make
# sure that each section has a due date. If it does not, it inherits
# the last section's due date. This is to make sure that the sections
# are in chronological order. It is an exception to have a later section
# due before an earlier one.
# How are due dates handled for different time zones? What _time_ are things due?
# First, we grab the first due date to occur. This is our starting date.
firstSectionDue
=
course
.
xpath
(
"//section[@due]"
)[
0
]
# I tried adding [1] to the end of the query string to select the first,
# but it didn't work. Is this not supported in etree?
# All new dates must be further than currentDate
currentDate
=
firstSectionDue
.
get
(
'due'
)
sections
=
course
.
xpath
(
"//section"
)
for
section
in
sections
:
existingDate
=
section
.
get
(
'due'
)
if
existingDate
:
#TODO: Make sure existing date is further into the future than currentDate
currentDate
=
existingDate
else
:
section
.
set
(
'due'
,
currentDate
)
problems
=
course
.
xpath
(
'//section[@name=$section]//problem'
,
section
=
section
.
get
(
'name'
))
for
problem
in
problems
:
problem
.
set
(
'due'
,
currentDate
)
def
course_file
(
user
):
# TODO: Cache.
tree
=
etree
.
parse
(
settings
.
DATA_DIR
+
UserProfile
.
objects
.
get
(
user
=
user
)
.
courseware
)
id_tag
(
tree
)
due_tag
(
tree
)
return
tree
def
module_xml
(
coursefile
,
module
,
id_tag
,
module_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