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
e49fd700
Commit
e49fd700
authored
Apr 13, 2012
by
Lyla Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
respones to code review
parent
bfff8222
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
31 deletions
+65
-31
djangoapps/courseware/grades.py
+22
-28
djangoapps/courseware/modules/capa_module.py
+5
-2
djangoapps/courseware/tests.py
+33
-0
templates/problem.html
+5
-1
No files found.
djangoapps/courseware/grades.py
View file @
e49fd700
...
...
@@ -83,7 +83,6 @@ def grade_sheet(student):
graded
=
True
if
s
.
get
(
'graded'
)
==
"true"
else
False
scores
=
[]
weighted
=
False
if
len
(
problems
)
>
0
:
for
p
in
problems
:
(
correct
,
total
)
=
get_grade
(
student
,
p
,
response_by_id
)
...
...
@@ -101,33 +100,9 @@ def grade_sheet(student):
correct
=
random
.
randrange
(
max
(
total
-
2
,
1
)
,
total
+
1
)
else
:
correct
=
total
if
p
.
get
(
"weight"
):
weighted
=
True
scores
.
append
(
Score
(
int
(
correct
),
total
,
p
.
get
(
"weight"
,
1
),
graded
,
p
.
get
(
"name"
))
)
if
weighted
:
total_correct_graded
=
sum
([(
score
.
earned
*
1.0
/
score
.
possible
)
*
int
(
score
.
weight
)
for
score
in
scores
if
score
.
graded
])
total_possible_graded
=
sum
([
int
(
score
.
weight
)
for
score
in
scores
if
score
.
graded
])
total_correct
=
sum
([(
score
.
earned
*
1.0
/
score
.
possible
)
*
int
(
score
.
weight
)
for
score
in
scores
])
total_possible
=
sum
([
int
(
score
.
weight
)
for
score
in
scores
])
section_weight
=
s
.
get
(
"weight"
,
1
)
else
:
total_correct_graded
=
sum
([
score
.
earned
for
score
in
scores
if
score
.
graded
])
total_possible_graded
=
sum
([
score
.
possible
for
score
in
scores
if
score
.
graded
])
total_correct
=
sum
([
score
.
earned
for
score
in
scores
])
total_possible
=
sum
([
score
.
possible
for
score
in
scores
])
section_weight
=
None
#regardless of whether or not it is graded
section_total
=
Score
(
total_correct
,
total_possible
,
section_weight
,
False
,
p
.
get
(
"id"
))
#selecting only graded things
graded_total
=
Score
(
total_correct_graded
,
total_possible_graded
,
section_weight
,
True
,
p
.
get
(
"id"
))
scores
.
append
(
Score
(
int
(
correct
),
total
,
float
(
p
.
get
(
"weight"
,
1
)),
graded
,
p
.
get
(
"name"
))
)
section_total
,
graded_total
=
aggregate_scores
(
scores
)
#Add the graded total to totaled_scores
format
=
s
.
get
(
'format'
)
if
s
.
get
(
'format'
)
else
""
subtitle
=
s
.
get
(
'subtitle'
)
if
s
.
get
(
'subtitle'
)
else
format
...
...
@@ -155,6 +130,25 @@ def grade_sheet(student):
'grade_summary'
:
grade_summary
,
#graded assessments only
}
def
aggregate_scores
(
scores
):
total_correct_graded
=
sum
((
score
.
earned
*
1.0
/
score
.
possible
)
*
score
.
weight
for
score
in
scores
if
score
.
graded
)
total_possible_graded
=
sum
(
score
.
weight
for
score
in
scores
if
score
.
graded
)
total_correct
=
sum
((
score
.
earned
*
1.0
/
score
.
possible
)
*
score
.
weight
for
score
in
scores
)
total_possible
=
sum
(
score
.
weight
for
score
in
scores
)
#regardless of whether or not it is graded
all_total
=
Score
(
total_correct
,
total_possible
,
1
,
False
,
"summary"
)
#selecting only graded things
graded_total
=
Score
(
total_correct_graded
,
total_possible_graded
,
1
,
True
,
"summary"
)
return
all_total
,
graded_total
def
grade_summary_6002x
(
totaled_scores
):
"""
...
...
djangoapps/courseware/modules/capa_module.py
View file @
e49fd700
...
...
@@ -71,7 +71,9 @@ class Module(XModule):
def
get_problem_html
(
self
,
encapsulate
=
True
):
html
=
self
.
lcp
.
get_html
()
content
=
{
'name'
:
self
.
name
,
'html'
:
html
}
'html'
:
html
,
'weight'
:
self
.
weight
,
}
# We using strings as truthy values, because the terminology of the check button
# is context-specific.
...
...
@@ -136,7 +138,7 @@ class Module(XModule):
self
.
max_attempts
=
None
dom2
=
etree
.
fromstring
(
xml
)
self
.
explanation
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@explain'
),
default
=
"closed"
)
self
.
explain_available
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@explain_available'
))
...
...
@@ -186,6 +188,7 @@ class Module(XModule):
self
.
filename
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@filename'
))
filename
=
settings
.
DATA_DIR
+
"/problems/"
+
self
.
filename
+
".xml"
self
.
name
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@name'
))
self
.
weight
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@weight'
))
if
self
.
rerandomize
==
'never'
:
seed
=
1
else
:
...
...
djangoapps/courseware/tests.py
View file @
e49fd700
...
...
@@ -4,6 +4,7 @@ import numpy
import
courseware.modules
import
courseware.capa.calc
as
calc
from
grades
import
Score
,
aggregate_scores
class
ModelsTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -53,3 +54,35 @@ class ModelsTest(unittest.TestCase):
exception_happened
=
True
self
.
assertTrue
(
exception_happened
)
class
GraderTest
(
unittest
.
TestCase
):
def
test_weighted_grading
(
self
):
scores
=
[]
all
,
graded
=
aggregate_scores
(
scores
)
self
.
assertTrue
(
all
.
earned
==
0
)
self
.
assertTrue
(
graded
.
earned
==
0
)
self
.
assertTrue
(
all
.
possible
==
0
)
self
.
assertTrue
(
graded
.
possible
==
0
)
scores
.
append
(
Score
(
0
,
5
,
1
,
False
,
'foo'
))
all
,
graded
=
aggregate_scores
(
scores
)
self
.
assertTrue
(
all
.
earned
==
0
)
self
.
assertTrue
(
graded
.
earned
==
0
)
print
all
self
.
assertTrue
(
all
.
possible
==
1
)
self
.
assertTrue
(
graded
.
possible
==
0
)
scores
.
append
(
Score
(
3
,
5
,
1
,
True
,
'foo'
))
all
,
graded
=
aggregate_scores
(
scores
)
self
.
assertTrue
(
all
.
earned
==
3.0
/
5
)
self
.
assertTrue
(
graded
.
earned
==
3.0
/
5
)
self
.
assertTrue
(
all
.
possible
==
2
)
self
.
assertTrue
(
graded
.
possible
==
1
)
scores
.
append
(
Score
(
2
,
5
,
2
,
True
,
'foo'
))
all
,
graded
=
aggregate_scores
(
scores
)
self
.
assertTrue
(
all
.
earned
==
7.0
/
5
)
self
.
assertTrue
(
graded
.
earned
==
7.0
/
5
)
self
.
assertTrue
(
all
.
possible
==
4
)
self
.
assertTrue
(
graded
.
possible
==
3
)
templates/problem.html
View file @
e49fd700
<h2>
${ problem['name'] }
</h2>
<h2
class=
"problem-header"
>
${ problem['name'] }
% if problem['weight']:
: ${ problem['weight'] } points
% endif
</h2>
<section
class=
"problem"
>
${ problem['html'] }
...
...
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