Google表单允许每天在特定时间开放

时间:2017-04-24 16:57:39

标签: google-apps-script

我正在寻找一个允许从上午9点到下午3点打开谷歌表单的脚本。下午3点后,它应该限制打开它。

由于

1 个答案:

答案 0 :(得分:0)

您需要创建一个创建触发器的函数。类似的东西:

public class Tab1 extends Fragment {

static ListView listNotifications;
final static ArrayList<String> name = new ArrayList<>();
static ArrayList<Integer> number = new ArrayList<>();
static ArrayList<String> nick = new ArrayList<>();

static ImageAdapter adapter;


public static class ImageAdapter extends ArrayAdapter<String> {
    private final Context context;
    private final String[] values;

    public ImageAdapter (Context context, String[] values) {
        super(context, R.layout.list_with_icons, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View rowView = inflater.inflate(R.layout.list_with_icons, parent, false);

        TextView textView = (TextView) rowView.findViewById(R.id.textViewName);

        ImageView imageView = (ImageView) rowView.findViewById(R.id.imagePicture);

        textView.setText(values[position]);
        // Change the icon for Windows and iPhone


        return rowView;
    }
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.tab1layout, container, false);

    String[] nameString = new String[name.size()];
    nameString = name.toArray(nameString);

    adapter = new ImageAdapter (getActivity(), nameString);



   listNotifications =(ListView)rootView.findViewById(R.id.listNotifications);

listNotifications.setAdapter(adapter);




    return rootView;


}}

您可以使用https://developers.google.com/apps-script/reference/script/trigger-builder处的文档来优化此代码。使用类似的结构来构建一个触发器,在上午9点打开表单。

这每天在第3小时调用一个函数。以下是一些打开和关闭表单函数的示例:

function triggerClose() {
  ScriptApp.newTrigger('closeForm')
    .timeBased()
    .everyDays(1)
    .atHour(3)
    .forForm(FormApp.openById(FORM_ID))
    .create();
}

我希望这有用。