本文介绍了在Google Form测验之间复制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Google测验项目从一个Form复制到另一个,这似乎已经完全成功.但是,我忘记了其中一些物品附有图片.

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.

这是一个链接到示例测验.

没有任何文献记录建议如何访问它们,但是我已经尝试了从ItemItem.asMultipleChoiceItem进行的getImage,但是都没有被发现.只是最后两行代码不起作用.

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.

我知道

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);
}

这是附在MultipleChoiceItem上的图像的图片,而不是本身的ImageItem:

Here's a picture of the image which is attached to the MultipleChoiceItem, not an ImageItem in its own right:

推荐答案

这是结果代码

if(questionType=='MULTIPLE_CHOICE'){
var img = UrlFetchApp.fetch(www.myWebSite.com/tomato.png);
form.addImageItem()
 .setTitle('Quizz')
 .setHelpText('Any number off answer')
 .setImage(img);
var item = form.addMultipleChoiceItem();
item.setChoices([
    item.createChoice('tomato'),
    item.createChoice('pomodoro'),
    item.createChoice('tomate'),
    item.createChoice('tomata'),

]);

这有点奇怪,但这是我发现使测验显示的唯一方法,就像我在测验中添加图像一样(使用不带脚本的表单编辑器).现在,您对电子表格的响应有疑问,对不起

It is a bit odd but this is the only way I have found to make the quizz appear the same way as if I had add the image in the quizz(using the form editor without script).Now you have a problem with the spreadsheet with the response, sorry

这篇关于在Google Form测验之间复制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:05