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
977e1904
Commit
977e1904
authored
Feb 06, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor out time parsing logic into its own class.
parent
40854fc1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
26 deletions
+56
-26
common/lib/xmodule/xmodule/combined_open_ended_module.py
+10
-23
common/lib/xmodule/xmodule/peer_grading_module.py
+13
-3
common/lib/xmodule/xmodule/timeinfo.py
+33
-0
No files found.
common/lib/xmodule/xmodule/combined_open_ended_module.py
View file @
977e1904
...
@@ -7,13 +7,10 @@ from lxml import etree
...
@@ -7,13 +7,10 @@ from lxml import etree
from
lxml.html
import
rewrite_links
from
lxml.html
import
rewrite_links
from
path
import
path
from
path
import
path
import
os
import
os
import
dateutil
import
dateutil.parser
import
datetime
import
sys
import
sys
from
timeparse
import
parse_timedelta
from
pkg_resources
import
resource_string
from
pkg_resources
import
resource_string
from
timeinfo
import
TimeInfo
from
.capa_module
import
only_one
,
ComplexEncoder
from
.capa_module
import
only_one
,
ComplexEncoder
from
.editing_module
import
EditingDescriptor
from
.editing_module
import
EditingDescriptor
...
@@ -167,26 +164,16 @@ class CombinedOpenEndedModule(XModule):
...
@@ -167,26 +164,16 @@ class CombinedOpenEndedModule(XModule):
self
.
accept_file_upload
=
self
.
metadata
.
get
(
'accept_file_upload'
,
ACCEPT_FILE_UPLOAD
)
in
TRUE_DICT
self
.
accept_file_upload
=
self
.
metadata
.
get
(
'accept_file_upload'
,
ACCEPT_FILE_UPLOAD
)
in
TRUE_DICT
display_due_date_string
=
self
.
metadata
.
get
(
'due'
,
None
)
display_due_date_string
=
self
.
metadata
.
get
(
'due'
,
None
)
if
display_due_date_string
is
not
None
:
try
:
self
.
display_due_date
=
dateutil
.
parser
.
parse
(
display_due_date_string
)
except
ValueError
:
log
.
error
(
"Could not parse due date {0} for location {1}"
.
format
(
display_due_date_string
,
location
))
raise
else
:
self
.
display_due_date
=
None
grace_period_string
=
self
.
metadata
.
get
(
'graceperiod'
,
None
)
grace_period_string
=
self
.
metadata
.
get
(
'graceperiod'
,
None
)
if
grace_period_string
is
not
None
and
self
.
display_due_date
:
try
:
try
:
self
.
grace_period
=
parse_timedelta
(
grace_period_string
)
self
.
timeinfo
=
TimeInfo
(
display_due_date_string
,
grace_period_string
)
self
.
close_date
=
self
.
display_due_date
+
self
.
grace_period
except
:
except
:
log
.
error
(
"Error parsing due date information in location {0}"
.
format
(
location
))
log
.
error
(
"Error parsing the grace period {0} for location {1}"
.
format
(
grace_period_string
,
location
))
raise
raise
else
:
self
.
display_due_date
=
self
.
timeinfo
.
display_due_date
self
.
grace_period
=
None
self
.
close_date
=
self
.
display_due_date
# Used for progress / grading. Currently get credit just for
# Used for progress / grading. Currently get credit just for
# completion (doesn't matter if you self-assessed correct/incorrect).
# completion (doesn't matter if you self-assessed correct/incorrect).
...
@@ -210,7 +197,7 @@ class CombinedOpenEndedModule(XModule):
...
@@ -210,7 +197,7 @@ class CombinedOpenEndedModule(XModule):
'rubric'
:
definition
[
'rubric'
],
'rubric'
:
definition
[
'rubric'
],
'display_name'
:
self
.
display_name
,
'display_name'
:
self
.
display_name
,
'accept_file_upload'
:
self
.
accept_file_upload
,
'accept_file_upload'
:
self
.
accept_file_upload
,
'close_date'
:
self
.
close_date
'close_date'
:
self
.
timeinfo
.
close_date
}
}
self
.
task_xml
=
definition
[
'task_xml'
]
self
.
task_xml
=
definition
[
'task_xml'
]
...
...
common/lib/xmodule/xmodule/peer_grading_module.py
View file @
977e1904
...
@@ -22,7 +22,6 @@ import json
...
@@ -22,7 +22,6 @@ import json
import
logging
import
logging
from
lxml.html
import
rewrite_links
from
lxml.html
import
rewrite_links
import
os
import
os
from
pkg_resources
import
resource_string
from
pkg_resources
import
resource_string
from
.capa_module
import
only_one
,
ComplexEncoder
from
.capa_module
import
only_one
,
ComplexEncoder
from
.editing_module
import
EditingDescriptor
from
.editing_module
import
EditingDescriptor
...
@@ -32,6 +31,7 @@ from .stringify import stringify_children
...
@@ -32,6 +31,7 @@ from .stringify import stringify_children
from
.x_module
import
XModule
from
.x_module
import
XModule
from
.xml_module
import
XmlDescriptor
from
.xml_module
import
XmlDescriptor
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
timeinfo
import
TimeInfo
from
peer_grading_service
import
peer_grading_service
,
GradingServiceError
from
peer_grading_service
import
peer_grading_service
,
GradingServiceError
...
@@ -71,6 +71,17 @@ class PeerGradingModule(XModule):
...
@@ -71,6 +71,17 @@ class PeerGradingModule(XModule):
self
.
system
=
system
self
.
system
=
system
self
.
peer_gs
=
peer_grading_service
(
self
.
system
)
self
.
peer_gs
=
peer_grading_service
(
self
.
system
)
display_due_date_string
=
self
.
metadata
.
get
(
'due'
,
None
)
grace_period_string
=
self
.
metadata
.
get
(
'graceperiod'
,
None
)
try
:
self
.
timeinfo
=
TimeInfo
(
display_due_date_string
,
grace_period_string
)
except
:
log
.
error
(
"Error parsing due date information in location {0}"
.
format
(
location
))
raise
self
.
display_due_date
=
self
.
timeinfo
.
display_due_date
self
.
use_for_single_location
=
self
.
metadata
.
get
(
'use_for_single_location'
,
USE_FOR_SINGLE_LOCATION
)
self
.
use_for_single_location
=
self
.
metadata
.
get
(
'use_for_single_location'
,
USE_FOR_SINGLE_LOCATION
)
if
isinstance
(
self
.
use_for_single_location
,
basestring
):
if
isinstance
(
self
.
use_for_single_location
,
basestring
):
self
.
use_for_single_location
=
(
self
.
use_for_single_location
in
TRUE_DICT
)
self
.
use_for_single_location
=
(
self
.
use_for_single_location
in
TRUE_DICT
)
...
@@ -534,4 +545,4 @@ class PeerGradingDescriptor(XmlDescriptor, EditingDescriptor):
...
@@ -534,4 +545,4 @@ class PeerGradingDescriptor(XmlDescriptor, EditingDescriptor):
for
child
in
[
'task'
]:
for
child
in
[
'task'
]:
add_child
(
child
)
add_child
(
child
)
return
elt
return
elt
\ No newline at end of file
common/lib/xmodule/xmodule/timeinfo.py
0 → 100644
View file @
977e1904
import
dateutil
import
dateutil.parser
import
datetime
from
timeparse
import
parse_timedelta
import
logging
log
=
logging
.
getLogger
(
__name__
)
class
TimeInfo
(
object
):
"""
This is a simple object that stores datetime information for an XModule
based on the due date string and the grace period string
"""
def
__init__
(
self
,
display_due_date_string
,
grace_period_string
):
if
display_due_date_string
is
not
None
:
try
:
self
.
display_due_date
=
dateutil
.
parser
.
parse
(
display_due_date_string
)
except
ValueError
:
log
.
error
(
"Could not parse due date {0}"
.
format
(
display_due_date_string
))
raise
else
:
self
.
display_due_date
=
None
if
grace_period_string
is
not
None
and
self
.
display_due_date
:
try
:
self
.
grace_period
=
parse_timedelta
(
grace_period_string
)
self
.
close_date
=
self
.
display_due_date
+
self
.
grace_period
except
:
log
.
error
(
"Error parsing the grace period {0}"
.
format
(
grace_period_string
))
raise
else
:
self
.
grace_period
=
None
self
.
close_date
=
self
.
display_due_date
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