update page titles in ember quizzes
update the document.title to be consistent with the page that the user is viewing. update existing moderate page title to be consistent closes CNVS-12974 test plan: - enable :quiz_stats feature - enable :quiz_moderate feature - visit quiz index - title should display 'Quizzes' - select a quiz - title should display '<quiz title>: Overview' - select the moderate tab - title should display '<quiz title>: Moderate' - select the statistics tab - title should display '<quiz title>: Statistics' Change-Id: I36d94014e2225d78d59d35c77b16bb82af48d644 Reviewed-on: https://gerrit.instructure.com/36016 Reviewed-by: Derek DeVries <ddevries@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Product-Review: Jason Madsen <jmadsen@instructure.com>
This commit is contained in:
parent
38917d0c32
commit
e8168f02c5
|
@ -2,7 +2,9 @@ define [
|
|||
'ember'
|
||||
'../mixins/redirect'
|
||||
'../shared/environment'
|
||||
], (Em, Redirect, env) ->
|
||||
'i18n!quiz_moderate_route',
|
||||
'../shared/title_builder'
|
||||
], (Em, Redirect, env, I18n, titleBuilder) ->
|
||||
|
||||
ModerateRoute = Em.Route.extend Redirect,
|
||||
|
||||
|
@ -12,6 +14,11 @@ define [
|
|||
model: ->
|
||||
@combinedUsersSubmissionsPromise()
|
||||
|
||||
afterModel: ->
|
||||
title = @modelFor('quiz').get('title')
|
||||
desc = I18n.t('moderate', "Moderate")
|
||||
titleBuilder([title, desc])
|
||||
|
||||
combinedUsersSubmissionsPromise: ->
|
||||
quiz = @modelFor('quiz')
|
||||
_this = this
|
||||
|
|
|
@ -3,7 +3,8 @@ define [
|
|||
'../mixins/redirect'
|
||||
'../shared/environment'
|
||||
'i18n!quiz_route'
|
||||
], (Ember, Redirect, env, I18n) ->
|
||||
'../shared/title_builder'
|
||||
], (Ember, Redirect, env, I18n, titleBuilder) ->
|
||||
|
||||
QuizRoute = Ember.Route.extend Redirect,
|
||||
|
||||
|
@ -11,6 +12,7 @@ define [
|
|||
afterModel: (quiz, transition) ->
|
||||
# set the quiz in the env so that we can use it for nested routes
|
||||
env.set("quizId", quiz.id)
|
||||
titleBuilder([quiz.get('title')])
|
||||
|
||||
if quiz.get("deleted")
|
||||
quiz.unloadRecord()
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
define [
|
||||
'ember'
|
||||
], (Em) ->
|
||||
'ember',
|
||||
'i18n!quiz_overview_route',
|
||||
'../shared/title_builder'
|
||||
], (Em, I18n, titleBuilder) ->
|
||||
|
||||
Em.Route.extend
|
||||
model: ->
|
||||
@modelFor 'quiz'
|
||||
|
||||
afterModel: (quiz, transition) ->
|
||||
title = quiz.get('title')
|
||||
desc = I18n.t('overview', 'Overview')
|
||||
titleBuilder([title, desc])
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
define [ 'ember', '../mixins/redirect' ], (Ember, Redirect) ->
|
||||
define [
|
||||
'ember',
|
||||
'../mixins/redirect',
|
||||
'i18n!quiz_statistics_route'
|
||||
'../shared/title_builder'
|
||||
], (Ember, Redirect, I18n, titleBuilder) ->
|
||||
|
||||
Ember.Route.extend Redirect,
|
||||
beforeModel: (transition) ->
|
||||
@validateRoute('canManage', 'quiz.show')
|
||||
|
@ -13,6 +19,11 @@ define [ 'ember', '../mixins/redirect' ], (Ember, Redirect) ->
|
|||
quiz.get('quizReports').then ->
|
||||
latestStatistics
|
||||
|
||||
afterModel: () ->
|
||||
title = @modelFor('quiz').get('title')
|
||||
desc = I18n.t('quiz_statistics', "Statistics")
|
||||
titleBuilder([title, desc])
|
||||
|
||||
actions:
|
||||
showDiscriminationIndexHelp: ->
|
||||
@render 'quiz/statistics/questions/multiple_choice/discrimination_index_help',
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
define [
|
||||
'ember'
|
||||
'../shared/environment'
|
||||
], (Ember, env) ->
|
||||
'../shared/environment',
|
||||
'i18n!quizzes_route',
|
||||
'../shared/title_builder'
|
||||
], (Ember, env, I18n, titleBuilder) ->
|
||||
|
||||
QuizzesRoute = Ember.Route.extend
|
||||
|
||||
|
@ -17,3 +19,7 @@ define [
|
|||
perms.create = @store.metadataFor('quiz').permissions.quizzes.create
|
||||
env.set 'env.PERMISSIONS', perms
|
||||
quizzes
|
||||
|
||||
afterModel: ->
|
||||
title = I18n.t('quizzes_route_title', 'Quizzes')
|
||||
titleBuilder([title])
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
define [
|
||||
'ember'
|
||||
], (Ember) ->
|
||||
|
||||
updateTitle = (title) ->
|
||||
Ember.$(document).attr('title', title)
|
||||
|
||||
(tokens, separator = ': ') ->
|
||||
if tokens instanceof Array
|
||||
tokens = tokens || []
|
||||
title = tokens.join(separator)
|
||||
else
|
||||
title = tokens || ''
|
||||
updateTitle(title)
|
||||
title
|
|
@ -4,8 +4,9 @@ define [
|
|||
'../shared_ajax_fixtures'
|
||||
'../environment_setup'
|
||||
'../test_redirection'
|
||||
'../test_title'
|
||||
]
|
||||
, (Ember, startApp, fixtures, env, testRedirection) ->
|
||||
, (Ember, startApp, fixtures, env, testRedirection, testTitle) ->
|
||||
|
||||
module "Quiz Moderate: Integration",
|
||||
|
||||
|
@ -16,10 +17,15 @@ define [
|
|||
teardown: ->
|
||||
Ember.run App, 'destroy'
|
||||
|
||||
# something about quizSubmissions and users association isn't resolving
|
||||
# and cause instability in this
|
||||
# something about quizSubmissions and users association is causing promises
|
||||
# to not resolve and cause issues with getting `then` to resolve correctly
|
||||
# TODO: determine why
|
||||
|
||||
# testRedirection
|
||||
# path: '/1/moderate'
|
||||
# defaultRoute: 'quiz.moderate'
|
||||
# redirectRoute: 'quiz.show'
|
||||
|
||||
# testTitle
|
||||
# path: '/',
|
||||
# title: 'Alt practices test: Moderate'
|
||||
|
|
|
@ -5,8 +5,9 @@ define [
|
|||
'../environment_setup'
|
||||
'ic-ajax'
|
||||
'jquery'
|
||||
'../test_title'
|
||||
'jqueryui/dialog'
|
||||
], (Ember, startApp, fixtures, env, ajax, $) ->
|
||||
], (Ember, startApp, fixtures, env, ajax, $, testTitle) ->
|
||||
App = null
|
||||
|
||||
QUIZ = fixtures.QUIZZES[0]
|
||||
|
@ -26,6 +27,10 @@ define [
|
|||
test desc, ->
|
||||
visit('/1').then callback
|
||||
|
||||
testTitle
|
||||
path: '/1',
|
||||
title: 'Alt practice test: Overview'
|
||||
|
||||
testShowPage 'shows attributes', ->
|
||||
html = find('#quiz-show').html()
|
||||
|
||||
|
@ -147,4 +152,3 @@ define [
|
|||
|
||||
testShowPage 'doesnt show tabs', ->
|
||||
ok !find('#quiz-show-tabs').length, "should not have tabs"
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ define [
|
|||
'../environment_setup'
|
||||
'../shared_ajax_fixtures'
|
||||
'../test_redirection'
|
||||
], (Ember, startApp, env, fixtures, testRedirection) ->
|
||||
'../test_title'
|
||||
], (Ember, startApp, env, fixtures, testRedirection, testTitle) ->
|
||||
App = null
|
||||
|
||||
{$} = Ember
|
||||
|
|
|
@ -4,9 +4,10 @@ define [
|
|||
'ic-ajax',
|
||||
'../shared_ajax_fixtures',
|
||||
'../../shared/environment'
|
||||
'../test_title',
|
||||
'../environment_setup',
|
||||
'../../../../behaviors/elementToggler'
|
||||
], (startApp, Ember, ajax, fixtures, env) ->
|
||||
], (startApp, Ember, ajax, fixtures, env, testTitle) ->
|
||||
|
||||
App = null
|
||||
|
||||
|
@ -18,6 +19,10 @@ define [
|
|||
teardown: ->
|
||||
Ember.run App, 'destroy'
|
||||
|
||||
testTitle
|
||||
path: '/',
|
||||
title: 'Quizzes'
|
||||
|
||||
test 'Quizzes pages load appropriately', ->
|
||||
visit('/').then ->
|
||||
equal(find('.quiz').length, 2, 'Loads data into controller appropriately')
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
define [
|
||||
'../../shared/title_builder'
|
||||
], (titleBuilder) ->
|
||||
|
||||
module 'title_builder - Unit - '
|
||||
|
||||
test 'uses default separator', ->
|
||||
result = titleBuilder(['foo', 'bar'])
|
||||
equal result, 'foo: bar'
|
||||
|
||||
test 'uses separator from arguments', ->
|
||||
result = titleBuilder(['foo', 'bar'], ' - ')
|
||||
equal result, 'foo - bar'
|
||||
|
||||
test 'concats tokens in order given', ->
|
||||
result = titleBuilder(['foo', 'bar', 'baz'], ' ')
|
||||
equal result, 'foo bar baz'
|
||||
|
||||
test 'handles empty tokens', ->
|
||||
result = titleBuilder([], '!')
|
||||
equal result, ''
|
||||
|
||||
test 'handles no arguments', ->
|
||||
result = titleBuilder()
|
||||
equal result, ''
|
||||
|
||||
test 'handles first argument as a string', ->
|
||||
result = titleBuilder('baz')
|
||||
equal result, 'baz'
|
|
@ -0,0 +1,8 @@
|
|||
define ['ember'], (Ember) ->
|
||||
|
||||
# {path: '/1/moderate, title: 'Expected Title'}
|
||||
(options) ->
|
||||
test "updates document.title for #{options.path} correctly", ->
|
||||
visit(options.path)
|
||||
andThen ->
|
||||
equal document.title, options.title
|
|
@ -2,7 +2,7 @@
|
|||
add_crumb @quiz.title, context_url(@context, :context_quiz_url, @quiz)
|
||||
add_crumb t(:page_title, 'Moderate Quiz')
|
||||
%>
|
||||
<% content_for :page_title do %><%= t(:page_title, "Moderate Quiz") %><% end %>
|
||||
<% content_for :page_title do %><%= t(:moderate_page_title, "%{title}: Moderate", :title => @quiz.title) %><% end %>
|
||||
|
||||
<h2><%= t(:page_title, "Moderate Quiz") %></h2>
|
||||
<table id="students" class="<%= 'can_add_attempts' if @quiz.allowed_attempts < 0 %>">
|
||||
|
|
Loading…
Reference in New Issue