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
3adb1e71
Commit
3adb1e71
authored
Dec 17, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make grading not require get_instance_module
parent
5cb31c0e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
lms/djangoapps/courseware/grades.py
+22
-19
No files found.
lms/djangoapps/courseware/grades.py
View file @
3adb1e71
...
@@ -9,7 +9,7 @@ from django.conf import settings
...
@@ -9,7 +9,7 @@ from django.conf import settings
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
models
import
StudentModuleCache
from
models
import
StudentModuleCache
from
module_render
import
get_module
,
get_instance_module
from
module_render
import
get_module
from
xmodule
import
graders
from
xmodule
import
graders
from
xmodule.capa_module
import
CapaModule
from
xmodule.capa_module
import
CapaModule
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
...
@@ -338,6 +338,9 @@ def get_score(course_id, user, problem_descriptor, module_creator, student_modul
...
@@ -338,6 +338,9 @@ def get_score(course_id, user, problem_descriptor, module_creator, student_modul
Can return None if user doesn't have access, or if something else went wrong.
Can return None if user doesn't have access, or if something else went wrong.
cache: A StudentModuleCache
cache: A StudentModuleCache
"""
"""
if
not
user
.
is_authenticated
():
return
(
None
,
None
)
if
not
(
problem_descriptor
.
stores_state
and
problem_descriptor
.
has_score
):
if
not
(
problem_descriptor
.
stores_state
and
problem_descriptor
.
has_score
):
# These are not problems, and do not have a score
# These are not problems, and do not have a score
return
(
None
,
None
)
return
(
None
,
None
)
...
@@ -347,29 +350,29 @@ def get_score(course_id, user, problem_descriptor, module_creator, student_modul
...
@@ -347,29 +350,29 @@ def get_score(course_id, user, problem_descriptor, module_creator, student_modul
instance_module
=
student_module_cache
.
lookup
(
instance_module
=
student_module_cache
.
lookup
(
course_id
,
problem_descriptor
.
category
,
problem_descriptor
.
location
.
url
())
course_id
,
problem_descriptor
.
category
,
problem_descriptor
.
location
.
url
())
if
not
instance_module
:
if
instance_module
:
if
instance_module
.
max_grade
is
None
:
return
(
None
,
None
)
correct
=
instance_module
.
grade
if
instance_module
.
grade
is
not
None
else
0
total
=
instance_module
.
max_grade
else
:
# If the problem was not in the cache, we need to instantiate the problem.
# 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
)
problem
=
module_creator
(
problem_descriptor
)
if
problem
is
None
:
if
problem
is
None
:
return
(
None
,
None
)
return
(
None
,
None
)
instance_module
=
get_instance_module
(
course_id
,
user
,
problem
,
student_module_cache
)
# If this problem is ungraded/ungradable, bail
if
not
instance_module
or
instance_module
.
max_grade
is
None
:
return
(
None
,
None
)
correct
=
instance_module
.
grade
if
instance_module
.
grade
is
not
None
else
0
correct
=
0
total
=
instance_module
.
max_grade
total
=
problem
.
max_score
()
if
correct
is
not
None
and
total
is
not
None
:
#Now we re-weight the problem, if specified
#Now we re-weight the problem, if specified
weight
=
getattr
(
problem_descriptor
,
'weight'
,
None
)
weight
=
getattr
(
problem_descriptor
,
'weight'
,
None
)
if
weight
is
not
None
:
if
weight
is
not
None
:
if
total
==
0
:
if
total
==
0
:
log
.
exception
(
"Cannot reweight a problem with zero total points. Problem: "
+
str
(
instance_module
))
log
.
exception
(
"Cannot reweight a problem with zero total points. Problem: "
+
str
(
instance_module
))
return
(
correct
,
total
)
return
(
correct
,
total
)
correct
=
correct
*
weight
/
total
correct
=
correct
*
weight
/
total
total
=
weight
total
=
weight
return
(
correct
,
total
)
return
(
correct
,
total
)
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