Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
96f85915
Commit
96f85915
authored
Apr 02, 2015
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #684 from edx/waheed/tnl1736-add-beta-tester-functionality
Added beta tester functionality.
parents
fa3e83b0
bf037f47
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
2 deletions
+76
-2
openassessment/xblock/openassessmentblock.py
+26
-0
openassessment/xblock/test/test_openassessment.py
+39
-1
openassessment/xblock/test/test_staff_info.py
+11
-1
No files found.
openassessment/xblock/openassessmentblock.py
View file @
96f85915
...
...
@@ -330,6 +330,19 @@ class OpenAssessmentBlock(
return
False
@property
def
is_beta_tester
(
self
):
"""
Check whether the user is a beta tester.
Returns:
bool
"""
if
hasattr
(
self
,
'xmodule_runtime'
):
return
getattr
(
self
.
xmodule_runtime
,
'user_is_beta_tester'
,
False
)
else
:
return
False
@property
def
in_studio_preview
(
self
):
"""
Check whether we are in Studio preview mode.
...
...
@@ -634,6 +647,10 @@ class OpenAssessmentBlock(
if
course_staff
:
return
False
,
None
,
DISTANT_PAST
,
DISTANT_FUTURE
if
self
.
is_beta_tester
:
beta_start
=
self
.
_adjust_start_date_for_beta_testers
(
open_range
[
0
])
open_range
=
(
beta_start
,
open_range
[
1
])
# Check if we are in the open date range
now
=
dt
.
datetime
.
utcnow
()
.
replace
(
tzinfo
=
pytz
.
utc
)
...
...
@@ -809,3 +826,12 @@ class OpenAssessmentBlock(
def
get_username
(
self
,
anonymous_user_id
):
if
hasattr
(
self
,
"xmodule_runtime"
):
return
self
.
xmodule_runtime
.
get_real_user
(
anonymous_user_id
)
.
username
def
_adjust_start_date_for_beta_testers
(
self
,
start
):
if
hasattr
(
self
,
"xmodule_runtime"
):
delta
=
dt
.
timedelta
(
getattr
(
self
.
xmodule_runtime
,
'days_early_for_beta'
,
0
))
effective
=
start
-
delta
return
effective
return
start
openassessment/xblock/test/test_openassessment.py
View file @
96f85915
...
...
@@ -4,7 +4,7 @@ Tests the Open Assessment XBlock functionality.
from
collections
import
namedtuple
import
datetime
as
dt
import
pytz
from
mock
import
Mock
,
patch
,
MagicMock
from
mock
import
Mock
,
patch
,
MagicMock
,
PropertyMock
from
openassessment.xblock
import
openassessmentblock
from
openassessment.xblock.resolve_dates
import
DISTANT_PAST
,
DISTANT_FUTURE
...
...
@@ -119,6 +119,44 @@ class TestOpenAssessment(XBlockHandlerTestCase):
self
.
assertTrue
(
resp
.
body
.
find
(
'Tuesday, April 01, 2014'
))
self
.
assertTrue
(
resp
.
body
.
find
(
'Thursday, May 01, 2014'
))
@patch.object
(
openassessmentblock
.
OpenAssessmentBlock
,
'is_beta_tester'
,
new_callable
=
PropertyMock
)
@scenario
(
'data/basic_scenario.xml'
)
def
test_formatted_dates_for_beta_tester_with_days_early
(
self
,
xblock
,
mock_is_beta_tester
):
"""Test dates for beta tester with days early"""
mock_is_beta_tester
.
return_value
=
True
# Set start/due dates
xblock
.
start
=
dt
.
datetime
(
2014
,
4
,
6
,
1
,
1
,
1
)
xblock
.
due
=
dt
.
datetime
(
2014
,
5
,
1
)
xblock
.
xmodule_runtime
=
Mock
(
course_id
=
'test_course'
,
anonymous_student_id
=
'test_student'
,
days_early_for_beta
=
5
)
self
.
assertEqual
(
xblock
.
xmodule_runtime
.
days_early_for_beta
,
5
)
request
=
namedtuple
(
'Request'
,
'params'
)
request
.
params
=
{}
resp
=
xblock
.
render_peer_assessment
(
request
)
self
.
assertTrue
(
resp
.
body
.
find
(
'Tuesday, April 01, 2014'
))
self
.
assertTrue
(
resp
.
body
.
find
(
'Thursday, May 01, 2014'
))
@patch.object
(
openassessmentblock
.
OpenAssessmentBlock
,
'is_beta_tester'
,
new_callable
=
PropertyMock
)
@scenario
(
'data/basic_scenario.xml'
)
def
test_formatted_dates_for_beta_tester_without_days_early
(
self
,
xblock
,
mock_is_beta_tester
):
"""Test dates for beta tester without days early"""
mock_is_beta_tester
.
return_value
=
True
# Set start/due dates
xblock
.
start
=
dt
.
datetime
(
2014
,
4
,
6
,
1
,
1
,
1
)
xblock
.
due
=
dt
.
datetime
(
2014
,
5
,
1
)
request
=
namedtuple
(
'Request'
,
'params'
)
request
.
params
=
{}
resp
=
xblock
.
render_peer_assessment
(
request
)
self
.
assertTrue
(
resp
.
body
.
find
(
'Tuesday, April 06, 2014'
))
self
.
assertTrue
(
resp
.
body
.
find
(
'Thursday, May 01, 2014'
))
@scenario
(
'data/basic_scenario.xml'
,
user_id
=
'Bob'
)
def
test_default_fields
(
self
,
xblock
):
...
...
openassessment/xblock/test/test_staff_info.py
View file @
96f85915
...
...
@@ -626,13 +626,23 @@ class TestCourseStaff(XBlockHandlerTestCase):
self
.
assertIn
(
"The student submission has been removed from peer"
,
resp
[
'msg'
])
self
.
assertEqual
(
True
,
resp
[
'success'
])
def
_create_mock_runtime
(
self
,
item_id
,
is_staff
,
is_admin
,
anonymous_user_id
):
def
_create_mock_runtime
(
self
,
item_id
,
is_staff
,
is_admin
,
anonymous_user_id
,
user_is_beta
=
False
,
days_early_for_beta
=
0
):
mock_runtime
=
Mock
(
course_id
=
'test_course'
,
item_id
=
item_id
,
anonymous_student_id
=
'Bob'
,
user_is_staff
=
is_staff
,
user_is_admin
=
is_admin
,
user_is_beta
=
user_is_beta
,
days_early_for_beta
=
days_early_for_beta
,
service
=
lambda
self
,
service
:
Mock
(
get_anonymous_student_id
=
lambda
user_id
,
course_id
:
anonymous_user_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