use raw score when grading schemes disabled
In the Student Grades Summary page, when a course does not have a grading scheme enabled, but a final grade override exists, show the raw override percentage, as opposed to the letter grade plus the letter bound of that letter grade. fixes GRADE-1931 Test Plan - Disable the course's grading scheme, if one is enabled. - Override a student's grading period or course scores via New Gradebook. - Verify that the student's grades page displays with the raw override percentage. Change-Id: Ib712fc6d43e4f65fab6d9f45580fa320a366f6a3 Reviewed-on: https://gerrit.instructure.com/177604 Tested-by: Jenkins Reviewed-by: Keith Garner <kgarner@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> QA-Review: James Butters <jbutters@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
This commit is contained in:
parent
5dcc11bce5
commit
16348c3502
|
@ -137,7 +137,7 @@ class GradebooksController < ApplicationController
|
|||
student_enrollment.find_score(course_score: true)
|
||||
end
|
||||
|
||||
js_hash[:effective_final_grade] = total_score.effective_final_grade if total_score.overridden?
|
||||
js_hash[:effective_final_score] = total_score.effective_final_score if total_score.overridden?
|
||||
end
|
||||
|
||||
js_env(js_hash)
|
||||
|
|
|
@ -361,11 +361,26 @@ function calculateTotals (calculatedGrades, currentOrFinal, groupWeightingScheme
|
|||
const scoreAsPercent = calculateGrade(finalScore, finalPossible)
|
||||
|
||||
let finalGrade
|
||||
let letterGrade
|
||||
let teaserText
|
||||
|
||||
if (!gradeChanged && ENV.grading_scheme && ENV.effective_final_grade) {
|
||||
finalGrade = formatPercentGrade(gradeToScoreLowerBound(ENV.effective_final_grade, ENV.grading_scheme))
|
||||
if (gradingSchemeEnabled()) {
|
||||
const scoreToUse = overrideScorePresent() ?
|
||||
ENV.effective_final_score :
|
||||
calculatePercentGrade(finalScore, finalPossible)
|
||||
|
||||
letterGrade = scoreToGrade(scoreToUse, ENV.grading_scheme)
|
||||
$('.final_grade .letter_grade').text(letterGrade)
|
||||
}
|
||||
|
||||
if (!gradeChanged && overrideScorePresent()) {
|
||||
teaserText = scoreAsPoints
|
||||
|
||||
if (gradingSchemeEnabled()) {
|
||||
finalGrade = formatPercentGrade(gradeToScoreLowerBound(letterGrade, ENV.grading_scheme))
|
||||
} else {
|
||||
finalGrade = formatPercentGrade(ENV.effective_final_score)
|
||||
}
|
||||
} else if (showTotalGradeAsPoints && groupWeightingScheme !== 'percent') {
|
||||
finalGrade = scoreAsPoints
|
||||
teaserText = scoreAsPercent
|
||||
|
@ -391,15 +406,21 @@ function calculateTotals (calculatedGrades, currentOrFinal, groupWeightingScheme
|
|||
$.screenReaderFlashMessageExclusive(msg)
|
||||
}
|
||||
|
||||
if (ENV.grading_scheme) {
|
||||
$('.final_letter_grade .grade').text(
|
||||
ENV.effective_final_grade || scoreToGrade(calculatePercentGrade(finalScore, finalPossible), ENV.grading_scheme)
|
||||
)
|
||||
}
|
||||
|
||||
$('.revert_all_scores').showIf($('#grades_summary .revert_score_link').length > 0)
|
||||
}
|
||||
|
||||
// This element is only rendered by the erb if the course has enabled grading
|
||||
// schemes. We can't rely on only checking for the presence of
|
||||
// ENV.grading_scheme as that, in this case, always returns Canvas's default
|
||||
// grading scheme even if grading schemes are not enabled.
|
||||
function gradingSchemeEnabled() {
|
||||
return $('.final_grade .letter_grade').length > 0 && ENV.grading_scheme
|
||||
}
|
||||
|
||||
function overrideScorePresent() {
|
||||
return ENV.effective_final_score != null
|
||||
}
|
||||
|
||||
function updateStudentGrades () {
|
||||
const droppedMessage = I18n.t('This assignment is dropped and will not be considered in the total calculation')
|
||||
const ignoreUngradedSubmissions = $('#only_consider_graded_assignments').attr('checked')
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
<div class="student_assignment final_grade">
|
||||
<%= before_label(:total, "Total") %> <span class="grade"></span>
|
||||
<% if @context.grading_standard_enabled? %>
|
||||
<span class="final_letter_grade">
|
||||
(<span class="grade" id="final_letter_grade_text">-</span>)
|
||||
</span>
|
||||
(<span class="letter_grade" id="final_letter_grade_text">–</span>)
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -232,27 +232,27 @@ describe GradebooksController do
|
|||
@student_enrollment.scores.find_by(course_score: true).update!(override_score: 99)
|
||||
end
|
||||
|
||||
it "includes the effective final grade in the ENV" do
|
||||
it "includes the effective final score in the ENV" do
|
||||
user_session(@teacher)
|
||||
get :grade_summary, params: { course_id: @course.id, id: @student.id }
|
||||
expect(assigns[:js_env][:effective_final_grade]).to eq "A"
|
||||
expect(assigns[:js_env][:effective_final_score]).to eq 99
|
||||
end
|
||||
|
||||
it "does not include the effective final grade in the ENV if the feature is disabled" do
|
||||
it "does not include the effective final score in the ENV if the feature is disabled" do
|
||||
@course.disable_feature!(:final_grades_override)
|
||||
user_session(@teacher)
|
||||
get :grade_summary, params: { course_id: @course.id, id: @student.id }
|
||||
expect(assigns[:js_env].key?(:effective_final_grade)).to be false
|
||||
expect(assigns[:js_env].key?(:effective_final_score)).to be false
|
||||
end
|
||||
|
||||
it "does not include the effective final grade in the ENV if there is no override score" do
|
||||
it "does not include the effective final score in the ENV if there is no override score" do
|
||||
@student_enrollment.scores.find_by(course_score: true).update!(override_score: nil)
|
||||
user_session(@teacher)
|
||||
get :grade_summary, params: { course_id: @course.id, id: @student.id }
|
||||
expect(assigns[:js_env].key?(:effective_final_grade)).to be false
|
||||
expect(assigns[:js_env].key?(:effective_final_score)).to be false
|
||||
end
|
||||
|
||||
it "takes the effective final grade for the grading period, if present" do
|
||||
it "takes the effective final score for the grading period, if present" do
|
||||
grading_period_group = @course.grading_period_groups.create!
|
||||
grading_period = grading_period_group.grading_periods.create!(
|
||||
title: "a grading period",
|
||||
|
@ -262,13 +262,13 @@ describe GradebooksController do
|
|||
@student_enrollment.scores.find_by(grading_period: grading_period).update!(override_score: 84)
|
||||
user_session(@teacher)
|
||||
get :grade_summary, params: { course_id: @course.id, id: @student.id }
|
||||
expect(assigns[:js_env][:effective_final_grade]).to eq "B"
|
||||
expect(assigns[:js_env][:effective_final_score]).to eq 84
|
||||
end
|
||||
|
||||
it "takes the effective final grade for the course score, if viewing all grading periods" do
|
||||
it "takes the effective final score for the course score, if viewing all grading periods" do
|
||||
user_session(@teacher)
|
||||
get :grade_summary, params: { course_id: @course.id, id: @student.id, grading_period_id: 0 }
|
||||
expect(assigns[:js_env][:effective_final_grade]).to eq "A"
|
||||
expect(assigns[:js_env][:effective_final_score]).to eq 99
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -92,11 +92,9 @@ function setPageHtmlFixture() {
|
|||
<div id="student-grades-right-content">
|
||||
<div class="student_assignment final_grade">
|
||||
<span class="grade"></span>
|
||||
<span class="final_letter_grade">
|
||||
(
|
||||
<span id="final_letter_grade_text" class="grade"></span>
|
||||
<span id="final_letter_grade_text" class="letter_grade">–</span>
|
||||
)
|
||||
</span>
|
||||
<span class="score_teaser"></span>
|
||||
</div>
|
||||
<div id="student-grades-whatif" class="show_guess_grades" style="display: none;">
|
||||
|
@ -349,38 +347,81 @@ QUnit.module('GradeSummary.calculateTotals', (suiteHooks) => {
|
|||
QUnit.module('final grade override', (contextHooks) => {
|
||||
contextHooks.beforeEach(() => {
|
||||
exampleGrades = createExampleGrades()
|
||||
exampleGrades.current = {score: 23, possible: 100}
|
||||
ENV.grading_scheme = [['A', 0.90], ['B', 0.80], ['C', 0.70], ['D', 0.60], ['F', 0]]
|
||||
})
|
||||
|
||||
test('sets the final letter grade to the effective final grade, if present', () => {
|
||||
ENV.effective_final_grade = 'D-'
|
||||
test('sets the percent grade to the corresponding lower bound of the effective grade', () => {
|
||||
ENV.effective_final_score = 72
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_letter_grade .grade')
|
||||
strictEqual($grade.text(), 'D-')
|
||||
})
|
||||
|
||||
test('sets the final letter grade to the calculated final grade, if not present', () => {
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_letter_grade .grade')
|
||||
strictEqual($grade.text(), 'F')
|
||||
})
|
||||
|
||||
test('sets the percent grade to the corresponding value of the effective grade, if present', () => {
|
||||
ENV.effective_final_grade = 'C'
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.student_assignment.final_grade .grade').first()
|
||||
const $grade = $fixtures.find('.final_grade .grade').first()
|
||||
strictEqual($grade.text(), '70%')
|
||||
})
|
||||
|
||||
test('sets the letter grade to the effective grade', () => {
|
||||
ENV.effective_final_score = 72
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_grade .letter_grade')
|
||||
strictEqual($grade.text(), 'C')
|
||||
})
|
||||
|
||||
test('sets the percent grade to the calculated percent grade, if overrides not present', () => {
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_grade .grade').first()
|
||||
strictEqual($grade.text(), '23%')
|
||||
})
|
||||
|
||||
test('sets the letter grade to the calculated letter grade, if overrides not present', () => {
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_grade .letter_grade')
|
||||
strictEqual($grade.text(), 'F')
|
||||
})
|
||||
|
||||
test('changed What-If scores take precedence over the effective grade', () => {
|
||||
ENV.effective_final_grade = 'C'
|
||||
exampleGrades.current = {score: 3, possible: 10 }
|
||||
ENV.effective_final_score = 72
|
||||
exampleGrades.current = {score: 3, possible: 10}
|
||||
const changedGrade = '<span class="grade changed">3</span>'
|
||||
$fixtures.find('.score_holder .tooltip').html(changedGrade)
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.student_assignment.final_grade .grade').first()
|
||||
const $grade = $fixtures.find('.final_grade .grade').first()
|
||||
strictEqual($grade.text(), '30%')
|
||||
})
|
||||
|
||||
test('override score of 0 results in a 0%', () => {
|
||||
ENV.effective_final_score = 0
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_grade .grade').first()
|
||||
strictEqual($grade.text(), '0%')
|
||||
})
|
||||
|
||||
test('override score of 0 results in an F letter grade', () => {
|
||||
ENV.effective_final_score = 0
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_grade .letter_grade').first()
|
||||
strictEqual($grade.text(), 'F')
|
||||
})
|
||||
|
||||
// At present, ENV.grading_scheme is always present, but that may change
|
||||
// some day if there's no longer a need to always send it back (in other
|
||||
// parts of Canvas, it's only present when a grading scheme is enabled),
|
||||
// so this is a defensive test.
|
||||
test('when a grading scheme is not present, but an override is, the raw override score is shown', () => {
|
||||
delete ENV.grading_scheme
|
||||
ENV.effective_final_score = 72
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_grade .grade').first()
|
||||
strictEqual($grade.text(), '72%')
|
||||
})
|
||||
|
||||
// This test is necessary because GradeSummary determines if a grading
|
||||
// scheme is present via the presence of this span.
|
||||
test('when the .letter_grade span is not present, the raw override score is shown', () => {
|
||||
$('.final_grade .letter_grade').remove()
|
||||
ENV.effective_final_score = 72
|
||||
GradeSummary.calculateTotals(exampleGrades, 'current', 'percent')
|
||||
const $grade = $fixtures.find('.final_grade .grade').first()
|
||||
strictEqual($grade.text(), '72%')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@ describe 'Final Grade Override' do
|
|||
end
|
||||
|
||||
it 'displays overridden grade for student grades', priority: '1', test_id: 3682131 do
|
||||
skip('GRADE-1931')
|
||||
user_session(@students.first)
|
||||
StudentGradesPage.visit_as_student(@course)
|
||||
expect(StudentGradesPage.final_grade.text).to eql "90%"
|
||||
|
|
Loading…
Reference in New Issue