i've made a function applyed to a specific Google Form. When i open that form (FORM A) in edit mode, he fire my function, that do the following tasks:
He select a random list of questions from another google form (FORM B)(used as questions' archive), and he create a CLONE of each question selected into FORM A.
To do that, i CREATE into FORM A, the same "type of item" selected in FORM B, than apply to the new item the same settings of the original one (title, text, options, required, etc...)
The problem is that whem i COPY the FORM B's paramethers, i don't know how to access to an eventually image or video charged IN THE ITEM....
That's the code:
for (var i = 0; i < questions.length; i++){
var q = questions[i];
var type = q.getType().toString();
if (type == FormApp.ItemType.MULTIPLE_CHOICE){
var qEl = q.asMultipleChoiceItem(); //qEl is the template element that i wan't to "clone" (read by FORM B)
console.log("creazione "+type);
var item = form.addMultipleChoiceItem(); //That's the new item, that i create in FORM A
// now i set to my new item, all the proprierties of qEl
item.setTitle(qEl.getTitle())
.setChoices(qEl.getChoices())
.setRequired(qEl.isRequired())
.showOtherOption(qEl.hasOtherOption()).setHelpText(qEl.getHelpText());
// oppsss... HOW CAN I see if in qEl is loaded a MEDIA (image/video) ?!??
}
..... continue with other types check
}
I've found a WORKAROUND, that consist in create an IMAGEITEM before the quiz item, but that solution need to build each "question" with media, as 2 ITEMS (1 with the image/video, and another with the question).
that's the code to duplicate, for example, an "imageItem":
if (type == FormApp.ItemType.IMAGE){
var qEl = q.asImageItem();
console.log("creazione "+type);
// var item = form.addMultipleChoiceItem(q.asMultipleChoiceItem);
var item = form.addImageItem();
item.setTitle(qEl.getTitle())
.setImage(qEl.getImage())
.setHelpText(qEl.getHelpText()).setWidth(qEl.getWidth()).setAlignment(qEl.getAlignment());
}
What i really want, is to access to an eventually IMAGE attacked INTO the QUIZ item. Any solution or suggestion?
Thank you, Piero