allow moving multiple questions for large quiz banks

fixes QO-541
flag = none

test plan:
 - create a classic quizzes bank with many questions (20+)
   (I think the issue can be reproduced with smaller banks,
    but it seems you'll hit the issue more often the more
    questions you have)
 - while viewing that bank, click "Move Multiple Questions"
 - the questions in the bank should load properly in the modal
 - refresh the page and repeat several times, as the original
   issue does not reproduce consistently

Change-Id: Idbed957d087bfb91a6978f81594006df482890f5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/233412
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Alex Slaughter <aslaughter@instructure.com>
QA-Review: Stephen Kacsmark <skacsmark@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
This commit is contained in:
Jared Crystal 2020-04-08 11:53:35 -06:00
parent a409162778
commit 3e8df5b04a
1 changed files with 11 additions and 10 deletions

View File

@ -32,11 +32,9 @@ import 'jquery.templateData' /* fillTemplateData, getTemplateData */
const moveQuestions = {
elements: {
$dialog: () => {
return $('#move_question_dialog')
},
$loadMessage: $('<li />').append(htmlEscape(I18n.t('load_questions', 'Loading Questions...'))),
$questions: $('#move_question_dialog .questions')
$dialog: () => $('#move_question_dialog'),
$questions: () => $('#move_question_dialog .questions'),
$loadMessage: $('<li />').append(htmlEscape(I18n.t('load_questions', 'Loading Questions...')))
},
messages: {
move_copy_questions: I18n.t('title.move_copy_questions', 'Move/Copy Questions'),
@ -64,8 +62,11 @@ const moveQuestions = {
.$dialog()
.find('.question_text')
.hide()
this.elements.$questions.show()
this.elements.$questions.find('.list_question:not(.blank)').remove()
this.elements.$questions().show()
this.elements
.$questions()
.find('.list_question:not(.blank)')
.remove()
this.elements
.$dialog()
.find('.question_name')
@ -102,7 +103,7 @@ const moveQuestions = {
})
},
loadData() {
this.elements.$questions.append(this.elements.$loadMessage)
this.elements.$questions().append(this.elements.$loadMessage)
$.ajaxJSON(
window.location.href + '/questions?page=' + this.page,
'GET',
@ -113,9 +114,9 @@ const moveQuestions = {
onData(data) {
const html = moveQuestionTemplate(data)
this.elements.$loadMessage.remove()
this.elements.$questions.append(html)
this.elements.$questions().append(html)
if (this.page < data.pages) {
this.elements.$questions.append(this.elements.$loadMessage)
this.elements.$questions().append(this.elements.$loadMessage)
this.page += 1
this.loadData()
} else {