untitled

Pasted Oct 22, 2026, 2:56 PM1 file139 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/zzgsphp08fbq58w6
untitled

const CONFIG = {
  // Use the ID from your FORM EDITOR URL, not the /viewform URL.
  FORM_ID: "PASTE_EDITOR_FORM_ID_HERE",
  TOTAL_RESPONSES: 100,
  TEST_EMAIL_DOMAIN: "example.com"
};

function generateTestResponses() {
  const form = FormApp.openById(CONFIG.FORM_ID);
  const items = form.getItems();
  let submitted = 0;

  for (let i = 0; i < CONFIG.TOTAL_RESPONSES; i++) {
    const response = form.createResponse();

    for (const item of items) {
      const type = item.getType();
      const title = item.getTitle().toLowerCase();

      try {
        let answer = null;

        if (type === FormApp.ItemType.TEXT) {
          const field = item.asTextItem();

          const value = title.includes("email")
            ? `test${i + 1}@${CONFIG.TEST_EMAIL_DOMAIN}`
            : `Test Response ${i + 1}`;

          answer = field.createResponse(value);
        }

        else if (type === FormApp.ItemType.PARAGRAPH_TEXT) {
          answer = item.asParagraphTextItem()
            .createResponse(
              "Synthetic response for system testing."
            );
        }

        else if (type === FormApp.ItemType.MULTIPLE_CHOICE) {
          const field = item.asMultipleChoiceItem();
          const choices = field.getChoices()
            .filter(c => !c.isOther());

          if (choices.length) {
            const selected = randomChoice(choices);
            answer = field.createResponse(
              selected.getValue()
            );
          }
        }

        else if (type === FormApp.ItemType.LIST) {
          const field = item.asListItem();
          const choices = field.getChoices();

          if (choices.length) {
            answer = field.createResponse(
              randomChoice(choices).getValue()
            );
          }
        }

        else if (type === FormApp.ItemType.CHECKBOX) {
          const field = item.asCheckboxItem();
          const choices = field.getChoices()
            .filter(c => !c.isOther());

          if (choices.length) {
            answer = field.createResponse([
              randomChoice(choices).getValue()
            ]);
          }
        }

        else if (type === FormApp.ItemType.SCALE) {
          const field = item.asScaleItem();
          const min = field.getLowerBound();
          const max = field.getUpperBound();

          answer = field.createResponse(
            randomInt(min, max)
          );
        }

        else if (type === FormApp.ItemType.GRID) {
          const field = item.asGridItem();
          const columns = field.getColumns();

          answer = field.createResponse(
            field.getRows().map(() =>
              randomChoice(columns)
            )
          );
        }

        else if (type === FormApp.ItemType.CHECKBOX_GRID) {
          const field = item.asCheckboxGridItem();
          const columns = field.getColumns();

          answer = field.createResponse(
            field.getRows().map(() => [
              randomChoice(columns)
            ])
          );
        }

        if (answer) {
          response.withItemResponse(answer);
        }

      } catch (error) {
        Logger.log(
          `Question skipped: ${item.getTitle()} - ${error}`
        );
      }
    }

    try {
      response.submit();
      submitted++;
      Logger.log(`Submitted ${submitted}`);
    } catch (error) {
      Logger.log(`Submission ${i + 1} failed: ${error}`);
    }
  }

  Logger.log(`Completed: ${submitted} test responses`);
}

function randomChoice(array) {
  return array[Math.floor(Math.random() * array.length)];
}

function randomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

3,679 chars · codepastes.com