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
ef07e1ed
Commit
ef07e1ed
authored
Jan 23, 2014
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For capa if weight is 0 don't try to create Progress objects.
LMS-1494
parent
593e8d23
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
common/lib/xmodule/xmodule/capa_base.py
+4
-0
common/lib/xmodule/xmodule/tests/test_capa_module.py
+12
-0
No files found.
common/lib/xmodule/xmodule/capa_base.py
View file @
ef07e1ed
...
@@ -328,6 +328,10 @@ class CapaMixin(CapaFields):
...
@@ -328,6 +328,10 @@ class CapaMixin(CapaFields):
if
total
>
0
:
if
total
>
0
:
if
self
.
weight
is
not
None
:
if
self
.
weight
is
not
None
:
# Progress objects expect total > 0
if
self
.
weight
==
0
:
return
None
# scale score and total by weight/total:
# scale score and total by weight/total:
score
=
score
*
self
.
weight
/
total
score
=
score
*
self
.
weight
/
total
total
=
self
.
weight
total
=
self
.
weight
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
ef07e1ed
...
@@ -1350,6 +1350,18 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -1350,6 +1350,18 @@ class CapaModuleTest(unittest.TestCase):
mock_log
.
reset_mock
()
mock_log
.
reset_mock
()
@patch
(
'xmodule.capa_base.Progress'
)
@patch
(
'xmodule.capa_base.Progress'
)
def
test_get_progress_no_error_if_weight_zero
(
self
,
mock_progress
):
"""
Check that if the weight is 0 get_progress does not try to create a Progress object.
"""
mock_progress
.
return_value
=
True
module
=
CapaFactory
.
create
()
module
.
weight
=
0
progress
=
module
.
get_progress
()
self
.
assertIsNone
(
progress
)
self
.
assertFalse
(
mock_progress
.
called
)
@patch
(
'xmodule.capa_base.Progress'
)
def
test_get_progress_calculate_progress_fraction
(
self
,
mock_progress
):
def
test_get_progress_calculate_progress_fraction
(
self
,
mock_progress
):
"""
"""
Check that score and total are calculated correctly for the progress fraction.
Check that score and total are calculated correctly for the progress fraction.
...
...
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