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
89d91691
Commit
89d91691
authored
Nov 17, 2016
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle DAGs with inaccessible Subsections on Problem Score update
TNL-5886
parent
0a27a167
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
13 deletions
+39
-13
lms/djangoapps/grades/tasks.py
+1
-0
lms/djangoapps/grades/tests/test_new.py
+7
-7
lms/djangoapps/grades/tests/test_tasks.py
+29
-5
openedx/core/lib/block_structure/block_structure.py
+1
-1
openedx/core/lib/block_structure/tests/test_block_structure.py
+1
-0
No files found.
lms/djangoapps/grades/tasks.py
View file @
89d91691
...
...
@@ -110,6 +110,7 @@ def _update_subsection_grades(
try
:
for
subsection_usage_key
in
subsections_to_update
:
if
subsection_usage_key
in
course_structure
:
subsection_grade
=
subsection_grade_factory
.
update
(
course_structure
[
subsection_usage_key
],
only_if_higher
,
...
...
lms/djangoapps/grades/tests/test_new.py
View file @
89d91691
...
...
@@ -434,12 +434,6 @@ class TestVariedMetadata(ProblemSubmissionTestMixin, ModuleStoreTestCase):
self
.
request
=
get_mock_request
(
UserFactory
())
self
.
client
.
login
(
username
=
self
.
request
.
user
.
username
,
password
=
"test"
)
CourseEnrollment
.
enroll
(
self
.
request
.
user
,
self
.
course
.
id
)
course_structure
=
get_course_blocks
(
self
.
request
.
user
,
self
.
course
.
location
)
self
.
subsection_factory
=
SubsectionGradeFactory
(
self
.
request
.
user
,
course_structure
=
course_structure
,
course
=
self
.
course
,
)
def
_get_altered_metadata
(
self
,
alterations
):
"""
...
...
@@ -471,7 +465,13 @@ class TestVariedMetadata(ProblemSubmissionTestMixin, ModuleStoreTestCase):
"""
self
.
submit_question_answer
(
u'problem'
,
{
u'2_1'
:
u'Correct'
})
return
self
.
subsection_factory
.
create
(
self
.
sequence
)
course_structure
=
get_course_blocks
(
self
.
request
.
user
,
self
.
course
.
location
)
subsection_factory
=
SubsectionGradeFactory
(
self
.
request
.
user
,
course_structure
=
course_structure
,
course
=
self
.
course
,
)
return
subsection_factory
.
create
(
self
.
sequence
)
@ddt.data
(
({},
1.25
,
2.5
),
...
...
lms/djangoapps/grades/tests/test_tasks.py
View file @
89d91691
...
...
@@ -49,8 +49,8 @@ class RecalculateSubsectionGradeTest(ModuleStoreTestCase):
PersistentGradesEnabledFlag
.
objects
.
create
(
enabled
=
False
)
self
.
chapter
=
ItemFactory
.
create
(
parent
=
self
.
course
,
category
=
"chapter"
,
display_name
=
"Chapter"
)
self
.
sequential
=
ItemFactory
.
create
(
parent
=
self
.
chapter
,
category
=
'sequential'
,
display_name
=
"
Open Sequential
"
)
self
.
problem
=
ItemFactory
.
create
(
parent
=
self
.
sequential
,
category
=
'problem'
,
display_name
=
'
p
roblem'
)
self
.
sequential
=
ItemFactory
.
create
(
parent
=
self
.
chapter
,
category
=
'sequential'
,
display_name
=
"
Sequential1
"
)
self
.
problem
=
ItemFactory
.
create
(
parent
=
self
.
sequential
,
category
=
'problem'
,
display_name
=
'
P
roblem'
)
self
.
problem_score_changed_kwargs
=
OrderedDict
([
(
'points_earned'
,
1.0
),
...
...
@@ -109,13 +109,13 @@ class RecalculateSubsectionGradeTest(ModuleStoreTestCase):
mock_task_apply
.
assert_called_once_with
(
args
=
expected_args
)
@patch
(
'lms.djangoapps.grades.signals.signals.SUBSECTION_SCORE_CHANGED.send'
)
def
test_subsection_update_triggers_
course_update
(
self
,
mock_course
_signal
):
def
test_subsection_update_triggers_
signal
(
self
,
mock_subsection
_signal
):
"""
Ensures that the subsection update operation
also updates the course grade
.
Ensures that the subsection update operation
triggers a signal
.
"""
self
.
set_up_course
()
self
.
_apply_recalculate_subsection_grade
()
self
.
assertTrue
(
mock_
course
_signal
.
called
)
self
.
assertTrue
(
mock_
subsection
_signal
.
called
)
@ddt.data
(
(
ModuleStoreEnum
.
Type
.
mongo
,
1
),
...
...
@@ -129,6 +129,30 @@ class RecalculateSubsectionGradeTest(ModuleStoreTestCase):
with
check_mongo_calls
(
2
)
and
self
.
assertNumQueries
(
20
+
added_queries
):
self
.
_apply_recalculate_subsection_grade
()
@patch
(
'lms.djangoapps.grades.signals.signals.SUBSECTION_SCORE_CHANGED.send'
)
def
test_other_inaccessible_subsection
(
self
,
mock_subsection_signal
):
self
.
set_up_course
()
accessible_seq
=
ItemFactory
.
create
(
parent
=
self
.
chapter
,
category
=
'sequential'
)
inaccessible_seq
=
ItemFactory
.
create
(
parent
=
self
.
chapter
,
category
=
'sequential'
,
visible_to_staff_only
=
True
)
# Update problem to have 2 additional sequential parents.
# So in total, 3 sequential parents, with one inaccessible.
for
sequential
in
(
accessible_seq
,
inaccessible_seq
):
sequential
.
children
=
[
self
.
problem
.
location
]
modulestore
()
.
update_item
(
sequential
,
self
.
user
.
id
)
# pylint: disable=no-member
# Make sure the signal is sent for only the 2 accessible sequentials.
self
.
_apply_recalculate_subsection_grade
()
self
.
assertEquals
(
mock_subsection_signal
.
call_count
,
2
)
sequentials_signalled
=
{
args
[
1
][
'subsection_grade'
]
.
location
for
args
in
mock_subsection_signal
.
call_args_list
}
self
.
assertSetEqual
(
sequentials_signalled
,
{
self
.
sequential
.
location
,
accessible_seq
.
location
},
)
def
test_single_call_to_create_block_structure
(
self
):
self
.
set_up_course
()
self
.
assertTrue
(
PersistentGradesEnabledFlag
.
feature_enabled
(
self
.
course
.
id
))
...
...
openedx/core/lib/block_structure/block_structure.py
View file @
89d91691
...
...
@@ -445,7 +445,7 @@ class BlockStructureBlockData(BlockStructure):
"""
Returns the BlockData associated with the given key.
"""
return
self
.
_block_data_map
.
get
(
usage_key
)
return
self
.
_block_data_map
[
usage_key
]
def
get_xblock_field
(
self
,
usage_key
,
field_name
,
default
=
None
):
"""
...
...
openedx/core/lib/block_structure/tests/test_block_structure.py
View file @
89d91691
...
...
@@ -131,6 +131,7 @@ class TestBlockStructureData(TestCase, ChildrenMapTestMixin):
block_structure
=
BlockStructureModulestoreData
(
root_block_usage_key
=
0
)
for
block
in
blocks
:
block_structure
.
_add_xblock
(
block
.
location
,
block
)
block_structure
.
_get_or_create_block
(
block
.
location
)
# request fields
fields
=
[
"field1"
,
"field2"
,
"field3"
]
...
...
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