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
57ed7983
Commit
57ed7983
authored
Sep 10, 2015
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! SplitTest and UserPartitions.
parent
6c602dee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
88 deletions
+29
-88
lms/djangoapps/course_blocks/transformers/split_test.py
+8
-8
lms/djangoapps/course_blocks/transformers/tests/test_split_test.py
+19
-69
lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py
+2
-11
No files found.
lms/djangoapps/course_blocks/transformers/split_test.py
View file @
57ed7983
...
@@ -45,10 +45,10 @@ class SplitTestTransformer(BlockStructureTransformer):
...
@@ -45,10 +45,10 @@ class SplitTestTransformer(BlockStructureTransformer):
user_partitions
=
getattr
(
xblock
,
'user_partitions'
,
[])
user_partitions
=
getattr
(
xblock
,
'user_partitions'
,
[])
split_test_partitions
=
getattr
(
xblock
,
'split_test_partition'
,
[])
or
[]
split_test_partitions
=
getattr
(
xblock
,
'split_test_partition'
,
[])
or
[]
# For each block, check if
there is an
split_test block.
# For each block, check if
it is a
split_test block.
# If split_test is found, check it
'
s user_partition value and get children.
# If split_test is found, check its user_partition value and get children.
# Set split_test_group on each of the children for fast retrival in transform phase.
# Set split_test_group on each of the children for fast retri
e
val in transform phase.
# Add same group to childrens children, because due to structure restrictions first level
# Add same group to children
'
s children, because due to structure restrictions first level
# children are verticals.
# children are verticals.
for
block_key
in
block_structure
.
topological_traversal
():
for
block_key
in
block_structure
.
topological_traversal
():
xblock
=
block_structure
.
get_xblock
(
block_key
)
xblock
=
block_structure
.
get_xblock
(
block_key
)
...
@@ -96,11 +96,11 @@ class SplitTestTransformer(BlockStructureTransformer):
...
@@ -96,11 +96,11 @@ class SplitTestTransformer(BlockStructureTransformer):
if
not
user_partitions
:
if
not
user_partitions
:
return
return
user_groups
=
get_user_partition_groups
(
user_info
.
course_key
,
user_partitions
,
user_info
.
user
)
if
not
user_info
.
has_staff_access
:
if
not
user_info
.
has_staff_access
:
user_groups
=
get_user_partition_groups
(
user_info
.
course_key
,
user_partitions
,
user_info
.
user
)
block_structure
.
remove_block_if
(
block_structure
.
remove_block_if
(
lambda
block_key
:
not
SplitTestTransformer
.
check_split_access
(
lambda
block_key
:
not
SplitTestTransformer
.
check_split_access
(
block_structure
.
get_transformer_block_data
(
block_structure
.
get_transformer_block_data
(
...
...
lms/djangoapps/course_blocks/transformers/tests/test_split_test.py
View file @
57ed7983
...
@@ -4,7 +4,6 @@ Tests for SplitTestTransformer.
...
@@ -4,7 +4,6 @@ Tests for SplitTestTransformer.
from
openedx.core.djangoapps.user_api.partition_schemes
import
RandomUserPartitionScheme
from
openedx.core.djangoapps.user_api.partition_schemes
import
RandomUserPartitionScheme
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
from
student.tests.factories
import
CourseEnrollmentFactory
from
student.tests.factories
import
CourseEnrollmentFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
course_blocks.transformers.split_test
import
SplitTestTransformer
from
course_blocks.transformers.split_test
import
SplitTestTransformer
...
@@ -27,8 +26,9 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
...
@@ -27,8 +26,9 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
# Set up user partitions and groups.
# Set up user partitions and groups.
self
.
groups
=
[
Group
(
3
,
'Group A'
),
Group
(
4
,
'Group B'
)]
self
.
groups
=
[
Group
(
3
,
'Group A'
),
Group
(
4
,
'Group B'
)]
self
.
content_groups
=
[
3
,
4
]
self
.
content_groups
=
[
3
,
4
]
self
.
split_test_user_partition_id
=
0
self
.
split_test_user_partition
=
UserPartition
(
self
.
split_test_user_partition
=
UserPartition
(
id
=
0
,
id
=
self
.
split_test_user_partition_id
,
name
=
'Partition 2'
,
name
=
'Partition 2'
,
description
=
'This is partition 2'
,
description
=
'This is partition 2'
,
groups
=
self
.
groups
,
groups
=
self
.
groups
,
...
@@ -40,7 +40,6 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
...
@@ -40,7 +40,6 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
self
.
course_hierarchy
=
self
.
get_course_hierarchy
()
self
.
course_hierarchy
=
self
.
get_course_hierarchy
()
self
.
blocks
=
self
.
build_course
(
self
.
course_hierarchy
)
self
.
blocks
=
self
.
build_course
(
self
.
course_hierarchy
)
self
.
course
=
self
.
blocks
[
'course'
]
self
.
course
=
self
.
blocks
[
'course'
]
clear_course_from_cache
(
self
.
course
.
id
)
# Enroll user in course.
# Enroll user in course.
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
,
is_active
=
True
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
,
is_active
=
True
)
...
@@ -119,37 +118,10 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
...
@@ -119,37 +118,10 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
]
]
}
}
def
add_user_to_splittest_group
(
self
,
assign
=
True
):
def
test_user_not_assigned
(
self
):
"""
"""
Add user to split test, get group for him and update blocks
.
Test when user is not assigned to any group in user partition
.
"""
"""
self
.
split_test_user_partition
.
scheme
.
get_group_for_user
(
CourseKey
.
from_string
(
unicode
(
self
.
course
.
id
)),
self
.
user
,
self
.
split_test_user_partition
,
assign
=
assign
,
)
store
=
modulestore
()
for
__
,
block
in
self
.
blocks
.
iteritems
():
block
.
save
()
store
.
update_item
(
block
,
self
.
user
.
id
)
def
test_course_structure_with_user_split_test
(
self
):
"""
Test course structure integrity if course has split test section
and user is not assigned to any group in user partition.
"""
# Add user to split test.
self
.
add_user_to_splittest_group
(
assign
=
False
)
raw_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
course
.
location
,
transformers
=
{}
)
self
.
assertEqual
(
len
(
list
(
raw_block_structure
.
get_block_keys
())),
len
(
self
.
blocks
))
clear_course_from_cache
(
self
.
course
.
id
)
trans_block_structure
=
get_course_blocks
(
trans_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
user
,
self
.
course
.
location
,
self
.
course
.
location
,
...
@@ -161,22 +133,17 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
...
@@ -161,22 +133,17 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
self
.
get_block_key_set
(
'course'
,
'chapter1'
,
'lesson1'
,
'vertical1'
,
'split_test1'
)
self
.
get_block_key_set
(
'course'
,
'chapter1'
,
'lesson1'
,
'vertical1'
,
'split_test1'
)
)
)
def
test_
course_structure_with_user_split_test_group
_assigned
(
self
):
def
test_
user
_assigned
(
self
):
"""
"""
Test course structure integrity if course has split test section
Test when user is assigned to any group in user partition.
and user is assigned to any group in user partition.
"""
"""
# Add user to split test.
# Add user to split test.
self
.
add_user_to_splittest_group
()
self
.
split_test_user_partition
.
scheme
.
get_group_for_user
(
CourseKey
.
from_string
(
unicode
(
self
.
course
.
id
)),
raw_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
user
,
self
.
course
.
location
,
self
.
split_test_user_partition
,
transformers
=
{}
)
)
self
.
assertEqual
(
len
(
list
(
raw_block_structure
.
get_block_keys
())),
len
(
self
.
blocks
))
clear_course_from_cache
(
self
.
course
.
id
)
trans_block_structure
=
get_course_blocks
(
trans_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
user
,
self
.
course
.
location
,
self
.
course
.
location
,
...
@@ -186,33 +153,16 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
...
@@ -186,33 +153,16 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
user_groups
=
get_user_partition_groups
(
user_groups
=
get_user_partition_groups
(
self
.
course
.
id
,
[
self
.
split_test_user_partition
],
self
.
user
self
.
course
.
id
,
[
self
.
split_test_user_partition
],
self
.
user
)
)
for
group
in
user_groups
.
itervalues
():
self
.
assertEquals
(
len
(
user_groups
),
1
)
if
group
.
id
==
3
:
group
=
user_groups
[
self
.
split_test_user_partition_id
]
self
.
assertEqual
(
set
(
trans_block_structure
.
get_block_keys
()),
expected_blocks
=
[
'course'
,
'chapter1'
,
'lesson1'
,
'vertical1'
,
'split_test1'
]
self
.
get_block_key_set
(
if
group
.
id
==
3
:
'course'
,
expected_blocks
+=
[
'vertical2'
,
'html1'
]
'chapter1'
,
else
:
'lesson1'
,
expected_blocks
+=
[
'vertical3'
,
'html2'
]
'vertical1'
,
'split_test1'
,
self
.
assertEqual
(
set
(
trans_block_structure
.
get_block_keys
()),
set
(
self
.
get_block_key_set
(
*
expected_blocks
)))
'vertical2'
,
'html1'
)
)
else
:
self
.
assertEqual
(
set
(
trans_block_structure
.
get_block_keys
()),
self
.
get_block_key_set
(
'course'
,
'chapter1'
,
'lesson1'
,
'vertical1'
,
'split_test1'
,
'vertical3'
,
'html2'
)
)
def
test_course_structure_with_staff_user
(
self
):
def
test_course_structure_with_staff_user
(
self
):
"""
"""
...
...
lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py
View file @
57ed7983
...
@@ -40,7 +40,6 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
...
@@ -40,7 +40,6 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
self
.
course_hierarchy
=
self
.
get_course_hierarchy
()
self
.
course_hierarchy
=
self
.
get_course_hierarchy
()
self
.
blocks
=
self
.
build_course
(
self
.
course_hierarchy
)
self
.
blocks
=
self
.
build_course
(
self
.
course_hierarchy
)
self
.
course
=
self
.
blocks
[
'course'
]
self
.
course
=
self
.
blocks
[
'course'
]
clear_course_from_cache
(
self
.
course
.
id
)
# Enroll user in course.
# Enroll user in course.
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
,
is_active
=
True
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
,
is_active
=
True
)
...
@@ -109,18 +108,10 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
...
@@ -109,18 +108,10 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
group
.
id
,
group
.
id
,
)
)
def
test_
course_structure_with_user_partition
(
self
):
def
test_
user_assigned
(
self
):
"""
"""
Test course structure integrity if course has user partition section
Test when user is assigned to group in user partition.
and user is assigned to group in user partition.
"""
"""
raw_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
course
.
location
,
transformers
=
{}
)
self
.
assertEqual
(
len
(
list
(
raw_block_structure
.
get_block_keys
())),
len
(
self
.
blocks
))
trans_block_structure
=
get_course_blocks
(
trans_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
user
,
self
.
course
.
location
,
self
.
course
.
location
,
...
...
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