Skip to content

Commit

Permalink
Update the progress bar on the XBlock to show a full green bar when t…
Browse files Browse the repository at this point in the history
…he user completes the module. We are simply scaling the progress bar to be full when mastery reaches 0.7, which is the cutoff for full credit. Any grade that is 0.7 or higher is simply just shown as a full bar.
  • Loading branch information
johnjlee committed May 12, 2015
1 parent 3058bf5 commit 5e4d377
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions schoolyourself/static/js/review_student_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,30 @@ function SchoolYourselfReviewStudentView(runtime, element) {

function renderMastery(masteries) {
var mastery = masteries[0][1];
var right = (100 - (mastery * 100)) + '%';

var bg = '#ddd';
if (!mastery) {
// A mastery level of 0.7 gives full credit -- anything beyond that
// doesn't count toward anything. So we should show a full, green bar
// when scaledMastery >= 0.7.
var scaledMastery = mastery / 0.7;

var right = (100 - (scaledMastery * 100)) + '%';

var color = '#fcd380';
if (!scaledMastery) {
var text = 'Get started!';
var color = '#fcd380';
} else if (mastery < 0.35) {
} else if (scaledMastery < 0.5) {
var text = 'Keep practicing!';
var color = '#fcd380';
} else if (mastery < 0.7) {
} else if (scaledMastery < 1) {
var text = 'Almost there!';
var color = '#f0b300';
} else if (mastery < 1) {
var text = 'Full credit!';
var color = '#6eb535';
var bg = '#a1d775';
} else {
var text = 'Mastered!';
var text = 'Complete!';
var color = '#6eb535';
var bg = '#a1d775';
}

$('.schoolyourself-review-mastery-text').html(text);
$('.schoolyourself-review-mastery-bar-filler').css('right', right);
$('.schoolyourself-review-mastery-bar-filler').css('background', color);
$('.schoolyourself-review-mastery-bar').css('background', bg);
}

function updateMastery(masteryUrl) {
Expand Down

0 comments on commit 5e4d377

Please sign in to comment.