How to Create a Quiz in Google Forms with AI for Free

How to Create a Quiz in Google Forms with AI for Free

Whether you are a teacher or corporate trainer, you often create a quiz in Google Forms. But quiz creation often takes time and reduces time for interacting with students directly, leading to poor learning experience for students. To lighten your burden for this task, in this article, I go through how to create a quiz in Google Forms using Gemini 2.5 Pro and Google Apps Script. Before getting started, I assume you have a Google account.

d

Step-by-Step Guide

Step 1: Generate Google Apps Script for Google Forms Quiz Generation

First, generate a Google Apps Script to generate a quiz in Google Forms using Gemini 2.5 Pro.

  1. Visit https://gemini.google.com.
  2. Click "2.5 Flash."
    Source: https://gemini.google.com
  3. Choose "2.5 Pro."
  4. Type this prompt template in the textbox.
    [Task]: Write GAS code to generate a quiz in Google Form. 
    [Purpose]: (explain the purpose).
    [Question Types]: (type question types).
    [Target]: (set the target).
    [Number of Questions]: (set the number of questions)
    [Constraints]:
    - When you create a multiple choice, write in this format. Please change the question number for each question as well as placeholders enclosed with “(” and “)”.
    
    ```
    const q1 = form.addMultipleChoiceItem();
    q1.setTitle("(Question))
    q1.setChoices([
        q1.createChoice("(Choice 1)"),
        q1.createChoice("(Choice 2)"),
        q1.createChoice("(Choice 3)"),
        q1.createChoice("(Choice 4)")
      ]);
    ```
    
    - Stop publishing the form by writing this code:
    
    ```
    const form = FormApp.create('the form's title here');
    
    form.setPublished(false);
    ```
    
    - In the end of the code, always log the editor URL in this format: "Editor URL: (the URL here)"
    
  5. Click "+" to upload your study material file (videos, audios, or documents), or reference another study material or article's URL in the [Purpose] section in the prompt.
    Source: https://gemini.google.com
  6. Fill other bold placeholders enclosed with "(" and ")" in the prompt.
  7. Press Enter.
  8. Google Apps Script code will be generated.
  9. Click the copy button in the top right corner of the generated code block to copy the code.
    Source: https://gemini.google.com
  10. Type this prompt in the same textbox.
    Generate the questions' answers.
  11. Press Enter.
  12. The questions's answers will be generated.

Step 2: Generate a Quiz

After Gemini 2.5 Pro generates the Google Apps Script code, execute the code to create a quiz.

  1. Visit https://script.google.com.
  2. Click "New project."
    Source: https://script.google.com
  3. A new project will be created. Replace the existing code with the copied code.
    Source: https://script.google.com
  4. Click "Run."
    Source: https://script.google.com
  5. A pop-up will be opened. Click "Review permissions."
    Source: https://script.google.com
  6. Sign in to your account.
  7. Another pop-up will be opened. Click "Advanced."
    Source: https://account.google.com
  8. Click "Go to Untitled project (unsafe)."
    Source: https://account.google.com
  9. Click "Continue."
    Source: https://account.google.com
  10. The script will be executed.
  11. Copy this URL.
    Source: https://script.google.com
  12. Access the URL.

Here's the example of a form.


Use Cases

Here are 3 use cases you can try with this AI application.

For Anti-Cheating

One questioner mentioned students googling answers or switching tabs during quizzes. In response to the question, the first commenter adviced including thought-provoking questions in the quiz as a measure. Then, I thought it would be useful if I streamlined this process with AI. So, I added a follow-up prompt after the first prompt execution and tested it. Looking at the quiz, Gemini thoughtfully mixed these questions in the quiz. As a result, it seems not just a fact-matching quiz but also a quiz that allows students to apply their learned knowledge. Here's the follow-up prompt and the result if the purpose is to test the understanding of this article.

Follow-up Prompt

To check if [Target] truly engaged with the source, mix creative questions that ask for the answerer's original thoughts.

Result

d

For Personalized Learning

In this Reddit thread, one teacher claimed that their students got wrong answers in activities or opportunities to practice even when they were taught the answers. Another teacher mentioned that attendance was the only thing they have to do because they get credit through credit recovery. Overall, it seems that students had low motivation to learning. However, despite the motivation, there's one way to address this problem—AI-powered, interest-based learning. Teachers can ask students with low motivation for their interests and describe about them in the [Target] section in this prompt below. This helps diverse students learn in a personalized way. Here's the prompt parameter example and the result.

