Skip to content

Instantly share code, notes, and snippets.

@nrm176
Created September 9, 2020 06:08
Show Gist options
  • Save nrm176/41df4f1c45e16a45522e1c783e3a471e to your computer and use it in GitHub Desktop.
Save nrm176/41df4f1c45e16a45522e1c783e3a471e to your computer and use it in GitHub Desktop.
const QUIZ_FOLDER_ID = 'YOUR_FOLDER_ID'

function myFunction() {
  addFormItems()
}

function addFormItems() {
  
  const formTitle = 'TestQuiz';
  const form = FormApp.create(formTitle).setIsQuiz(true)
  
  //const item = FormApp.openById(form.getId()).addMultipleChoiceItem()
  const item = form.addMultipleChoiceItem()
  
  item
  .setTitle('1+4')
  .setChoices([
    item.createChoice('1', false),
    item.createChoice('3', false),
    item.createChoice('5', true),
    item.createChoice('2', false),
  ]).setPoints(10).setRequired(true)
    
   
   const formFile = DriveApp.getFileById(form.getId())
   DriveApp.getFolderById(QUIZ_FOLDER_ID).addFile(formFile)
  
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment