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
5535f68b
Commit
5535f68b
authored
Sep 23, 2014
by
Matt Drayer
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/test_graders_fix: Added due field to Score namedtuples
parent
4219e1af
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
27 deletions
+49
-27
common/lib/xmodule/xmodule/graders.py
+5
-3
common/lib/xmodule/xmodule/tests/test_graders.py
+39
-21
lms/djangoapps/courseware/grades.py
+5
-3
No files found.
common/lib/xmodule/xmodule/graders.py
View file @
5535f68b
...
...
@@ -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 module_id"
)
Score
=
namedtuple
(
"Score"
,
"earned possible graded section module_id
due
"
)
def
aggregate_scores
(
scores
,
section_name
=
"summary"
):
...
...
@@ -32,7 +32,8 @@ def aggregate_scores(scores, section_name="summary"):
total_possible
,
False
,
section_name
,
None
None
,
None
,
)
# selecting only graded things
graded_total
=
Score
(
...
...
@@ -40,7 +41,8 @@ def aggregate_scores(scores, section_name="summary"):
total_possible_graded
,
True
,
section_name
,
None
None
,
None
,
)
return
all_total
,
graded_total
...
...
common/lib/xmodule/xmodule/tests/test_graders.py
View file @
5535f68b
...
...
@@ -13,26 +13,44 @@ 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"
,
module_id
=
None
))
self
.
assertEqual
(
graded_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
self
.
assertEqual
(
all_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
self
.
assertEqual
(
graded_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
scores
.
append
(
Score
(
earned
=
0
,
possible
=
5
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
))
scores
.
append
(
Score
(
earned
=
0
,
possible
=
5
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
))
all_total
,
graded_total
=
aggregate_scores
(
scores
)
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
))
self
.
assertEqual
(
all_total
,
Score
(
earned
=
0
,
possible
=
5
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
self
.
assertEqual
(
graded_total
,
Score
(
earned
=
0
,
possible
=
0
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
scores
.
append
(
Score
(
earned
=
3
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
scores
.
append
(
Score
(
earned
=
3
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
))
all_total
,
graded_total
=
aggregate_scores
(
scores
)
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
)
all_total
,
Score
(
earned
=
3
,
possible
=
10
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
self
.
assertAlmostEqual
(
graded_total
,
Score
(
earned
=
3
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
scores
.
append
(
Score
(
earned
=
2
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
))
scores
.
append
(
Score
(
earned
=
2
,
possible
=
5
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
))
all_total
,
graded_total
=
aggregate_scores
(
scores
)
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
)
all_total
,
Score
(
earned
=
5
,
possible
=
15
,
graded
=
False
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
self
.
assertAlmostEqual
(
graded_total
,
Score
(
earned
=
5
,
possible
=
10
,
graded
=
True
,
section
=
"summary"
,
module_id
=
None
,
due
=
None
)
)
...
...
@@ -49,19 +67,19 @@ class GraderTest(unittest.TestCase):
}
test_gradesheet
=
{
'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
)],
'Homework'
:
[
Score
(
earned
=
2
,
possible
=
20.0
,
graded
=
True
,
section
=
'hw1'
,
module_id
=
None
,
due
=
None
),
Score
(
earned
=
16
,
possible
=
16.0
,
graded
=
True
,
section
=
'hw2'
,
module_id
=
None
,
due
=
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'
,
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
)],
'Lab'
:
[
Score
(
earned
=
1
,
possible
=
2.0
,
graded
=
True
,
section
=
'lab1'
,
module_id
=
None
,
due
=
None
),
# Dropped
Score
(
earned
=
1
,
possible
=
1.0
,
graded
=
True
,
section
=
'lab2'
,
module_id
=
None
,
due
=
None
),
Score
(
earned
=
1
,
possible
=
1.0
,
graded
=
True
,
section
=
'lab3'
,
module_id
=
None
,
due
=
None
),
Score
(
earned
=
5
,
possible
=
25.0
,
graded
=
True
,
section
=
'lab4'
,
module_id
=
None
,
due
=
None
),
# Dropped
Score
(
earned
=
3
,
possible
=
4.0
,
graded
=
True
,
section
=
'lab5'
,
module_id
=
None
,
due
=
None
),
# Dropped
Score
(
earned
=
6
,
possible
=
7.0
,
graded
=
True
,
section
=
'lab6'
,
module_id
=
None
,
due
=
None
),
Score
(
earned
=
5
,
possible
=
6.0
,
graded
=
True
,
section
=
'lab7'
,
module_id
=
None
,
due
=
None
)],
'Midterm'
:
[
Score
(
earned
=
50.5
,
possible
=
100
,
graded
=
True
,
section
=
"Midterm Exam"
,
module_id
=
None
),
],
'Midterm'
:
[
Score
(
earned
=
50.5
,
possible
=
100
,
graded
=
True
,
section
=
"Midterm Exam"
,
module_id
=
None
,
due
=
None
),
],
}
def
test_single_section_grader
(
self
):
...
...
lms/djangoapps/courseware/grades.py
View file @
5535f68b
...
...
@@ -253,7 +253,8 @@ def _grade(student, request, course, keep_raw_scores):
total
,
graded
,
module_descriptor
.
display_name_with_default
,
section_due
module_descriptor
.
location
,
section_due
,
)
)
...
...
@@ -261,7 +262,7 @@ def _grade(student, request, course, keep_raw_scores):
if
keep_raw_scores
:
raw_scores
+=
scores
else
:
graded_total
=
Score
(
0.0
,
1.0
,
True
,
section_name
,
section_due
)
graded_total
=
Score
(
0.0
,
1.0
,
True
,
section_name
,
None
,
section_due
)
#Add the graded total to totaled_scores
if
graded_total
.
possible
>
0
:
...
...
@@ -402,7 +403,8 @@ def _progress_summary(student, request, course):
total
,
graded
,
module_descriptor
.
display_name_with_default
,
due
module_descriptor
.
location
,
due
,
)
)
...
...
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