Skip to content

Commit

Permalink
Add Build Shortcut to index pages
Browse files Browse the repository at this point in the history
This adds the build shortcut to the kabob menu
for new quiz items on the Assignments and Quizzes
index pages. (Previously this was added to the modules
page).

closes QUIZ-8842
flag = new_quizzes_skip_to_build_module_button

Test Plan:
1. Enable the ff (siteadmin) on your local sandbox.
2. Nav to the assigments list as a teacher.
3. Open up the kabob menu. Observe a Build button.
4. Click the build button.
5. Page should navigate to the quiz build page in NQ.
6. Repeat 3, 4, 5 with the quizzes page.

Change-Id: Ib05476c26c153fee906b151d22416104ee1a1ab3
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274688
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: Jared Crystal <[email protected]>
QA-Review: Mark McDermott <[email protected]>
Product-Review: Susan Sorensen <[email protected]>
  • Loading branch information
james-logan committed Nov 10, 2021
1 parent 9a30022 commit d26cf58
Show file tree
Hide file tree
Showing 14 changed files with 227 additions and 42 deletions.
3 changes: 2 additions & 1 deletion app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def index
DUE_DATE_REQUIRED_FOR_ACCOUNT: due_date_required_for_account,
FLAGS: {
newquizzes_on_quiz_page: @context.root_account.feature_enabled?(:newquizzes_on_quiz_page),
new_quizzes_modules_support: Account.site_admin.feature_enabled?(:new_quizzes_modules_support)
new_quizzes_modules_support: Account.site_admin.feature_enabled?(:new_quizzes_modules_support),
new_quizzes_skip_to_build_module_button: Account.site_admin.feature_enabled?(:new_quizzes_skip_to_build_module_button)
}
}

Expand Down
1 change: 1 addition & 0 deletions app/controllers/quizzes/quizzes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def index
post_to_sis_enabled: Assignment.sis_grade_export_enabled?(@context),
quiz_lti_enabled: quiz_lti_enabled?,
new_quizzes_modules_support: Account.site_admin.feature_enabled?(:new_quizzes_modules_support),
new_quizzes_skip_to_build_module_button: Account.site_admin.feature_enabled?(:new_quizzes_skip_to_build_module_button),
migrate_quiz_enabled:
@context.feature_enabled?(:quizzes_next) &&
@context.quiz_lti_tool.present?,
Expand Down
4 changes: 2 additions & 2 deletions config/feature_flags/quizzes_release_flags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ new_quizzes_account_course_level_item_banks:
applies_to: SiteAdmin
state: hidden
new_quizzes_skip_to_build_module_button:
display_name: New Quizzes Build Button In Module Items
description: Provides a button which navigates straight to the Build screen in the kebab menu for New Quizzes items on the Modules page.
display_name: New Quizzes Build Button On List Views
description: Provides a button which navigates straight to the Build screen in the kebab menu for New Quizzes items on the Modules page, Assignments page, and Quizzes page.
applies_to: SiteAdmin
state: hidden
8 changes: 7 additions & 1 deletion spec/coffeescripts/models/AssignmentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ test('escapes the name retrieved from the js env', () => {
)
})

