I am trying to copy Google quiz items from one Form
to another, which appeared to have been completely successful. However, I forgot that some of these items have images attached to them.
Here's a link to an example quiz.
There's nothing documented to suggest how to access these, but I have tried getImage
both from the Item
and the Item.asMultipleChoiceItem
but neither is recognised. It's just the last 2 lines of code that aren't working.
I get
TypeError: Cannot find function
getImage
in objectItem
or
TypeError: Cannot find function
getImage
in objectMultipleChoiceItem
function copyMultipleChoiceItem(item1, item2) {
// copies MC question item1 to item2 - tested PDW 17/05/20
// copy of feedback now working - tested PDW 17/05/30
//
var item1MC = item1.asMultipleChoiceItem();
// basic question items
item2.setTitle(item1.getTitle());
item2.setHelpText(item1.getHelpText());
item2.setPoints(item1MC.getPoints());
item2.setRequired(item1MC.isRequired());
// the choices
var choices = item1MC.getChoices();
for (var i = 0; i < choices.length; i++) {
item2.createChoice(choices[i].getValue(), choices[i].isCorrectAnswer());
}
item2.setChoices(choices);
// the feedback
var feedback1 = item1MC.getFeedbackForCorrect();
item2.setFeedbackForCorrect(feedback1);
var feedback1 = item1MC.getFeedbackForIncorrect();
item2.setFeedbackForIncorrect(feedback1);
// the image
var image1 = item1.getImage();
item2.setImage(image1);
}
Here's a picture of the image which is attached to the MultipleChoiceItem
, not an ImageItem
in its own right: