Skip to content

Commit

Permalink
removed redundant GradeDisplayWarningDialog and refactored to ES6
Browse files Browse the repository at this point in the history
refs CNVS-34243

test plan:
* Ensure specs pass
* Create a course with 2 assignments and 2 students
* Enter grades for :allthethings:
* Go to original gradebook (not Gradezilla)

* Open the Total column's options.  You should see
  a menu item that says "Display as Percentage"
* Click on this.  You should see a dialog warning
  you that students will see final grades in the
  format you choose.
* Click continue and notice that the Total column
  now shows the final grade as a percentage
* Click on the Total column's options again and
  you should see the menu item changed to say
  "Display as Points"
* Click this and you should see the warning dialog
  again.
* Check the box that says "Don't warn me again"
* Click continue and notice that the Total column
  now shows the final grade as points
* Try switching to percentage one more time and
  notice that the warning dialog is not shown any
  more

Change-Id: Ice4dae05c093e6ba2689b923164a7f0f3d4af173
Reviewed-on: https://gerrit.instructure.com/107450
Reviewed-by: Derek Bender <[email protected]>
Reviewed-by: Jeremy Neander <[email protected]>
Reviewed-by: Neil Gupta <[email protected]>
QA-Review: Anju Reddy <[email protected]>
Tested-by: Jenkins
Product-Review: Keith T. Garner <[email protected]>
  • Loading branch information
sjaveed committed Apr 5, 2017
1 parent 7661b83 commit a3564f6
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 109 deletions.
31 changes: 0 additions & 31 deletions app/coffeescripts/gradebook/GradeDisplayWarningDialog.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion app/coffeescripts/gradebook/Gradebook.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define [
'spin.js'
'compiled/SubmissionDetailsDialog'
'compiled/gradebook/AssignmentGroupWeightsDialog'
'compiled/gradebook/GradeDisplayWarningDialog'
'compiled/shared/GradeDisplayWarningDialog'
'compiled/gradebook/PostGradesFrameDialog'
'compiled/gradebook/SubmissionCell'
'compiled/gradebook/GradebookHeaderMenu'
Expand Down
2 changes: 1 addition & 1 deletion app/coffeescripts/gradezilla/Gradebook.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define [
'compiled/AssignmentMuter'
'compiled/SubmissionDetailsDialog'
'compiled/gradezilla/AssignmentGroupWeightsDialog'
'compiled/gradezilla/GradeDisplayWarningDialog'
'compiled/shared/GradeDisplayWarningDialog'
'compiled/gradezilla/PostGradesFrameDialog'
'compiled/gradezilla/SubmissionCell'
'compiled/util/NumberCompare'
Expand Down
151 changes: 75 additions & 76 deletions spec/javascripts/jsx/gradebook/gradebookSpec.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,86 @@
define(['compiled/gradebook/Gradebook',
'underscore',
'helpers/fakeENV'
], (Gradebook, _, fakeENV) => {
QUnit.module("addRow", {
setup: function() {
fakeENV.setup({
GRADEBOOK_OPTIONS: { context_id: 1 },
});
},
teardown: () => fakeENV.teardown(),
});
import Gradebook from 'compiled/gradebook/Gradebook';
import _ from 'underscore';
import fakeENV from 'helpers/fakeENV';

test("doesn't add filtered out users", () => {
const gb = {
sections_enabled: true,
sections: {"1": {name: "Section 1"}, "2": {name: "Section 2"}},
options: {},
rows: [],
sectionToShow: "2", // this is the filter
...Gradebook.prototype
};
QUnit.module('addRow', {
setup () {
fakeENV.setup({
GRADEBOOK_OPTIONS: { context_id: 1 },
});
},
teardown: () => fakeENV.teardown(),
});

test("doesn't add filtered out users", () => {
const gb = {
sections_enabled: true,
sections: {1: {name: 'Section 1'}, 2: {name: 'Section 2'}},
options: {},
rows: [],
sectionToShow: '2', // this is the filter
...Gradebook.prototype
};

const student1 = {
enrollments: [{grades: {}}],
sections: ["1"],
name: "student",
};
const student2 = {...student1, sections: ["2"]};
const student3 = {...student1, sections: ["2"]};
[student1, student2, student3].forEach(s => gb.addRow(s));
const student1 = {
enrollments: [{grades: {}}],
sections: ['1'],
name: 'student',
};
const student2 = {...student1, sections: ['2']};
const student3 = {...student1, sections: ['2']};
[student1, student2, student3].forEach(s => gb.addRow(s));

ok(student1.row == null, "filtered out students get no row number");
ok(student2.row === 0, "other students do get a row number");
ok(student3.row === 1, "row number increments");
ok(_.isEqual(gb.rows, [student2, student3]));
});
ok(student1.row == null, 'filtered out students get no row number');
ok(student2.row === 0, 'other students do get a row number');
ok(student3.row === 1, 'row number increments');
ok(_.isEqual(gb.rows, [student2, student3]));
});

QUnit.module('Gradebook#groupTotalFormatter', {
setup () {
fakeENV.setup();
},
teardown () {
fakeENV.teardown();
},
});
QUnit.module('Gradebook#groupTotalFormatter', {
setup () {
fakeENV.setup();
},
teardown () {
fakeENV.teardown();
},
});

test('calculates percentage from given score and possible values', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 10 }, {});
ok(groupTotalOutput.includes('9 / 10'));
ok(groupTotalOutput.includes('90%'));
});
test('calculates percentage from given score and possible values', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 10 }, {});
ok(groupTotalOutput.includes('9 / 10'));
ok(groupTotalOutput.includes('90%'));
});

