From 48b93fc985984b3e97c5e8843d083e38decc983d Mon Sep 17 00:00:00 2001 From: kimth Date: Sat, 22 Sep 2012 23:01:04 -0700 Subject: [PATCH 1/5] Arbitrary grading markers --- lms/djangoapps/courseware/grades.py | 5 +++- lms/templates/courseware/progress_graph.js | 35 ++++++++++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index e3e66724a5..452e30e032 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -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 diff --git a/lms/templates/courseware/progress_graph.js b/lms/templates/courseware/progress_graph.js index 9826250331..3b6320daf5 100644 --- a/lms/templates/courseware/progress_graph.js +++ b/lms/templates/courseware/progress_graph.js @@ -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) } - //Alwasy be sure that one series has the xaxis set to 2, or the second xaxis labels won't show up + //Always 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 Date: Sat, 22 Sep 2012 23:11:26 -0700 Subject: [PATCH 2/5] Adjust comments --- lms/djangoapps/courseware/grades.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index 452e30e032..df079b7703 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -217,7 +217,7 @@ def grade(student, request, course, student_module_cache=None, keep_raw_scores=F def grade_for_percentage(grade_cutoffs, percentage): """ - Returns a letter grade 'A' 'B' 'C' or None. + Returns a letter grade as defined in grading_policy (e.g. 'A' 'B' 'C' for 6.002x) or None. Arguments - grade_cutoffs is a dictionary mapping a grade to the lowest From b376bc09a3639eb4f5cdc0ee39ca2463dfd6d5d9 Mon Sep 17 00:00:00 2001 From: kimth Date: Sun, 23 Sep 2012 18:46:10 -0700 Subject: [PATCH 3/5] Arbitrary progress bar coloring --- lms/templates/courseware/progress_graph.js | 25 +++++----------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lms/templates/courseware/progress_graph.js b/lms/templates/courseware/progress_graph.js index 3b6320daf5..b2fcda67b5 100644 --- a/lms/templates/courseware/progress_graph.js +++ b/lms/templates/courseware/progress_graph.js @@ -19,15 +19,6 @@ $(function () { }).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 -------------------------------- */ <% @@ -123,19 +114,13 @@ $(function () { 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 ascending_grades = grade_cutoff_ticks.map(function (el) { return el[0]; }); + ascending_grades.sort(); - var colors = ['#ddd', '#e9e9e9', '#f3f3f3']; + var colors = ['#f3f3f3', '#e9e9e9', '#ddd']; var markings = []; - var marking_from, marking_to = 1; - for(var i=0; i Date: Sun, 23 Sep 2012 18:47:35 -0700 Subject: [PATCH 4/5] Add comments --- lms/templates/courseware/progress_graph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/templates/courseware/progress_graph.js b/lms/templates/courseware/progress_graph.js index b2fcda67b5..44ee2efd07 100644 --- a/lms/templates/courseware/progress_graph.js +++ b/lms/templates/courseware/progress_graph.js @@ -114,12 +114,12 @@ $(function () { 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. - var ascending_grades = grade_cutoff_ticks.map(function (el) { return el[0]; }); + var ascending_grades = grade_cutoff_ticks.map(function (el) { return el[0]; }); // Percentage point (in decimal) of each grade cutoff ascending_grades.sort(); var colors = ['#f3f3f3', '#e9e9e9', '#ddd']; var markings = []; - for(var i=1; i Date: Sun, 23 Sep 2012 20:53:38 -0700 Subject: [PATCH 5/5] Increase height of progress graph; allows for more cutoffs to look reasonable --- lms/static/sass/course/_profile.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/static/sass/course/_profile.scss b/lms/static/sass/course/_profile.scss index 5b1d6ee068..0683781e44 100644 --- a/lms/static/sass/course/_profile.scss +++ b/lms/static/sass/course/_profile.scss @@ -150,7 +150,7 @@ div.profile-wrapper { } div#grade-detail-graph { - min-height: 300px; + min-height: 400px; width: 100%; }