Parameter Example

[Task]: Write GAS code to generate a quiz in Google Form.
[Purpose]: [Target] will be able to understand the difference between zero, first, and second conditionals explained in [this article](https://learnenglish.britishcouncil.org/grammar/b1-b2-grammar/conditionals-zero-first-second).
[Question Types]: Short answer, multiple choice, checkboxes, dropdown.
[Target]: A high school student with a learning disability and an interest in illustration.
[Number of Questions]: 10
[Constraints]: When you create a multiple choice, write in this format. Please change the question number for each question as well as placeholders enclosed with “(” and “)”.
```
const q1 = form.addMultipleChoiceItem();
q1.setTitle("(Question))
q1.setChoices([
    q1.createChoice("(Choice 1)"),
    q1.createChoice("(Choice 2)"),
    q1.createChoice("(Choice 3)"),
    q1.createChoice("(Choice 4)")
  ]);
```
- Stop publishing the form by writing this code:

```
const form = FormApp.create('the form's title here');

form.setPublished(false);
```

- In the end of the code, always log the editor URL in this format: "Editor URL: (the URL here)."

Result

d

Before-Test Quiz

Some students need more practice before their tests unless they fail academically. On the other hand, teachers' burdens for quiz creation are serious. To keep up with the demand, a data-driven quiz that specifically approaches their weaknesses is needed. To base quizzes on your student's performance, I added [Past Students' Performance] section in the original prompt. Here's the optimized prompt, the example, and the result.

Prompt Template

[Task]: Write GAS code to generate a quiz in Google Form. 
[Purpose]: (explain the purpose).
[Question Types]: (type question types).
[Target]: (set the target).
[Number of Questions]: (set the number of questions)
[Past Students' Performance]: (describe clear data that show your students' weaknesses)
[Constraints]:
- When you create a multiple choice, write in this format. Please change the question number for each question as well as placeholders enclosed with “(” and “)”.

```
const q1 = form.addMultipleChoiceItem();
q1.setTitle("(Question))
q1.setChoices([
    q1.createChoice("(Choice 1)"),
    q1.createChoice("(Choice 2)"),
    q1.createChoice("(Choice 3)"),
    q1.createChoice("(Choice 4)")
  ]);
```

- Stop publishing the form by writing this code:

```
const form = FormApp.create('the form's title here');

form.setPublished(false);
```

- In the end of the code, always log the editor URL in this format: "Editor URL: (the URL here)."

Parameter Example

[Task]: Write GAS code to generate a quiz in Google Forms.
[Purpose]: All my students will be able to understand [present perfect tense](https://learnenglish.britishcouncil.org/grammar/b1-b2-grammar/present-perfect) in English.
[Question Types]: Short answer, multiple choice, checkboxes, dropdown.
[Target]: 5th grade students in the US.
[Number of Questions]: 10
[Past Students' Performance]: According to a past test, 70% of my students failed to distinguish between present perfect tense and past tense.
[Constraints]: When you create a multiple choice, write in this format. Please change the question number for each question as well as placeholders enclosed with “(” and “)”.
```
const q1 = form.addMultipleChoiceItem();
q1.setTitle("(Question))
q1.setChoices([
    q1.createChoice("(Choice 1)"),
    q1.createChoice("(Choice 2)"),
    q1.createChoice("(Choice 3)"),
    q1.createChoice("(Choice 4)")
  ]);
```
- Stop publishing the form by writing this code:

```
const form = FormApp.create('the form's title here');

form.setPublished(false);
```

- In the end of the code, always log the editor URL in this format: "Editor URL: (the URL here)."

Result


d

Troubleshooting

Errors related to Google Apps Script

If your Google Apps Script code is causing an error, ask Gemini with this prompt below.

Source: https://script.google.com
It seems your code is having this error. Fix it.
```
(The error message here)
```

In summary, you learned how to create a quiz in Google Forms with Gemini 2.5 Pro and Google Apps Script. If this information is helpful, please share you thoughts on social media. You can share this article by clicking thebutton with 3 connected dots below.

In summary, you learned how to create a quiz in Google Forms with Gemini 2.5 Pro and Google Apps Script. If you want to add mathmatical formulas in the questions, also try reading this article below.

Comments