test('displays percentage as "-" when group total score is positive infinity', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
this.stub(gradebook, 'calculateAndRoundGroupTotalScore').returns(Number.POSITIVE_INFINITY);
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 0 }, {});
ok(groupTotalOutput.includes('9 / 0'));
ok(groupTotalOutput.includes('-'));
});
test('displays percentage as "-" when group total score is positive infinity', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
this.stub(gradebook, 'calculateAndRoundGroupTotalScore').returns(Number.POSITIVE_INFINITY);
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 0 }, {});
ok(groupTotalOutput.includes('9 / 0'));
ok(groupTotalOutput.includes('-'));
});

test('displays percentage as "-" when group total score is negative infinity', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
this.stub(gradebook, 'calculateAndRoundGroupTotalScore').returns(Number.NEGATIVE_INFINITY);
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 0 }, {});
ok(groupTotalOutput.includes('9 / 0'));
ok(groupTotalOutput.includes('-'));
});
test('displays percentage as "-" when group total score is negative infinity', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
this.stub(gradebook, 'calculateAndRoundGroupTotalScore').returns(Number.NEGATIVE_INFINITY);
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 0 }, {});
ok(groupTotalOutput.includes('9 / 0'));
ok(groupTotalOutput.includes('-'));
});

test('displays percentage as "-" when group total score is not a number', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
this.stub(gradebook, 'calculateAndRoundGroupTotalScore').returns(NaN);
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 0 }, {});
ok(groupTotalOutput.includes('9 / 0'));
ok(groupTotalOutput.includes('-'));
});
test('displays percentage as "-" when group total score is not a number', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
this.stub(gradebook, 'calculateAndRoundGroupTotalScore').returns(NaN);
const groupTotalOutput = gradebook.groupTotalFormatter(0, 0, { score: 9, possible: 0 }, {});
ok(groupTotalOutput.includes('9 / 0'));
ok(groupTotalOutput.includes('-'));
});

QUnit.module('Gradebook#getFrozenColumnCount');
QUnit.module('Gradebook#getFrozenColumnCount');

test('returns number of columns in frozen section', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
gradebook.parentColumns = [{ id: 'student' }, { id: 'secondary_identifier' }];
gradebook.customColumns = [{ id: 'custom_col_1' }];
equal(gradebook.getFrozenColumnCount(), 3);
});
test('returns number of columns in frozen section', function () {
const gradebook = new Gradebook({ settings: {}, sections: {} });
gradebook.parentColumns = [{ id: 'student' }, { id: 'secondary_identifier' }];
gradebook.customColumns = [{ id: 'custom_col_1' }];
equal(gradebook.getFrozenColumnCount(), 3);
});

0 comments on commit a3564f6

Please sign in to comment.