QUnit.module('Assignment#defaultToolName', {
QUnit.module('Assignment#defaultToolName is undefined', {
setup() {
fakeENV.setup({
DEFAULT_ASSIGNMENT_TOOL_NAME: undefined
Expand Down Expand Up @@ -1109,6 +1109,12 @@ test('includes htmlEditUrl', () => {
equal(json.htmlEditUrl, 'http://example.com/assignments/1/edit')
})

test('includes htmlBuildUrl', () => {
const assignment = new Assignment({html_url: 'http://example.com/assignments/1'})
const json = assignment.toView()
equal(json.htmlBuildUrl, 'http://example.com/assignments/1')
})

test('includes multipleDueDates', () => {
const assignment = new Assignment({
all_dates: [{title: 'Summer'}, {title: 'Winter'}]
Expand Down
86 changes: 50 additions & 36 deletions spec/coffeescripts/models/QuizSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ QUnit.module('Quiz', {
teardown() {}
})

test('#initialize ignores assignment if not given', function() {
test('#initialize ignores assignment if not given', function () {
ok(!this.quiz.get('assignment'))
})

test('#initialize sets assignment', function() {
test('#initialize sets assignment', function () {
const assign = {
id: 1,
title: 'Foo Bar'
Expand All @@ -48,66 +48,66 @@ test('#initialize sets assignment', function() {
equal(this.quiz.get('assignment').constructor, Assignment)
})

test('#initialize ignores assignment_overrides if not given', function() {
test('#initialize ignores assignment_overrides if not given', function () {
ok(!this.quiz.get('assignment_overrides'))
})

test('#initialize assigns assignment_override collection', function() {
test('#initialize assigns assignment_override collection', function () {
this.quiz = new Quiz({assignment_overrides: []})
equal(this.quiz.get('assignment_overrides').constructor, AssignmentOverrideCollection)
})

test('#initialize should set url from html url', function() {
test('#initialize should set url from html url', function () {
equal(this.quiz.get('url'), 'http://localhost:3000/courses/1/quizzes/1')
})

test('#initialize should set edit_url from html url', function() {
test('#initialize should set edit_url from html url', function () {
equal(this.quiz.get('edit_url'), 'http://localhost:3000/courses/1/quizzes/1/edit')
})

test('#initialize should set publish_url from html url', function() {
test('#initialize should set publish_url from html url', function () {
equal(this.quiz.get('publish_url'), 'http://localhost:3000/courses/1/quizzes/publish')
})

test('#initialize should set unpublish_url from html url', function() {
test('#initialize should set unpublish_url from html url', function () {
equal(this.quiz.get('unpublish_url'), 'http://localhost:3000/courses/1/quizzes/unpublish')
})

test('#initialize should set deletion_url from html url', function() {
test('#initialize should set deletion_url from html url', function () {
equal(this.quiz.get('deletion_url'), 'http://localhost:3000/courses/1/quizzes/1')
})

test('#initialize should set title_label from title', function() {
test('#initialize should set title_label from title', function () {
this.quiz = new Quiz({
title: 'My Quiz!',
readable_type: 'Quiz'
})
equal(this.quiz.get('title_label'), 'My Quiz!')
})

test('#initialize should set title_label from readable_type', function() {
test('#initialize should set title_label from readable_type', function () {
this.quiz = new Quiz({readable_type: 'Quiz'})
equal(this.quiz.get('title_label'), 'Quiz')
})

test('#initialize defaults unpublishable to true', function() {
test('#initialize defaults unpublishable to true', function () {
ok(this.quiz.get('unpublishable'))
})

test('#initialize sets unpublishable to false', function() {
test('#initialize sets unpublishable to false', function () {
this.quiz = new Quiz({unpublishable: false})
ok(!this.quiz.get('unpublishable'))
})

test('#initialize sets publishable from can_unpublish and published', function() {
test('#initialize sets publishable from can_unpublish and published', function () {
this.quiz = new Quiz({
can_unpublish: false,
published: true
})
ok(!this.quiz.get('unpublishable'))
})

test('#initialize sets question count', function() {
test('#initialize sets question count', function () {
this.quiz = new Quiz({
question_count: 1,
published: true
Expand All @@ -120,55 +120,55 @@ test('#initialize sets question count', function() {
equal(this.quiz.get('question_count_label'), '2 Questions')
})

test('#initialize sets possible points count with no points', function() {
test('#initialize sets possible points count with no points', function () {
this.quiz = new Quiz()
equal(this.quiz.get('possible_points_label'), '')
})

test('#initialize sets possible points count with 0 points', function() {
test('#initialize sets possible points count with 0 points', function () {
this.quiz = new Quiz({points_possible: 0})
equal(this.quiz.get('possible_points_label'), '')
})

test('#initialize sets possible points count with 1 points', function() {
test('#initialize sets possible points count with 1 points', function () {
this.quiz = new Quiz({points_possible: 1})
equal(this.quiz.get('possible_points_label'), '1 pt')
})

test('#initialize sets possible points count with 2 points', function() {
test('#initialize sets possible points count with 2 points', function () {
this.quiz = new Quiz({points_possible: 2})
equal(this.quiz.get('possible_points_label'), '2 pts')
})

test('#initialize sets possible points count with 1.23 points', function() {
test('#initialize sets possible points count with 1.23 points', function () {
this.quiz = new Quiz({points_possible: 1.23})
equal(this.quiz.get('possible_points_label'), '1.23 pts')
})

test('#initialize points possible to null if ungraded survey', function() {
test('#initialize points possible to null if ungraded survey', function () {
this.quiz = new Quiz({
points_possible: 5,
quiz_type: 'survey'
})
equal(this.quiz.get('possible_points_label'), '')
})

test('#publish saves to the server', function() {
test('#publish saves to the server', function () {
this.quiz.publish()
ok(this.ajaxStub.called)
})

test('#publish sets published attribute to true', function() {
test('#publish sets published attribute to true', function () {
this.quiz.publish()
ok(this.quiz.get('published'))
})

test('#unpublish saves to the server', function() {
test('#unpublish saves to the server', function () {
this.quiz.unpublish()
ok(this.ajaxStub.called)
})

test('#unpublish sets published attribute to false', function() {
test('#unpublish sets published attribute to false', function () {
this.quiz.unpublish()
ok(!this.quiz.get('published'))
})
Expand Down Expand Up @@ -200,30 +200,34 @@ QUnit.module('Quiz.Next', {
teardown() {}
})

test('#initialize model record id', function() {
test('#initialize model record id', function () {
equal(this.quiz.id, 'assignment_7')
})

test('#initialize should set url from html url', function() {
test('#initialize should set url from html url', function () {
equal(this.quiz.get('url'), 'http://localhost:3000/courses/1/assignments/7')
})

test('#initialize should set edit_url from html url', function() {
test('#initialize should set build_url from html url', function () {
equal(this.quiz.get('build_url'), 'http://localhost:3000/courses/1/assignments/7')
})

test('#initialize should set edit_url from html url', function () {
equal(this.quiz.get('edit_url'), 'http://localhost:3000/courses/1/assignments/7/edit?quiz_lti')
})

test('#initialize should set publish_url from html url', function() {
test('#initialize should set publish_url from html url', function () {
equal(this.quiz.get('publish_url'), 'http://localhost:3000/courses/1/assignments/publish/quiz')
})

test('#initialize should set unpublish_url from html url', function() {
test('#initialize should set unpublish_url from html url', function () {
equal(
this.quiz.get('unpublish_url'),
'http://localhost:3000/courses/1/assignments/unpublish/quiz'
)
})

test('#initialize should set deletion_url from html url', function() {
test('#initialize should set deletion_url from html url', function () {
equal(this.quiz.get('deletion_url'), 'http://localhost:3000/courses/1/assignments/7')
})

Expand All @@ -246,7 +250,7 @@ QUnit.module('Quiz.Next with manage and new_quizzes_modules_support enabled', {
}
})

test('#initialize should set url as edit_url', function() {
test('#initialize should set url as edit_url', function () {
equal(this.quiz.get('url'), 'http://localhost:3000/courses/1/assignments/7/edit?quiz_lti')
})

Expand Down Expand Up @@ -329,6 +333,16 @@ test('includes htmlUrl', () => {
deepEqual(json.htmlUrl, 'http://example.com/quizzes/1')
})

test('includes buildUrl', () => {
const quiz = new Quiz({
id: '1',
url: 'http://example.com/quizzes/1',
html_url: 'http://example.com/quizzes/1'
})
const json = quiz.toView()
deepEqual(json.buildUrl, 'http://example.com/quizzes/1')
})

test('includes multipleDueDates', () => {
const quiz = new Quiz({
all_dates: [{title: 'Summer'}, {title: 'Winter'}]
Expand Down Expand Up @@ -434,15 +448,15 @@ QUnit.module('Assignment#pollUntilFinishedLoading (duplicate)', {
}
})

test('polls for updates (duplicate)', function() {
test('polls for updates (duplicate)', function () {
this.quiz.pollUntilFinishedLoading(4000)
this.clock.tick(2000)
notOk(this.quiz.fetch.called)
this.clock.tick(3000)
ok(this.quiz.fetch.called)
})

test('stops polling when the quiz has finished duplicating', function() {
test('stops polling when the quiz has finished duplicating', function () {
this.quiz.pollUntilFinishedLoading(3000)
this.quiz.set({workflow_state: 'unpublished'})
this.clock.tick(3000)
Expand All @@ -462,15 +476,15 @@ QUnit.module('Assignment#pollUntilFinishedLoading (migration)', {
}
})

test('polls for updates (migration)', function() {
test('polls for updates (migration)', function () {
this.quiz.pollUntilFinishedLoading(4000)
this.clock.tick(2000)
notOk(this.quiz.fetch.called)
this.clock.tick(3000)
ok(this.quiz.fetch.called)
})

test('stops polling when the quiz has finished migrating', function() {
test('stops polling when the quiz has finished migrating', function () {
this.quiz.pollUntilFinishedLoading(3000)
this.quiz.set({workflow_state: 'unpublished'})
this.clock.tick(3000)
Expand Down
60 changes: 60 additions & 0 deletions spec/coffeescripts/views/assignments/AssignmentListItemViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,66 @@ QUnit.module('AssignmentListItemViewSpec - editing assignments', function (hooks
})
})

QUnit.module('AssignmentListItemViewSpec - skip to build screen button', function (hooks) {
hooks.beforeEach(function () {
fakeENV.setup({
current_user_roles: ['teacher'],
URLS: {assignment_sort_base_url: 'test'},
QUIZ_LTI_ENABLED: true,
FLAGS: {
new_quizzes_skip_to_build_module_button: true
}
})
})

hooks.afterEach(function () {
fakeENV.teardown()
genTeardown.call(this)
})

test('canShowBuildLink is true if QUIZ_LTI_ENABLED and the skip to build button are enabled', function () {
const view = createView(
buildAssignment({
id: 1,
title: 'Foo',
is_quiz_lti_assignment: true
})
)

const json = view.toJSON()
strictEqual(json.canShowBuildLink, true)
})

test('canShowBuildLink is false if new_quizzes_skip_to_build_module_button is false', function () {
ENV.FLAGS = {
new_quizzes_skip_to_build_module_button: false
}
const view = createView(
buildAssignment({
id: 1,
title: 'Foo',
is_quiz_lti_assignment: true
})
)

const json = view.toJSON()
strictEqual(json.canShowBuildLink, false)
})

test('canShowBuildLink is false if the assignment is not a new quiz', function () {
const view = createView(
buildAssignment({
id: 1,
title: 'Foo',
is_quiz_lti_assignment: false
})
)

const json = view.toJSON()
strictEqual(json.canShowBuildLink, false)
})
})

QUnit.module('AssignmentListItemViewSpec - deleting assignments', function (hooks) {
hooks.beforeEach(function () {
fakeENV.setup({
Expand Down
Loading

0 comments on commit d26cf58

Please sign in to comment.