随机回答属性 [英] Shuffle answer properties

查看:14
本文介绍了随机回答属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须激活属性才能对多项选择题类型的问题进行随机排序,但我找不到这些属性.我发现这段代码会随机化问题,而不是答案.

I have to activate the properties to shuffle the question of a multiple choice type questoin, but I can't find the properties. I found this code that randomizes questions, but not the answers.

form.setShuffleQuestions(true); 

视觉组件的图像

推荐答案

Issuetracker:

这目前是不可能的.考虑在以下功能请求中添加一颗星(左上角),以便 Google 确定问题的优先级:

Issuetracker:

This isn't currently possible. Consider adding a star (on top left) to the following feature requests for Google to prioritize the issue:

https://issuetracker.google.com/issues/64134484

已经提到的部分解决方法在这个答案中是改组数组创建选项并使用 setChoiceValues().这种服务器端随机化的缺点是

Partial Workaround as already mentioned in this answer is to shuffle the array creating options and setback the array using setChoiceValues(). The drawback of such server side randomizing is

  • 只能在服务器脚本运行时执行,而不能在客户端打开表单时执行

  • It can only be done whenever the server script runs and not when client opens the form

即使您将每分钟随机化,也有可能同时打开表单的用户看到的选项顺序相同

Even if you randomize each minute, it is possible that users opening the form simultaneously will see the same order of options

const form = FormApp.openById('/*form id*/');
const item = form.addMultipleChoiceItem();
item.setTitle('Car or truck?');
const options = ['Truck', 'Car'];
//Durstenfeld algo
for (let i = options.length - 1; i > 0; i--) {
  let rand = Math.floor(Math.random() * i);
  [options[i], options[rand]] = [options[rand], options[i]];
}
item.setChoiceValues(options);

这篇关于随机回答属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