fix essay speedgrader button

closes QO-391

Test plan:
Create a quiz with essay question
Take the quiz as a student
Go to quiz statistics page
Verify that "View in SpeedGrader"
  button is present in item analysis,
  and that clicking takes you to
  speedgrader
Repeat with practice quiz, graded
  survey, and ungraded survey.  Of these,
  only graded survey has access to speed
  grader, so button should be present
  for it and absent for other types

Change-Id: I43d1d688ba4c2e790a767d7191b2186b8a3ddfb0
Reviewed-on: https://gerrit.instructure.com/164636
Reviewed-by: Aaron Griffin <agriffin@instructure.com>
QA-Review: Aaron Griffin <agriffin@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
Tested-by: Jenkins
This commit is contained in:
Michael Brewer-Davis 2018-09-16 18:16:25 -05:00 committed by Michael Brewer-Davis
parent 0ef142a374
commit 5a028b3050
3 changed files with 14 additions and 3 deletions

View File

@ -258,7 +258,7 @@ class Quizzes::QuizStatisticsController < ApplicationController
scope = @quiz.quiz_submissions.not_settings_only.completed
updated = scope.order('updated_at DESC').limit(1).pluck(:updated_at).first
cache_key = [
'quiz_statistics',
'quiz_statistics_1',
@quiz.id,
@quiz.updated_at,
updated,
@ -293,6 +293,7 @@ class Quizzes::QuizStatisticsController < ApplicationController
def serialize(statistics)
Canvas::APIArraySerializer.new([ statistics ], {
controller: self,
scope: @current_user,
each_serializer: Quizzes::QuizStatisticsSerializer,
root: :quiz_statistics,
include_root: false

View File

@ -59,6 +59,9 @@ define(function(require) {
},
renderLinkButton: function() {
if (!this.props.speedGraderUrl) {
return null
}
return (
<a className="btn" href={this.props.speedGraderUrl} target="_blank" style={{marginBottom: "20px", maxWidth: "50%"}}>
{I18n.t('speedgrader', 'View in SpeedGrader')}
@ -68,4 +71,4 @@ define(function(require) {
});
return Essay;
});
});

View File

@ -36,5 +36,12 @@ define(function(require) {
expect('a[href*=speed_grader]').toExist();
expect(find('a[href*=speed_grader]').innerText).toContain('View in SpeedGrader');
});
it('should not render if no link to speedgrader present', () => {
setProps({
speedGraderUrl: null
})
expect('a').not.toExist()
})
});
});
});