随机播放答案属性 [英] Shuffle answer properties

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

问题描述

我必须激活属性才能改变多选类型questoin的问题,但找不到属性.我发现这段代码随机分配了问题,但没有给出答案.

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

视觉组件的图像

推荐答案

问题跟踪程序:

目前无法实现.考虑在以下功能请求中添加一个星号(在左上方),以供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

在此答案中已经提到的 的部分解决方法是改组数组创建选项并使用

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天全站免登陆