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
263c71a6
Commit
263c71a6
authored
Jan 29, 2016
by
Douglas Hall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PHX-246
parent
30b5cebc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
lms/djangoapps/courseware/grades.py
+3
-1
lms/djangoapps/courseware/tests/test_grades.py
+24
-1
No files found.
lms/djangoapps/courseware/grades.py
View file @
263c71a6
...
...
@@ -842,7 +842,9 @@ def _calculate_score_for_modules(user_id, course, modules):
if
module
.
category
not
in
ignore_categories
and
(
module
.
graded
or
module
.
has_score
):
module_score
=
scores_client
.
get
(
locations
[
index
])
if
module_score
:
module_percentages
.
append
(
module_score
.
correct
/
module_score
.
total
)
correct
=
module_score
.
correct
or
0
total
=
module_score
.
total
or
1
module_percentages
.
append
(
correct
/
total
)
return
sum
(
module_percentages
)
/
float
(
len
(
module_percentages
))
if
module_percentages
else
0
...
...
lms/djangoapps/courseware/tests/test_grades.py
View file @
263c71a6
...
...
@@ -19,7 +19,7 @@ from courseware.grades import (
get_module_score
)
from
courseware.module_render
import
get_module
from
courseware.model_data
import
FieldDataCache
from
courseware.model_data
import
FieldDataCache
,
set_score
from
courseware.tests.helpers
import
(
LoginEnrollmentTestCase
,
get_request_for_user
...
...
@@ -432,6 +432,29 @@ class TestGetModuleScore(LoginEnrollmentTestCase, ModuleStoreTestCase):
score
=
get_module_score
(
self
.
request
.
user
,
self
.
course
,
self
.
seq1
)
self
.
assertEqual
(
score
,
.
5
)
def
test_get_module_score_with_empty_score
(
self
):
"""
Test test_get_module_score_with_empty_score
"""
set_score
(
self
.
request
.
user
.
id
,
self
.
problem1
.
location
,
None
,
None
)
# pylint: disable=no-member
set_score
(
self
.
request
.
user
.
id
,
self
.
problem2
.
location
,
None
,
None
)
# pylint: disable=no-member
with
self
.
assertNumQueries
(
1
):
score
=
get_module_score
(
self
.
request
.
user
,
self
.
course
,
self
.
seq1
)
self
.
assertEqual
(
score
,
0
)
answer_problem
(
self
.
course
,
self
.
request
,
self
.
problem1
)
with
self
.
assertNumQueries
(
1
):
score
=
get_module_score
(
self
.
request
.
user
,
self
.
course
,
self
.
seq1
)
self
.
assertEqual
(
score
,
0.5
)
answer_problem
(
self
.
course
,
self
.
request
,
self
.
problem2
)
with
self
.
assertNumQueries
(
1
):
score
=
get_module_score
(
self
.
request
.
user
,
self
.
course
,
self
.
seq1
)
self
.
assertEqual
(
score
,
1.0
)
def
test_get_module_score_with_randomize
(
self
):
"""
Test test_get_module_score_with_randomize
...
...
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