Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
48b93fc9
Commit
48b93fc9
authored
12 years ago
by
kimth
Browse files
Options
Downloads
Patches
Plain Diff
Arbitrary grading markers
parent
31ff5f28
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/grades.py
+4
-1
4 additions, 1 deletion
lms/djangoapps/courseware/grades.py
lms/templates/courseware/progress_graph.js
+29
-6
29 additions, 6 deletions
lms/templates/courseware/progress_graph.js
with
33 additions
and
7 deletions
lms/djangoapps/courseware/grades.py
+
4
−
1
View file @
48b93fc9
...
...
@@ -226,7 +226,10 @@ def grade_for_percentage(grade_cutoffs, percentage):
"""
letter_grade
=
None
for
possible_grade
in
[
'
A
'
,
'
B
'
,
'
C
'
]:
# Possible grades, sorted in descending order of score
descending_grades
=
sorted
(
grade_cutoffs
,
key
=
lambda
x
:
grade_cutoffs
[
x
],
reverse
=
True
)
for
possible_grade
in
descending_grades
:
if
percentage
>=
grade_cutoffs
[
possible_grade
]:
letter_grade
=
possible_grade
break
...
...
This diff is collapsed.
Click to expand it.
lms/templates/courseware/progress_graph.js
+
29
−
6
View file @
48b93fc9
...
...
@@ -18,7 +18,16 @@ $(function () {
opacity
:
0.90
}).
appendTo
(
"
body
"
).
fadeIn
(
200
);
}
function
sortGradeCutoffs
(
obj
)
{
var
arr
=
[];
for
(
var
prop
in
obj
)
if
(
obj
.
hasOwnProperty
(
prop
))
arr
.
push
({
'
key
'
:
prop
,
'
value
'
:
obj
[
prop
]});
arr
.
sort
(
function
(
a
,
b
)
{
return
b
.
value
-
a
.
value
;
});
return
arr
.
map
(
function
(
el
)
{
return
el
.
key
;
});
}
/* -------------------------------- Grade detail bars -------------------------------- */
<%
...
...
@@ -97,7 +106,8 @@ $(function () {
## ----------------------------- Grade cutoffs ------------------------- ##
grade_cutoff_ticks = [ [1, "100%"], [0, "0%"] ]
for grade in [
'
A
'
,
'
B
'
,
'
C
'
]:
descending_grades = sorted(grade_cutoffs, key=lambda x: grade_cutoffs[x], reverse=True)
for grade in descending_grades:
percent = grade_cutoffs[grade]
grade_cutoff_ticks.append( [ percent, "{0} {1:.0%}".format(grade, percent) ] )
%>
...
...
@@ -109,18 +119,31 @@ $(function () {
var droppedScores = ${ json.dumps(droppedScores) };
var grade_cutoff_ticks = ${ json.dumps(grade_cutoff_ticks) }
//Alwa
s
y be sure that one series has the xaxis set to 2, or the second xaxis labels won
'
t
show
up
//Alway
s
be sure that one series has the xaxis set to 2, or the second xaxis labels won
'
t
show
up
series
.
push
(
{
label
:
'
Dropped Scores
'
,
data
:
droppedScores
,
points
:
{
symbol
:
"
cross
"
,
show
:
true
,
radius
:
3
},
bars
:
{
show
:
false
},
color
:
"
#333
"
}
);
// Allow for arbitrary grade markers e.g. ['A', 'B', 'C'], ['Pass'], etc.
// by building the grade markers and grid markings from the `grade_cutoffs` object
var
grade_cutoffs
=
JSON
.
parse
(
'
${ json.dumps(grade_cutoffs) }
'
);
descending_grades
=
sortGradeCutoffs
(
grade_cutoffs
);
var
colors
=
[
'
#ddd
'
,
'
#e9e9e9
'
,
'
#f3f3f3
'
];
var
markings
=
[];
var
marking_from
,
marking_to
=
1
;
for
(
var
i
=
0
;
i
<
descending_grades
.
length
;
i
++
)
{
marking_from
=
grade_cutoffs
[
descending_grades
[
i
]];
var
marking
=
{
yaxis
:
{
from
:
marking_from
,
to
:
marking_to
},
color
:
colors
[
i
%
colors
.
length
]};
marking_to
=
marking_from
;
markings
.
push
(
marking
);
}
var
options
=
{
series
:
{
stack
:
true
,
lines
:
{
show
:
false
,
steps
:
false
},
bars
:
{
show
:
true
,
barWidth
:
0.8
,
align
:
'
center
'
,
lineWidth
:
0
,
fill
:
.
8
},},
xaxis
:
{
tickLength
:
0
,
min
:
0.0
,
max
:
$
{
tickIndex
-
sectionSpacer
},
ticks
:
ticks
,
labelAngle
:
90
},
yaxis
:
{
ticks
:
grade_cutoff_ticks
,
min
:
0.0
,
max
:
1.0
,
labelWidth
:
50
},
grid
:
{
hoverable
:
true
,
clickable
:
true
,
borderWidth
:
1
,
markings
:
[
{
yaxis
:
{
from
:
$
{
grade_cutoffs
[
'
A
'
]},
to
:
1
},
color
:
"
#ddd
"
},
{
yaxis
:
{
from
:
$
{
grade_cutoffs
[
'
B
'
]},
to
:
$
{
grade_cutoffs
[
'
A
'
]}
},
color
:
"
#e9e9e9
"
},
{
yaxis
:
{
from
:
$
{
grade_cutoffs
[
'
C
'
]},
to
:
$
{
grade_cutoffs
[
'
B
'
]}
},
color
:
"
#f3f3f3
"
},
]
},
grid
:
{
hoverable
:
true
,
clickable
:
true
,
borderWidth
:
1
,
markings
:
markings
},
legend
:
{
show
:
false
},
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment