cancel
Showing results for 
Search instead for 
Did you mean: 
david_white
Surveyor

Faster way to move questions between banks?

Jump to solution

Is there a faster way to move multiple questions between banks?  I am importing custom banks from offline for merger into my existing banks, and once I import them, I go to Move Multiple Questions (from inside Manage Question Banks window, after opening the newly-imported bank).  But then, I have to click each individual question box in its turn (which is a pain considering how small the window view is, but that's another issue...).  Am I missing something?  How feasible would it be to put a Select All box at the top of the window?  This would make my task much easier.  

I also suppose a option to Merge Question Banks at the Manage Question Banks window would also be nice, but there probably is not as much call for that feature.

1 Solution

Accepted Solutions
James
Navigator

 @david_white ‌ and  @bbaumgartner ‌

You may find this helpful under certain conditions.

Select All questions in a bank

  1. Open up the question bank
  2. Click on the Move Multiple Questions button
  3. Press F12 to bring up the Developer Tools in your browser.
  4. Switch to the Console tab of the developer tools
  5. Paste the code below at the console prompt and press Enter.
  6. Choose where you would like to move the questions
  7. Click on Move Questions

$('li.list_question:not(".blank") input.list_question_checkbox').prop('checked',true);

That will select every checkbox for every question question that has been loaded ... even if it isn't showing because you haven't scrolled down far enough. In other words ... be careful ... you might end up moving more than you wanted to move.


Here are some screenshots from Firefox.

Open Move/Copy Questions

Yes, some of my questions had the same names - but this is my sandbox where I was testing things.

224079_pastedImage_5.png

F12 - then Console and paste

224087_pastedImage_21.png

Console after pasting.

I did this command twice -- notice how it continues to load questions in the background (294 more the first time then 594 more the second time).

224088_pastedImage_23.png

Move/Copy after pasting JavaScript

224083_pastedImage_13.png

Select Some questions containing certain text

Let's say that you don't want to move all of your questions into a new question bank, you just want to move some of them.  The code above moves everything that had been loaded, which was 305 items for me without doing any scrolling down to select additional ones.

If you have labels for the question that are wisely named, then you may be able to select just certain questions.

Let's say that I just want to select the elements that contain "ch3d_" in the label, I could use this code instead of the line above. It uses the jQuery :contains() selector.

$('li.list_question:not(".blank") input.list_question_checkbox + label:contains("ch3d_")')
.each(function(i, e) {  $('#' + e.htmlFor).prop('checked', true); });‍‍‍‍

Note that this could all be on one line, I just split it here so it didn't wrap.

It finds all of the inputs directly followed (because of the +) by a label that contains the text "ch3d_". It then iterates over each of them, taking the for="id" portion of the label (which is stored in the htmlFor property) and then checking the input box that has that id.

After running it here, I get this in the console:

224084_pastedImage_17.png

and this on the selection screen.

224085_pastedImage_18.png

Select some questions using a regular expression

The second example uses the jQuery :contains() selector to look for text. It is case sensitive and it will match anywhere in the text, so if had a question label "bank1_ch3d_001", it would still find it, but it wouldn't find "Ch3d_001" (because of the capital C).

You can create a regular expression in JavaScript to be more specific about what you're after.

Let's say that I have some questions that are groups ch4a_, ch4b_, ch4c_, and so on up to ch4i_. Each group has 150 questions, numbered 001 - 150. They were all created at the same and they are matched, so ch4a_100 is about the same problem as ch4b_100, ch4c_100, and so on.

I want to copy questions 100-150 for all of the question groups over to a new bank. The following code will do that: again, it's split over multiple lines for readability.

$('li.list_question:not(".blank") input.list_question_checkbox + label').each(function(i,e) {
   if (/^ch4[a-i]_1[0-9][0-9]$/.test(e.textContent)) { $('#' + e.htmlFor).prop('checked',true); }
});‍‍‍‍

The important part is getting the regular expression correct.

Since the test for matching the regular expression is done after the CSS selector, the console will like show that it found more items than it actually did. But notice in the image that it did not select _099.

224086_pastedImage_20.png

Teaching regular expressions is beyond the scope of this post, but hopefully one of the three ways will help you out.

Final notes

There may be more efficient ways to write those, and I've probably put more CSS selectors in there than was absolutely necessary. But this mass select is probably going to be used so infrequently that they won't benefit a lot from optimization. It takes fractions of a second to execute even the regular expression version on my list of 2053 questions.

I will also add that it found 2053 question labels despite Canvas only showing there were 2049 in the question bank. I'm not sure where the difference is. It seems to work okay when there were fewer questions. The selectors could probably be tweaked with additional testing, but hopefully you don't have a question bank with that many questions in it.

And yes -- you probably could add a select all button that did this, but then it would eat up the already limited space.

View solution in original post

4 Replies
Robbie_Grant
Community Coach
Community Coach

 @david_white ,

What you are currently doing is the only option, currently, for selecting the questions to move to another question bank.  Now, the a new quiz tool is currently under development, so maybe the functionality you are looking for will be built into the new quiz tool.

Robbie

Yes, please.   This would make exam editing a lot faster, particularly for an instructor who truly wants to combine, say, multiple chapters into a single pool.

Yes! I am facing the same issue. Very annoying and time consuming. 

James
Navigator

 @david_white ‌ and  @bbaumgartner ‌

You may find this helpful under certain conditions.

Select All questions in a bank

  1. Open up the question bank
  2. Click on the Move Multiple Questions button
  3. Press F12 to bring up the Developer Tools in your browser.
  4. Switch to the Console tab of the developer tools
  5. Paste the code below at the console prompt and press Enter.
  6. Choose where you would like to move the questions
  7. Click on Move Questions

$('li.list_question:not(".blank") input.list_question_checkbox').prop('checked',true);

That will select every checkbox for every question question that has been loaded ... even if it isn't showing because you haven't scrolled down far enough. In other words ... be careful ... you might end up moving more than you wanted to move.


Here are some screenshots from Firefox.

Open Move/Copy Questions

Yes, some of my questions had the same names - but this is my sandbox where I was testing things.

224079_pastedImage_5.png

F12 - then Console and paste

224087_pastedImage_21.png

Console after pasting.

I did this command twice -- notice how it continues to load questions in the background (294 more the first time then 594 more the second time).

224088_pastedImage_23.png

Move/Copy after pasting JavaScript

224083_pastedImage_13.png

Select Some questions containing certain text

Let's say that you don't want to move all of your questions into a new question bank, you just want to move some of them.  The code above moves everything that had been loaded, which was 305 items for me without doing any scrolling down to select additional ones.

If you have labels for the question that are wisely named, then you may be able to select just certain questions.

Let's say that I just want to select the elements that contain "ch3d_" in the label, I could use this code instead of the line above. It uses the jQuery :contains() selector.

$('li.list_question:not(".blank") input.list_question_checkbox + label:contains("ch3d_")')
.each(function(i, e) {  $('#' + e.htmlFor).prop('checked', true); });‍‍‍‍

Note that this could all be on one line, I just split it here so it didn't wrap.

It finds all of the inputs directly followed (because of the +) by a label that contains the text "ch3d_". It then iterates over each of them, taking the for="id" portion of the label (which is stored in the htmlFor property) and then checking the input box that has that id.

After running it here, I get this in the console:

224084_pastedImage_17.png

and this on the selection screen.

224085_pastedImage_18.png

Select some questions using a regular expression

The second example uses the jQuery :contains() selector to look for text. It is case sensitive and it will match anywhere in the text, so if had a question label "bank1_ch3d_001", it would still find it, but it wouldn't find "Ch3d_001" (because of the capital C).

You can create a regular expression in JavaScript to be more specific about what you're after.

Let's say that I have some questions that are groups ch4a_, ch4b_, ch4c_, and so on up to ch4i_. Each group has 150 questions, numbered 001 - 150. They were all created at the same and they are matched, so ch4a_100 is about the same problem as ch4b_100, ch4c_100, and so on.

I want to copy questions 100-150 for all of the question groups over to a new bank. The following code will do that: again, it's split over multiple lines for readability.

$('li.list_question:not(".blank") input.list_question_checkbox + label').each(function(i,e) {
   if (/^ch4[a-i]_1[0-9][0-9]$/.test(e.textContent)) { $('#' + e.htmlFor).prop('checked',true); }
});‍‍‍‍

The important part is getting the regular expression correct.

Since the test for matching the regular expression is done after the CSS selector, the console will like show that it found more items than it actually did. But notice in the image that it did not select _099.

224086_pastedImage_20.png

Teaching regular expressions is beyond the scope of this post, but hopefully one of the three ways will help you out.

Final notes

There may be more efficient ways to write those, and I've probably put more CSS selectors in there than was absolutely necessary. But this mass select is probably going to be used so infrequently that they won't benefit a lot from optimization. It takes fractions of a second to execute even the regular expression version on my list of 2053 questions.

I will also add that it found 2053 question labels despite Canvas only showing there were 2049 in the question bank. I'm not sure where the difference is. It seems to work okay when there were fewer questions. The selectors could probably be tweaked with additional testing, but hopefully you don't have a question bank with that many questions in it.

And yes -- you probably could add a select all button that did this, but then it would eat up the already limited space.

View solution in original post