when create a quiz in a format where i need to repeat with the same list of vocabulary. how do i save tmy time typinh them over and over?

Jump to solution
ls29
Community Member

Example here:

 

  1. [rank1]
  2. [rank2}

 

Only me

Young of a sibling

Oldest of a sibling

Youngest of three

Last of four

Last of five

Last of six

Third out of four

Second out of four

Second of three

Third oldest of four

Third oldest of five

Second oldest of four

Second oldest of five

 

Labels (1)
0 Likes
1 Solution
James
Community Champion

@ls29 

Unfortunately, there is no way using just the web-interface to duplicate a set of responses. This is true for multiple responses within the same question and also for reusing the same choices across multiple questions.

Unless you have some advanced technical skills, retyping the information for each response is going to be the fastest way to accomplish this. If this is just for a couple of questions, it is definitely faster to retype. You are going to spend a substantial amount of time on the advanced techniques (unless the code I give happens to work perfectly for you). If you are doing this for a lot of questions, then it may be worth looking into alternative approaches.

 

You didn't mention whether you were using Classic Quizzes or New Quizzes.

For Classic Quizzes, you can create questions outside the web interface. The Quiz Questions API specifies how to create the questions and the appendices at the bottom of the Quiz Statistics API shows the format for each type of question. Similar information is found for New Quizzes under the New Quiz Items API.

One can be able to use JavaScript to duplicate the responses, but it would be highly specific to the situation (multiple dropdowns vs multiple fill in the blanks). I wrote some code and tested it for a multiple dropdown question using Classic Quizzes.

  1. Edit the Classic Quiz
  2. Edit a question. Make sure you're only editing one question as I did not test this with multiple questions open at the same time.
  3. Open the browser's developer tools (usually F12) and switch to the Console tab.
  4. Paste the following code. Edit it if necessary.
  5. Execute the code (hit enter in Chrome. I think it's Ctrl+Enter in Firefox).
  6. Go through the question sets to make sure they are the way they are supposed to be.
  7. Update the question in Canvas.

This code looks for a multiple dropdown question that has more than one variable. It removes any existing answers except for the first set of responses and then duplicates the first set of responses for all remaining items. It does not try to determine which is the active set of questions (it could by looking at the hidden class), so make sure that the answers you want to duplicate are in the first set of responses.

(function () {
  'use strict';
  const options = document.querySelectorAll(
    'form.question_form div.multi_answer_sets select option'
  );
  if (options.length < 2) {
    return;
  }
  const src=options[0].value;
  const parent = document.querySelector('div.form_answers');
  for (let i = 1; i < options.length; i++) {
    const dst = options[i].value;
    parent
      .querySelectorAll(`div.answer[class~="answer_for_${dst}"]`)
      .forEach(e => e.remove());
    parent
      .querySelectorAll(`div.answer[class~="answer_for_${src}"]`)
      .forEach(e => {
        const el = e.cloneNode(true);
        el.classList.remove(`answer_for_${src}`);
        el.classList.add(`answer_for_${dst}`);
        el.classList.remove(`answer_idx_0`);
        e.classList.add(`answer_idx_${i}`);
        parent.appendChild(el);
      });
  }
})();

 

This code does not try to set the hidden option, so when you run it, so it will look weird. Be sure to toggle through the different question sets to reset the hidden/shown attributes and double check that it worked before updating the question.

This is a quick script I wrote for you. I didn't do any error checking and minimal debugging. It seems to work, but I might have missed something.

View solution in original post