show course settings link only when relevant
fixes TALLY-41 flag = none test plan: 1. Enable "Filter SpeedGrader by Student Group" in the account settings 2. Create a course with enough students to make SpeedGrader time out 3. Create an assignment 4. Load that assignment in SpeedGrader * ensure that SpeedGrader times out 5. Verify the error message includes a link to the course settings and mentions the "Large Course" setting 6. Disable "Filter SpeedGrader by Student Group" in the account settings 7. Load that assignment in SpeedGrader * ensure that SpeedGrader times out 8. Verify the error message does not include a link to the course settings Change-Id: I2bd6909429730193ce1c59797309a811f451abb3 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/226132 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Spencer Olson <solson@instructure.com> Reviewed-by: Adrian Packel <apackel@instructure.com> QA-Review: Jeremy Neander <jneander@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
This commit is contained in:
parent
0552d3c8e4
commit
f07dae8f8a
|
@ -746,6 +746,9 @@ class GradebooksController < ApplicationController
|
|||
:user_id => "{{user_id}}"
|
||||
end
|
||||
|
||||
env[:filter_speed_grader_by_student_group_feature_enabled] =
|
||||
@context.root_account.feature_enabled?(:filter_speed_grader_by_student_group)
|
||||
|
||||
if @context.filter_speed_grader_by_student_group?
|
||||
env[:filter_speed_grader_by_student_group] = true
|
||||
|
||||
|
|
|
@ -3673,11 +3673,19 @@ function setupSpeedGrader(gradingPeriods, speedGraderJsonResponse) {
|
|||
}
|
||||
|
||||
function buildAlertMessage() {
|
||||
const alertMessage = I18n.t(
|
||||
'Something went wrong. Please try refreshing the page. If the problem persists, you can try loading a single student group in SpeedGrader by using the *Large Course setting*.',
|
||||
{wrappers: [`<a href="/courses/${ENV.course_id}/settings#course_large_course">$1</a>`]}
|
||||
)
|
||||
return {__html: alertMessage.string}
|
||||
let alertMessage
|
||||
if (
|
||||
ENV.filter_speed_grader_by_student_group_feature_enabled &&
|
||||
!ENV.filter_speed_grader_by_student_group
|
||||
) {
|
||||
alertMessage = I18n.t(
|
||||
'Something went wrong. Please try refreshing the page. If the problem persists, you can try loading a single student group in SpeedGrader by using the *Large Course setting*.',
|
||||
{wrappers: [`<a href="/courses/${ENV.course_id}/settings#course_large_course">$1</a>`]}
|
||||
).string
|
||||
} else {
|
||||
alertMessage = I18n.t('Something went wrong. Please try refreshing the page.')
|
||||
}
|
||||
return {__html: alertMessage}
|
||||
}
|
||||
|
||||
function speedGraderJSONErrorFn(_data, xhr, _textStatus, _errorThrown) {
|
||||
|
|
|
@ -2119,6 +2119,18 @@ describe GradebooksController do
|
|||
expect(js_env[:final_grader_id]).to eql @teacher.id
|
||||
end
|
||||
|
||||
it "sets filter_speed_grader_by_student_group_feature_enabled to true when enabled" do
|
||||
@course.root_account.enable_feature!(:filter_speed_grader_by_student_group)
|
||||
get :speed_grader, params: { course_id: @course, assignment_id: @assignment }
|
||||
expect(js_env.fetch(:filter_speed_grader_by_student_group_feature_enabled)).to be true
|
||||
end
|
||||
|
||||
it "sets filter_speed_grader_by_student_group_feature_enabled to false when disabled" do
|
||||
@course.root_account.disable_feature!(:filter_speed_grader_by_student_group)
|
||||
get :speed_grader, params: { course_id: @course, assignment_id: @assignment }
|
||||
expect(js_env.fetch(:filter_speed_grader_by_student_group_feature_enabled)).to be false
|
||||
end
|
||||
|
||||
describe "student group filtering" do
|
||||
before(:each) do
|
||||
@course.root_account.enable_feature!(:filter_speed_grader_by_student_group)
|
||||
|
|
|
@ -2079,8 +2079,10 @@ QUnit.module('SpeedGrader', rootHooks => {
|
|||
})
|
||||
})
|
||||
|
||||
QUnit.module('SpeedGrader - gateway timeout', {
|
||||
setup() {
|
||||
QUnit.module('when the gateway times out', contextHooks => {
|
||||
let server
|
||||
|
||||
contextHooks.beforeEach(() => {
|
||||
fakeENV.setup({
|
||||
assignment_id: '17',
|
||||
course_id: '29',
|
||||
|
@ -2088,42 +2090,55 @@ QUnit.module('SpeedGrader', rootHooks => {
|
|||
help_url: 'example.com/support',
|
||||
show_help_menu_item: false
|
||||
})
|
||||
this.server = sinon.fakeServer.create({respondImmediately: true})
|
||||
|
||||
server = sinon.fakeServer.create({respondImmediately: true})
|
||||
// in production, json responses that timeout receive html content type responses unfortunately
|
||||
this.server.respondWith('GET', `${window.location.pathname}.json${window.location.search}`, [
|
||||
server.respondWith('GET', `${window.location.pathname}.json${window.location.search}`, [
|
||||
504,
|
||||
{'Content-Type': 'text/html'},
|
||||
''
|
||||
])
|
||||
setupFixtures('<div id="speed_grader_timeout_alert"></div>')
|
||||
},
|
||||
teardown() {
|
||||
|
||||
sandbox.stub(SpeedGrader.EG, 'domReady')
|
||||
ENV.assignment_title = 'Assignment Title'
|
||||
})
|
||||
|
||||
contextHooks.afterEach(() => {
|
||||
SpeedGrader.teardown()
|
||||
teardownFixtures()
|
||||
this.server.restore()
|
||||
server.restore()
|
||||
fakeENV.teardown()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
test('shows an error when the gateway times out', function() {
|
||||
sandbox.stub(SpeedGrader.EG, 'domReady')
|
||||
ENV.assignment_title = 'Assignment Title'
|
||||
SpeedGrader.setup()
|
||||
const message = [
|
||||
'Something went wrong. Please try refreshing the page. If the problem persists, you can try',
|
||||
'loading a single student group in SpeedGrader by using the Large Course setting.'
|
||||
].join(' ')
|
||||
strictEqual($('#speed_grader_timeout_alert').text(), message)
|
||||
SpeedGrader.teardown()
|
||||
})
|
||||
test('shows an error', () => {
|
||||
SpeedGrader.setup()
|
||||
notEqual($('#speed_grader_timeout_alert').text(), '')
|
||||
})
|
||||
|
||||
test('links to the course settings page', () => {
|
||||
sandbox.stub(SpeedGrader.EG, 'domReady')
|
||||
ENV.assignment_title = 'Assignment Title'
|
||||
SpeedGrader.setup()
|
||||
const $link = $('#speed_grader_timeout_alert a')
|
||||
const url = new URL($link[0].href)
|
||||
strictEqual(url.pathname, '/courses/29/settings')
|
||||
SpeedGrader.teardown()
|
||||
QUnit.module('when the filter_speed_grader_by_student_group feature is enabled', () => {
|
||||
test('includes a link to the "large course" setting when the setting is not enabled', () => {
|
||||
ENV.filter_speed_grader_by_student_group_feature_enabled = true
|
||||
ENV.filter_speed_grader_by_student_group = false
|
||||
SpeedGrader.setup()
|
||||
const $link = $('#speed_grader_timeout_alert a')
|
||||
const url = new URL($link[0].href)
|
||||
strictEqual(url.pathname, '/courses/29/settings')
|
||||
})
|
||||
|
||||
test('excludes a link to the "large course" setting when the setting is already enabled', () => {
|
||||
ENV.filter_speed_grader_by_student_group_feature_enabled = true
|
||||
ENV.filter_speed_grader_by_student_group = true
|
||||
SpeedGrader.setup()
|
||||
strictEqual($('#speed_grader_timeout_alert a').length, 0)
|
||||
})
|
||||
})
|
||||
|
||||
test('excludes a link to the "large course" setting when the filter_speed_grader_by_student_group feature is disabled', () => {
|
||||
ENV.filter_speed_grader_by_student_group_feature_enabled = false
|
||||
SpeedGrader.setup()
|
||||
strictEqual($('#speed_grader_timeout_alert a').length, 0)
|
||||
})
|
||||
})
|
||||
|
||||
QUnit.module('SpeedGrader - clicking save rubric button', function(hooks) {
|
||||
|
@ -5228,7 +5243,10 @@ QUnit.module('SpeedGrader', rootHooks => {
|
|||
|
||||
test('unselects existing grades when isNewGrade is passed', () => {
|
||||
EG.handleProvisionalGradeSelected({isNewGrade: true})
|
||||
strictEqual(submission.provisional_grades.some(grade => grade.selected), false)
|
||||
strictEqual(
|
||||
submission.provisional_grades.some(grade => grade.selected),
|
||||
false
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue