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
3cce6c1e
Commit
3cce6c1e
authored
Apr 05, 2016
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12034 from edx/renzo/discussion-topics
Fix discussion category map for self-paced courses
parents
d86aff28
0e7247f2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
6 deletions
+101
-6
lms/djangoapps/django_comment_client/tests/test_utils.py
+97
-1
lms/djangoapps/django_comment_client/utils.py
+4
-4
lms/envs/aws.py
+0
-1
No files found.
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
3cce6c1e
...
...
@@ -666,6 +666,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 2"
,
"Discussion"
,
start
=
later
)
self
.
create_discussion
(
"Chapter 3 / Section 1"
,
"Discussion"
,
start
=
later
)
self
.
assertFalse
(
self
.
course
.
self_paced
)
self
.
assert_category_map_equals
(
{
"entries"
:
{},
...
...
@@ -696,7 +697,102 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
"children"
:
[
"Chapter 1"
,
"Chapter 2"
]
}
)
self
.
maxDiff
=
None
def
test_self_paced_start_date_filter
(
self
):
self
.
course
.
self_paced
=
True
self
.
course
.
save
()
now
=
datetime
.
datetime
.
now
()
later
=
datetime
.
datetime
.
max
self
.
create_discussion
(
"Chapter 1"
,
"Discussion 1"
,
start
=
now
)
self
.
create_discussion
(
"Chapter 1"
,
"Discussion 2"
,
start
=
later
)
self
.
create_discussion
(
"Chapter 2"
,
"Discussion"
,
start
=
now
)
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 1"
,
"Discussion"
,
start
=
later
)
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 2"
,
"Discussion"
,
start
=
later
)
self
.
create_discussion
(
"Chapter 3 / Section 1"
,
"Discussion"
,
start
=
later
)
self
.
assertTrue
(
self
.
course
.
self_paced
)
self
.
assert_category_map_equals
(
{
"entries"
:
{},
"subcategories"
:
{
"Chapter 1"
:
{
"entries"
:
{
"Discussion 1"
:
{
"id"
:
"discussion1"
,
"sort_key"
:
None
,
"is_cohorted"
:
False
,
},
"Discussion 2"
:
{
"id"
:
"discussion2"
,
"sort_key"
:
None
,
"is_cohorted"
:
False
,
}
},
"subcategories"
:
{},
"children"
:
[
"Discussion 1"
,
"Discussion 2"
]
},
"Chapter 2"
:
{
"entries"
:
{
"Discussion"
:
{
"id"
:
"discussion3"
,
"sort_key"
:
None
,
"is_cohorted"
:
False
,
}
},
"subcategories"
:
{
"Section 1"
:
{
"entries"
:
{},
"subcategories"
:
{
"Subsection 1"
:
{
"entries"
:
{
"Discussion"
:
{
"id"
:
"discussion4"
,
"sort_key"
:
None
,
"is_cohorted"
:
False
,
}
},
"subcategories"
:
{},
"children"
:
[
"Discussion"
]
},
"Subsection 2"
:
{
"entries"
:
{
"Discussion"
:
{
"id"
:
"discussion5"
,
"sort_key"
:
None
,
"is_cohorted"
:
False
,
}
},
"subcategories"
:
{},
"children"
:
[
"Discussion"
]
}
},
"children"
:
[
"Subsection 1"
,
"Subsection 2"
]
}
},
"children"
:
[
"Discussion"
,
"Section 1"
]
},
"Chapter 3"
:
{
"entries"
:
{},
"subcategories"
:
{
"Section 1"
:
{
"entries"
:
{
"Discussion"
:
{
"id"
:
"discussion6"
,
"sort_key"
:
None
,
"is_cohorted"
:
False
,
}
},
"subcategories"
:
{},
"children"
:
[
"Discussion"
]
}
},
"children"
:
[
"Section 1"
]
}
},
"children"
:
[
"Chapter 1"
,
"Chapter 2"
,
"Chapter 3"
]
}
)
def
test_sort_inline_explicit
(
self
):
self
.
create_discussion
(
"Chapter"
,
"Discussion 1"
,
sort_key
=
"D"
)
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
3cce6c1e
...
...
@@ -198,7 +198,7 @@ def get_discussion_id_map(course, user):
return
dict
(
map
(
get_discussion_id_map_entry
,
get_accessible_discussion_modules
(
course
,
user
)))
def
_filter_unstarted_categories
(
category_map
):
def
_filter_unstarted_categories
(
category_map
,
course
):
"""
Returns a subset of categories from the provided map which have not yet met the start date
Includes information about category children, subcategories (different), and entries
...
...
@@ -221,7 +221,7 @@ def _filter_unstarted_categories(category_map):
for
child
in
unfiltered_map
[
"children"
]:
if
child
in
unfiltered_map
[
"entries"
]:
if
unfiltered_map
[
"entries"
][
child
][
"start_date"
]
<=
now
:
if
course
.
self_paced
or
unfiltered_map
[
"entries"
][
child
][
"start_date"
]
<=
now
:
filtered_map
[
"children"
]
.
append
(
child
)
filtered_map
[
"entries"
][
child
]
=
{}
for
key
in
unfiltered_map
[
"entries"
][
child
]:
...
...
@@ -230,7 +230,7 @@ def _filter_unstarted_categories(category_map):
else
:
log
.
debug
(
u"Filtering out:
%
s with start_date:
%
s"
,
child
,
unfiltered_map
[
"entries"
][
child
][
"start_date"
])
else
:
if
unfiltered_map
[
"subcategories"
][
child
][
"start_date"
]
<
now
:
if
course
.
self_paced
or
unfiltered_map
[
"subcategories"
][
child
][
"start_date"
]
<
now
:
filtered_map
[
"children"
]
.
append
(
child
)
filtered_map
[
"subcategories"
][
child
]
=
{}
unfiltered_queue
.
append
(
unfiltered_map
[
"subcategories"
][
child
])
...
...
@@ -382,7 +382,7 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
_sort_map_entries
(
category_map
,
course
.
discussion_sort_alpha
)
return
_filter_unstarted_categories
(
category_map
)
if
exclude_unstarted
else
category_map
return
_filter_unstarted_categories
(
category_map
,
course
)
if
exclude_unstarted
else
category_map
def
discussion_category_id_access
(
course
,
user
,
discussion_id
):
...
...
lms/envs/aws.py
View file @
3cce6c1e
...
...
@@ -190,7 +190,6 @@ if ENV_TOKENS.get('SESSION_COOKIE_NAME', None):
SESSION_COOKIE_NAME
=
str
(
ENV_TOKENS
.
get
(
'SESSION_COOKIE_NAME'
))
BOOK_URL
=
ENV_TOKENS
[
'BOOK_URL'
]
MEDIA_URL
=
ENV_TOKENS
[
'MEDIA_URL'
]
LOG_DIR
=
ENV_TOKENS
[
'LOG_DIR'
]
CACHES
=
ENV_TOKENS
[
'CACHES'
]
...
...
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