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
b0e2ea3a
Commit
b0e2ea3a
authored
Apr 06, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Still working on grades refactor. Not working yet, but reached a checkpoint.
parent
a0eb072a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
90 deletions
+48
-90
djangoapps/courseware/grades.py
+25
-21
templates/profile_graphs.js
+23
-69
No files found.
djangoapps/courseware/grades.py
View file @
b0e2ea3a
...
...
@@ -19,7 +19,7 @@ SectionPercentage = namedtuple("SectionPercentage", "percentage label summary")
class
CourseGrader
:
def
grade
(
self
,
grade_sheet
):
raise
NotImplementedError
class
FormatWithDropsGrader
(
CourseGrader
):
"""
Grades all sections specified in course_format with an equal weight. A specified
...
...
@@ -62,14 +62,14 @@ class FormatWithDropsGrader(CourseGrader):
def
grade
(
self
,
grade_sheet
):
def
totalWithDrops
(
breakdown
,
drop_count
):
#create an array of tuples with (index, mark), sorted by mark['percent
age
'] descending
sorted_breakdown
=
sorted
(
enumerate
(
breakdown
),
key
=
lambda
x
:
-
x
[
1
][
'percent
age
'
]
)
#create an array of tuples with (index, mark), sorted by mark['percent'] descending
sorted_breakdown
=
sorted
(
enumerate
(
breakdown
),
key
=
lambda
x
:
-
x
[
1
][
'percent'
]
)
# A list of the indices of the dropped scores
dropped_indices
=
[
x
[
0
]
for
x
in
sorted_breakdown
[
-
drop_count
:]]
aggregate_score
=
0
for
index
,
mark
in
enumerate
(
breakdown
):
if
index
not
in
dropped_indices
:
aggregate_score
+=
mark
[
'percent
age
'
]
aggregate_score
+=
mark
[
'percent'
]
aggregate_score
/=
len
(
scores
)
-
drop_count
...
...
@@ -81,38 +81,38 @@ class FormatWithDropsGrader(CourseGrader):
for
i
in
range
(
12
):
if
i
<
len
(
scores
):
percentage
=
scores
[
i
]
.
earned
/
float
(
scores
[
i
]
.
possible
)
summary
=
self
.
section_detail_formatter
.
format
(
index
:
i
+
1
,
name
:
scores
[
i
]
.
section
,
percent
age
:
percentage
,
earned
:
scores
[
i
]
.
earned
,
possible
:
scores
[
i
]
.
possible
)
summary
=
self
.
section_detail_formatter
.
format
(
index
=
i
+
1
,
name
=
scores
[
i
]
.
section
,
percent
=
percentage
,
earned
=
scores
[
i
]
.
earned
,
possible
=
scores
[
i
]
.
possible
)
else
:
percentage
=
0
summary
=
self
.
section_missing_detail_formatter
.
format
(
index
:
i
+
1
)
summary
=
self
.
section_missing_detail_formatter
.
format
(
index
=
i
+
1
)
if
settings
.
GENERATE_PROFILE_SCORES
:
points_possible
=
random
.
randrange
(
10
,
50
)
points_earned
=
random
.
randrange
(
5
,
points_possible
)
percentage
=
points_earned
/
float
(
points_possible
)
summary
=
self
.
section_detail_formatter
.
format
(
index
:
i
+
1
,
name
:
"Randomly Generated"
,
percent
age
:
percentage
,
earned
:
points_earned
,
possible
:
points_possible
)
summary
=
self
.
section_detail_formatter
.
format
(
index
=
i
+
1
,
name
=
"Randomly Generated"
,
percent
=
percentage
,
earned
=
points_earned
,
possible
=
points_possible
)
label
=
self
.
section_label_formatter
.
format
(
index
:
i
+
1
)
label
=
self
.
section_label_formatter
.
format
(
index
=
i
+
1
)
breakdown
.
append
(
{
'percent'
:
percentage
,
'label'
:
label
,
'detail'
:
summary
,
category
:
self
.
category
}
)
breakdown
.
append
(
{
'percent'
:
percentage
,
'label'
:
label
,
'detail'
:
summary
,
'category'
:
self
.
category
}
)
total_percent
,
dropped_indices
=
totalWithDrops
(
breakdown
,
self
.
drop_count
)
for
dropped_index
in
dropped_indic
i
es
:
for
dropped_index
in
dropped_indices
:
breakdown
[
dropped_index
][
'mark'
]
=
{
'detail'
:
"The lowest {0} scores are dropped."
.
format
(
self
.
drop_count
)
}
total_detail
=
self
.
total_detail_formatter
.
format
(
percent
:
total_percent
)
breakdown
.
append
(
{
'percent'
:
total_percent
,
'label'
:
self
.
total_label_formatter
,
'detail'
:
total_detail
,
category
:
self
.
category
,
prominent
:
True
}
)
total_detail
=
self
.
total_detail_formatter
.
format
(
percent
=
total_percent
)
breakdown
.
append
(
{
'percent'
:
total_percent
,
'label'
:
self
.
total_label_formatter
,
'detail'
:
total_detail
,
'category'
:
self
.
category
,
'prominent'
:
True
}
)
return
{
'percent'
:
total_percent
,
...
...
@@ -245,7 +245,11 @@ def grade_sheet(student):
'sections'
:
sections
,})
grade_summary
=
grade_summary_6002x
(
totaled_scores
)
grader
=
FormatWithDropsGrader
(
"Homework"
,
12
,
2
,
"Homework"
,
"Homework {index} - {name} - {percent:.0
%
} ({earned:g}/{possible:g})"
,
"Unreleased Homework {index} - 0
%
(?/?)"
,
"HW {index:02d}"
,
"Homework Average = {percent:.0
%
}"
,
"HW Avg"
)
grade_summary
=
grader
.
grade
(
totaled_scores
)
return
{
'courseware_summary'
:
chapters
,
'grade_summary'
:
grade_summary
}
...
...
templates/profile_graphs.js
View file @
b0e2ea3a
...
...
@@ -22,6 +22,7 @@ $(function () {
<%
colors
=
[
"#b72121"
,
"#600101"
,
"#666666"
,
"#333333"
]
categories
=
{}
#
'
tickIndex = 1
sectionSpacer = 0.5
...
...
@@ -34,78 +35,31 @@ $(function () {
droppedScores = [] #These are the datapoints to indicate assignments which aren'
t
factored
into
the
total
score
dropped_score_tooltips
=
[]
for
section
in
grade_summary
:
if
'subscores'
in
section
:
##
This
is
for
sections
like
labs
or
homeworks
,
with
several
smaller
components
and
a
total
series
.
append
({
'label'
:
section
[
'category'
],
'data'
:
[[
i
+
tickIndex
,
score
.
percentage
]
for
i
,
score
in
enumerate
(
section
[
'subscores'
])],
'color'
:
colors
[
sectionIndex
]
})
ticks
+=
[[
i
+
tickIndex
,
score
.
label
]
for
i
,
score
in
enumerate
(
section
[
'subscores'
])]
bottomTicks
.
append
(
[
tickIndex
+
len
(
section
[
'subscores'
])
/
2
,
section
[
'category'
]]
)
detail_tooltips
[
section
[
'category'
]
]
=
[
score
.
summary
for
score
in
section
[
'subscores'
]]
droppedScores
+=
[[
tickIndex
+
index
,
0.05
]
for
index
in
section
[
'dropped_indices'
]]
dropExplanation
=
"The lowest {0} {1} scores are dropped"
.
format
(
len
(
section
[
'dropped_indices'
]),
section
[
'category'
]
)
dropped_score_tooltips
+=
[
dropExplanation
]
*
len
(
section
[
'dropped_indices'
])
tickIndex
+=
len
(
section
[
'subscores'
])
+
sectionSpacer
category_total_label
=
section
[
'category'
]
+
" Total"
series
.
append
({
'label'
:
category_total_label
,
'data'
:
[
[
tickIndex
,
section
[
'totalscore'
]]
],
'color'
:
colors
[
sectionIndex
]
})
ticks
.
append
(
[
tickIndex
,
section
[
'totallabel'
]]
)
detail_tooltips
[
category_total_label
]
=
[
section
[
'totalscore_summary'
]]
else
:
series
.
append
({
'label'
:
section
[
'category'
],
'data'
:
[
[
tickIndex
,
section
[
'totalscore'
]]
],
'color'
:
colors
[
sectionIndex
]
})
ticks
.
append
(
[
tickIndex
,
section
[
'totallabel'
]]
)
detail_tooltips
[
section
[
'category'
]]
=
[
section
[
'totalscore_summary'
]]
for
section
in
grade_summary
[
'section_breakdown'
]:
if
section
.
get
(
'prominent'
,
False
):
tickIndex
+=
sectionSpacer
if
section
[
'category'
]
not
in
categories
:
colorIndex
=
len
(
categories
)
%
len
(
colors
)
categories
[
section
[
'category'
]
]
=
{
'label'
:
section
[
'category'
],
'data'
:
[],
'color'
:
colors
[
colorIndex
]}
tickIndex
+=
1
+
sectionSpacer
sectionIndex
+=
1
detail_tooltips
[
'Dropped Scores'
]
=
dropped_score_tooltips
categoryData
=
categories
[
section
[
'category'
]
]
##
-----------------------------
Grade
overviewew
bar
-------------------------
##
totalWeight
=
0.0
sectionIndex
=
0
totalScore
=
0.0
overviewBarX
=
tickIndex
for
section
in
grade_summary
:
weighted_score
=
section
[
'totalscore'
]
*
section
[
'weight'
]
summary_text
=
"{0} - {1:.1%} of a possible {2:.0%}"
.
format
(
section
[
'category'
],
weighted_score
,
section
[
'weight'
])
weighted_category_label
=
section
[
'category'
]
+
" - Weighted"
if
section
[
'totalscore'
]
>
0
:
series
.
append
({
'label'
:
weighted_category_label
,
'data'
:
[
[
overviewBarX
,
weighted_score
]
],
'color'
:
colors
[
sectionIndex
]
})
detail_tooltips
[
weighted_category_label
]
=
[
summary_text
]
sectionIndex
+=
1
totalWeight
+=
section
[
'weight'
]
totalScore
+=
section
[
'totalscore'
]
*
section
[
'weight'
]
categoryData
[
'data'
].
append
(
[
tickIndex
,
section
[
'percent'
]]
)
ticks
.
append
(
[
tickIndex
,
section
[
'label'
]
]
)
if
section
[
'category'
]
in
detail_tooltips
:
detail_tooltips
[
section
[
'category'
]
].
append
(
section
[
'detail'
]
)
else
:
detail_tooltips
[
section
[
'category'
]
]
=
[
section
[
'detail'
],
]
ticks
+=
[
[
overviewBarX
,
"Total"
]
]
tickIndex
+=
1
+
sectionSpacer
tickIndex
+=
1
if
section
.
get
(
'prominent'
,
False
):
tickIndex
+=
sectionSpacer
%>
var
series
=
$
{
json
.
dumps
(
series
)
};
...
...
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