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
9c93cd8d
Commit
9c93cd8d
authored
Aug 19, 2014
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Display error when attempting to reset nonexistent due date extension
parent
f4e02109
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
19 deletions
+27
-19
lms/djangoapps/instructor/tests/test_api.py
+2
-1
lms/djangoapps/instructor/tests/test_tools.py
+5
-18
lms/djangoapps/instructor/views/tools.py
+20
-0
No files found.
lms/djangoapps/instructor/tests/test_api.py
View file @
9c93cd8d
...
@@ -47,7 +47,8 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
...
@@ -47,7 +47,8 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
from
shoppingcart.models
import
CourseRegistrationCode
,
RegistrationCodeRedemption
,
Order
,
PaidCourseRegistration
,
Coupon
from
shoppingcart.models
import
CourseRegistrationCode
,
RegistrationCodeRedemption
,
Order
,
PaidCourseRegistration
,
Coupon
from
course_modes.models
import
CourseMode
from
course_modes.models
import
CourseMode
from
.test_tools
import
msk_from_problem_urlname
,
get_extended_due
from
.test_tools
import
msk_from_problem_urlname
from
..views.tools
import
get_extended_due
@common_exceptions_400
@common_exceptions_400
...
...
lms/djangoapps/instructor/tests/test_tools.py
View file @
9c93cd8d
...
@@ -197,7 +197,7 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
...
@@ -197,7 +197,7 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
self
.
user
=
user
self
.
user
=
user
self
.
extended_due
=
functools
.
partial
(
self
.
extended_due
=
functools
.
partial
(
get_extended_due
,
course
,
student
=
user
)
tools
.
get_extended_due
,
course
,
student
=
user
)
def
test_set_due_date_extension
(
self
):
def
test_set_due_date_extension
(
self
):
extended
=
datetime
.
datetime
(
2013
,
12
,
25
,
0
,
0
,
tzinfo
=
utc
)
extended
=
datetime
.
datetime
(
2013
,
12
,
25
,
0
,
0
,
tzinfo
=
utc
)
...
@@ -209,7 +209,7 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
...
@@ -209,7 +209,7 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
extended
=
datetime
.
datetime
(
2013
,
12
,
25
,
0
,
0
,
tzinfo
=
utc
)
extended
=
datetime
.
datetime
(
2013
,
12
,
25
,
0
,
0
,
tzinfo
=
utc
)
user
=
UserFactory
.
create
()
# No student modules for this user
user
=
UserFactory
.
create
()
# No student modules for this user
tools
.
set_due_date_extension
(
self
.
course
,
self
.
week1
,
user
,
extended
)
tools
.
set_due_date_extension
(
self
.
course
,
self
.
week1
,
user
,
extended
)
extended_due
=
functools
.
partial
(
get_extended_due
,
self
.
course
,
student
=
user
)
extended_due
=
functools
.
partial
(
tools
.
get_extended_due
,
self
.
course
,
student
=
user
)
self
.
assertEqual
(
extended_due
(
self
.
week1
),
extended
)
self
.
assertEqual
(
extended_due
(
self
.
week1
),
extended
)
self
.
assertEqual
(
extended_due
(
self
.
homework
),
extended
)
self
.
assertEqual
(
extended_due
(
self
.
homework
),
extended
)
...
@@ -224,8 +224,11 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
...
@@ -224,8 +224,11 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
tools
.
set_due_date_extension
(
self
.
course
,
self
.
week3
,
self
.
user
,
extended
)
tools
.
set_due_date_extension
(
self
.
course
,
self
.
week3
,
self
.
user
,
extended
)
def
test_reset_due_date_extension
(
self
):
def
test_reset_due_date_extension
(
self
):
extended
=
datetime
.
datetime
(
2013
,
12
,
25
,
0
,
0
,
tzinfo
=
utc
)
tools
.
set_due_date_extension
(
self
.
course
,
self
.
week1
,
self
.
user
,
extended
)
tools
.
set_due_date_extension
(
self
.
course
,
self
.
week1
,
self
.
user
,
None
)
tools
.
set_due_date_extension
(
self
.
course
,
self
.
week1
,
self
.
user
,
None
)
self
.
assertEqual
(
self
.
extended_due
(
self
.
week1
),
None
)
self
.
assertEqual
(
self
.
extended_due
(
self
.
week1
),
None
)
self
.
assertEqual
(
self
.
extended_due
(
self
.
homework
),
None
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
...
@@ -341,22 +344,6 @@ class TestDataDumps(ModuleStoreTestCase):
...
@@ -341,22 +344,6 @@ class TestDataDumps(ModuleStoreTestCase):
"Extended Due Date"
:
"2013-12-25 00:00"
}])
"Extended Due Date"
:
"2013-12-25 00:00"
}])
def
get_extended_due
(
course
,
unit
,
student
):
"""
Get the extended due date out of a student's state for a particular unit.
"""
student_module
=
StudentModule
.
objects
.
get
(
student_id
=
student
.
id
,
course_id
=
course
.
id
,
module_state_key
=
unit
.
location
)
state
=
json
.
loads
(
student_module
.
state
)
extended
=
state
.
get
(
'extended_due'
,
None
)
if
extended
:
return
DATE_FIELD
.
from_json
(
extended
)
def
msk_from_problem_urlname
(
course_id
,
urlname
,
block_type
=
'problem'
):
def
msk_from_problem_urlname
(
course_id
,
urlname
,
block_type
=
'problem'
):
"""
"""
Convert a 'problem urlname' to a module state key (db field)
Convert a 'problem urlname' to a module state key (db field)
...
...
lms/djangoapps/instructor/views/tools.py
View file @
9c93cd8d
...
@@ -159,6 +159,22 @@ def title_or_url(node):
...
@@ -159,6 +159,22 @@ def title_or_url(node):
return
title
return
title
def
get_extended_due
(
course
,
unit
,
student
):
"""
Get the extended due date out of a student's state for a particular unit.
"""
student_module
=
StudentModule
.
objects
.
get
(
student_id
=
student
.
id
,
course_id
=
course
.
id
,
module_state_key
=
unit
.
location
)
state
=
json
.
loads
(
student_module
.
state
)
extended
=
state
.
get
(
'extended_due'
,
None
)
if
extended
:
return
DATE_FIELD
.
from_json
(
extended
)
def
set_due_date_extension
(
course
,
unit
,
student
,
due_date
):
def
set_due_date_extension
(
course
,
unit
,
student
,
due_date
):
"""
"""
Sets a due date extension. Raises DashboardError if the unit or extended
Sets a due date extension. Raises DashboardError if the unit or extended
...
@@ -172,6 +188,10 @@ def set_due_date_extension(course, unit, student, due_date):
...
@@ -172,6 +188,10 @@ def set_due_date_extension(course, unit, student, due_date):
raise
DashboardError
(
_
(
"Unit {0} has no due date to extend."
)
.
format
(
unit
.
location
))
raise
DashboardError
(
_
(
"Unit {0} has no due date to extend."
)
.
format
(
unit
.
location
))
if
due_date
<
original_due_date
:
if
due_date
<
original_due_date
:
raise
DashboardError
(
_
(
"An extended due date must be later than the original due date."
))
raise
DashboardError
(
_
(
"An extended due date must be later than the original due date."
))
else
:
# We are deleting a due date extension. Check that it exists:
if
not
get_extended_due
(
course
,
unit
,
student
):
raise
DashboardError
(
_
(
"No due date extension is set for that student and unit."
))
def
set_due_date
(
node
):
def
set_due_date
(
node
):
"""
"""
...
...
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