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
941311f0
Commit
941311f0
authored
Oct 11, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #865 from MITx/bugfix/victor/progress-tab-crash
Check for None to fix 3.091 progress tab crash
parents
73f32599
fdfcbd91
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
lms/djangoapps/courseware/grades.py
+13
-5
No files found.
lms/djangoapps/courseware/grades.py
View file @
941311f0
...
...
@@ -329,9 +329,15 @@ def progress_summary(student, request, course, student_module_cache):
def
get_score
(
course_id
,
user
,
problem_descriptor
,
module_creator
,
student_module_cache
):
"""
Return the score for a user on a problem, as a tuple (correct, total).
e.g. (5,7) if you got 5 out of 7 points.
If this problem doesn't have a score, or we couldn't load it, returns (None,
None).
user: a Student object
problem: an XModule
problem_descriptor: an XModuleDescriptor
module_creator: a function that takes a descriptor, and returns the corresponding XModule for this user.
Can return None if user doesn't have access, or if something else went wrong.
cache: A StudentModuleCache
"""
if
not
(
problem_descriptor
.
stores_state
and
problem_descriptor
.
has_score
):
...
...
@@ -339,14 +345,16 @@ def get_score(course_id, user, problem_descriptor, module_creator, student_modul
return
(
None
,
None
)
correct
=
0.0
instance_module
=
student_module_cache
.
lookup
(
course_id
,
problem_descriptor
.
category
,
problem_descriptor
.
location
.
url
())
if
not
instance_module
:
# If the problem was not in the cache, we need to instantiate the problem.
# Otherwise, the max score (cached in instance_module) won't be available
# Otherwise, the max score (cached in instance_module) won't be available
problem
=
module_creator
(
problem_descriptor
)
if
problem
is
None
:
return
(
None
,
None
)
instance_module
=
get_instance_module
(
course_id
,
user
,
problem
,
student_module_cache
)
# If this problem is ungraded/ungradable, bail
...
...
@@ -361,7 +369,7 @@ def get_score(course_id, user, problem_descriptor, module_creator, student_modul
weight
=
getattr
(
problem_descriptor
,
'weight'
,
None
)
if
weight
is
not
None
:
if
total
==
0
:
log
.
exception
(
"Cannot reweight a problem with zero
weight
. Problem: "
+
str
(
instance_module
))
log
.
exception
(
"Cannot reweight a problem with zero
total points
. Problem: "
+
str
(
instance_module
))
return
(
correct
,
total
)
correct
=
correct
*
weight
/
total
total
=
weight
...
...
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