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
7df9ab9c
Commit
7df9ab9c
authored
Apr 17, 2015
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend the Score namedtuple to know about module locations.
parent
53da306c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
33 deletions
+49
-33
common/lib/xmodule/xmodule/graders.py
+15
-9
common/lib/xmodule/xmodule/tests/test_graders.py
+21
-21
lms/djangoapps/courseware/grades.py
+13
-3
No files found.
common/lib/xmodule/xmodule/graders.py
View file @
7df9ab9c
...
...
@@ -10,7 +10,7 @@ log = logging.getLogger("edx.courseware")
# This is a tuple for holding scores, either from problems or sections.
# Section either indicates the name of the problem or the name of the section
Score
=
namedtuple
(
"Score"
,
"earned possible graded section"
)
Score
=
namedtuple
(
"Score"
,
"earned possible graded section
module_id
"
)
def
aggregate_scores
(
scores
,
section_name
=
"summary"
):
...
...
@@ -27,15 +27,21 @@ def aggregate_scores(scores, section_name="summary"):
total_possible
=
sum
(
score
.
possible
for
score
in
scores
)
#regardless of whether or not it is graded
all_total
=
Score
(
total_correct
,
total_possible
,
False
,
section_name
)
all_total
=
Score
(
total_correct
,
total_possible
,
False
,
section_name
,
None
)
#selecting only graded things
graded_total
=
Score
(
total_correct_graded
,
total_possible_graded
,
True
,
section_name
)
graded_total
=
Score
(
total_correct_graded
,
total_possible_graded
,
True
,
section_name
,
None
)
return
all_total
,
graded_total
...
...
common/lib/xmodule/xmodule/tests/test_graders.py
View file @
7df9ab9c
...
...
@@ -13,23 +13,23 @@ class GradesheetTest(unittest.TestCase):
Score
.
__sub__
=
lambda
me
,
other
:
(
me
.
earned
-
other
.
earned
)
+
(
me
.
possible
-
other
.
possible
)
all_total
,
graded_total
=
aggregate_scores
(
scores
)
self
.
assertEqual
(
all_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
False
,
section
=
"summary"
))
self
.
assertEqual
(
graded_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
True
,
section
=
"summary"
))
self
.
assertEqual
(
all_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
))
self
.
assertEqual
(
graded_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
scores
.
append
(
Score
(
earned
=
0
,
possible
=
5
,
graded
=
False
,
section
=
"summary"
))
scores
.
append
(
Score
(
earned
=
0
,
possible
=
5
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
))
all_total
,
graded_total
=
aggregate_scores
(
scores
)
self
.
assertEqual
(
all_total
,
Score
(
earned
=
0
,
possible
=
5
,
graded
=
False
,
section
=
"summary"
))
self
.
assertEqual
(
graded_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
True
,
section
=
"summary"
))
self
.
assertEqual
(
all_total
,
Score
(
earned
=
0
,
possible
=
5
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
))
self
.
assertEqual
(
graded_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
scores
.
append
(
Score
(
earned
=
3
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
))
scores
.
append
(
Score
(
earned
=
3
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
all_total
,
graded_total
=
aggregate_scores
(
scores
)
self
.
assertAlmostEqual
(
all_total
,
Score
(
earned
=
3
,
possible
=
10
,
graded
=
False
,
section
=
"summary"
))
self
.
assertAlmostEqual
(
graded_total
,
Score
(
earned
=
3
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
))
self
.
assertAlmostEqual
(
all_total
,
Score
(
earned
=
3
,
possible
=
10
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
))
self
.
assertAlmostEqual
(
graded_total
,
Score
(
earned
=
3
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
scores
.
append
(
Score
(
earned
=
2
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
))
scores
.
append
(
Score
(
earned
=
2
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
all_total
,
graded_total
=
aggregate_scores
(
scores
)
self
.
assertAlmostEqual
(
all_total
,
Score
(
earned
=
5
,
possible
=
15
,
graded
=
False
,
section
=
"summary"
))
self
.
assertAlmostEqual
(
graded_total
,
Score
(
earned
=
5
,
possible
=
10
,
graded
=
True
,
section
=
"summary"
))
self
.
assertAlmostEqual
(
all_total
,
Score
(
earned
=
5
,
possible
=
15
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
))
self
.
assertAlmostEqual
(
graded_total
,
Score
(
earned
=
5
,
possible
=
10
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
class
GraderTest
(
unittest
.
TestCase
):
...
...
@@ -45,19 +45,19 @@ class GraderTest(unittest.TestCase):
}
test_gradesheet
=
{
'Homework'
:
[
Score
(
earned
=
2
,
possible
=
20.0
,
graded
=
True
,
section
=
'hw1'
),
Score
(
earned
=
16
,
possible
=
16.0
,
graded
=
True
,
section
=
'hw2'
)],
'Homework'
:
[
Score
(
earned
=
2
,
possible
=
20.0
,
graded
=
True
,
section
=
'hw1'
,
module_id
=
None
),
Score
(
earned
=
16
,
possible
=
16.0
,
graded
=
True
,
section
=
'hw2'
,
module_id
=
None
)],
# The dropped scores should be from the assignments that don't exist yet
'Lab'
:
[
Score
(
earned
=
1
,
possible
=
2.0
,
graded
=
True
,
section
=
'lab1'
),
# Dropped
Score
(
earned
=
1
,
possible
=
1.0
,
graded
=
True
,
section
=
'lab2'
),
Score
(
earned
=
1
,
possible
=
1.0
,
graded
=
True
,
section
=
'lab3'
),
Score
(
earned
=
5
,
possible
=
25.0
,
graded
=
True
,
section
=
'lab4'
),
# Dropped
Score
(
earned
=
3
,
possible
=
4.0
,
graded
=
True
,
section
=
'lab5'
),
# Dropped
Score
(
earned
=
6
,
possible
=
7.0
,
graded
=
True
,
section
=
'lab6'
),
Score
(
earned
=
5
,
possible
=
6.0
,
graded
=
True
,
section
=
'lab7'
)],
'Lab'
:
[
Score
(
earned
=
1
,
possible
=
2.0
,
graded
=
True
,
section
=
'lab1'
,
module_id
=
None
),
# Dropped
Score
(
earned
=
1
,
possible
=
1.0
,
graded
=
True
,
section
=
'lab2'
,
module_id
=
None
),
Score
(
earned
=
1
,
possible
=
1.0
,
graded
=
True
,
section
=
'lab3'
,
module_id
=
None
),
Score
(
earned
=
5
,
possible
=
25.0
,
graded
=
True
,
section
=
'lab4'
,
module_id
=
None
),
# Dropped
Score
(
earned
=
3
,
possible
=
4.0
,
graded
=
True
,
section
=
'lab5'
,
module_id
=
None
),
# Dropped
Score
(
earned
=
6
,
possible
=
7.0
,
graded
=
True
,
section
=
'lab6'
,
module_id
=
None
),
Score
(
earned
=
5
,
possible
=
6.0
,
graded
=
True
,
section
=
'lab7'
,
module_id
=
None
)],
'Midterm'
:
[
Score
(
earned
=
50.5
,
possible
=
100
,
graded
=
True
,
section
=
"Midterm Exam"
),
],
'Midterm'
:
[
Score
(
earned
=
50.5
,
possible
=
100
,
graded
=
True
,
section
=
"Midterm Exam"
,
module_id
=
None
),
],
}
def
test_single_section_grader
(
self
):
...
...
lms/djangoapps/courseware/grades.py
View file @
7df9ab9c
...
...
@@ -228,13 +228,15 @@ def _grade(student, request, course, keep_raw_scores):
#We simply cannot grade a problem that is 12/0, because we might need it as a percentage
graded
=
False
scores
.
append
(
Score
(
correct
,
total
,
graded
,
module_descriptor
.
display_name_with_default
))
scores
.
append
(
Score
(
correct
,
total
,
graded
,
module_descriptor
.
display_name_with_default
,
module_descriptor
.
location
)
)
_
,
graded_total
=
graders
.
aggregate_scores
(
scores
,
section_name
)
if
keep_raw_scores
:
raw_scores
+=
scores
else
:
graded_total
=
Score
(
0.0
,
1.0
,
True
,
section_name
)
graded_total
=
Score
(
0.0
,
1.0
,
True
,
section_name
,
None
)
#Add the graded total to totaled_scores
if
graded_total
.
possible
>
0
:
...
...
@@ -364,7 +366,15 @@ def _progress_summary(student, request, course):
if
correct
is
None
and
total
is
None
:
continue
scores
.
append
(
Score
(
correct
,
total
,
graded
,
module_descriptor
.
display_name_with_default
))
scores
.
append
(
Score
(
correct
,
total
,
graded
,
module_descriptor
.
display_name_with_default
,
module_descriptor
.
location
)
)
scores
.
reverse
()
section_total
,
_
=
graders
.
aggregate_scores
(
...
...
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