forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed redundant GradeDisplayWarningDialog and refactored to ES6
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
Showing
5 changed files
with
77 additions
and
109 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
app/coffeescripts/gradebook/GradeDisplayWarningDialog.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |