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
31b180be
Commit
31b180be
authored
Jan 27, 2016
by
M. Rehan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip orphans while getting discussion modules
parent
b575d50a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletions
+30
-1
lms/djangoapps/django_comment_client/tests/test_utils.py
+29
-0
lms/djangoapps/django_comment_client/utils.py
+1
-1
No files found.
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
31b180be
# -*- coding: utf-8 -*-
import
datetime
import
json
import
ddt
import
mock
from
nose.plugins.attrib
import
attr
from
pytz
import
UTC
...
...
@@ -23,6 +24,7 @@ from student.tests.factories import UserFactory, AdminFactory, CourseEnrollmentF
from
openedx.core.djangoapps.content.course_structures.models
import
CourseStructure
from
openedx.core.djangoapps.util.testing
import
ContentGroupTestCase
from
student.roles
import
CourseStaffRole
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
TEST_DATA_MIXED_TOY_MODULESTORE
from
xmodule.modulestore.django
import
modulestore
...
...
@@ -108,6 +110,7 @@ class AccessUtilsTestCase(ModuleStoreTestCase):
self
.
assertFalse
(
ret
)
@ddt.ddt
@attr
(
'shard_1'
)
class
CoursewareContextTestCase
(
ModuleStoreTestCase
):
"""
...
...
@@ -170,6 +173,32 @@ class CoursewareContextTestCase(ModuleStoreTestCase):
assertThreadCorrect
(
threads
[
0
],
self
.
discussion1
,
"Chapter / Discussion 1"
)
assertThreadCorrect
(
threads
[
1
],
self
.
discussion2
,
"Subsection / Discussion 2"
)
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
2
),
(
ModuleStoreEnum
.
Type
.
split
,
1
))
@ddt.unpack
def
test_get_accessible_discussion_modules
(
self
,
modulestore_type
,
expected_discussion_modules
):
"""
Tests that the accessible discussion modules having no parents do not get fetched for split modulestore.
"""
course
=
CourseFactory
.
create
(
default_store
=
modulestore_type
)
# Create a discussion module.
test_discussion
=
self
.
store
.
create_child
(
self
.
user
.
id
,
course
.
location
,
'discussion'
,
'test_discussion'
)
# Assert that created discussion module is not an orphan.
self
.
assertNotIn
(
test_discussion
.
location
,
self
.
store
.
get_orphans
(
course
.
id
))
# Assert that there is only one discussion module in the course at the moment.
self
.
assertEqual
(
len
(
utils
.
get_accessible_discussion_modules
(
course
,
self
.
user
)),
1
)
# Add an orphan discussion module to that course
orphan
=
course
.
id
.
make_usage_key
(
'discussion'
,
'orphan_discussion'
)
self
.
store
.
create_item
(
self
.
user
.
id
,
orphan
.
course_key
,
orphan
.
block_type
,
block_id
=
orphan
.
block_id
)
# Assert that the discussion module is an orphan.
self
.
assertIn
(
orphan
,
self
.
store
.
get_orphans
(
course
.
id
))
self
.
assertEqual
(
len
(
utils
.
get_accessible_discussion_modules
(
course
,
self
.
user
)),
expected_discussion_modules
)
class
CachedDiscussionIdMapTestCase
(
ModuleStoreTestCase
):
"""
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
31b180be
...
...
@@ -129,7 +129,7 @@ def get_accessible_discussion_modules(course, user, include_all=False): # pylin
Return a list of all valid discussion modules in this course that
are accessible to the given user.
"""
all_modules
=
modulestore
()
.
get_items
(
course
.
id
,
qualifiers
=
{
'category'
:
'discussion'
})
all_modules
=
modulestore
()
.
get_items
(
course
.
id
,
qualifiers
=
{
'category'
:
'discussion'
}
,
include_orphans
=
False
)
return
[
module
for
module
in
all_modules
...
...
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