/**
 * APPLES OF MY EYES — TEACHER FAVORITES & CLASSROOM WISHES
 * Middle School Mary Poppins | msmarypoppins.com
 *
 * HOW TO USE: Visit https://script.google.com, start a New Project,
 * paste ALL of this script into Code.gs, save, select
 * createApplesOfMyEyesTeacherForm and click Run.
 * Authorize the permissions Google requests.
 * Check Execution log for edit link, teacher link, and responses sheet.
 * Each run creates a NEW Google Form and a NEW responses spreadsheet.
 */
function createApplesOfMyEyesTeacherForm() {
  const title = 'Apples of My Eyes 🍎 | Teacher Favorites & Classroom Wishes';
  const form = FormApp.create(title);
  form.setDescription(
    'The Teacher Tree Project | Middle School Mary Poppins — msmarypoppins.com\n\n' +
    'We want to appreciate you as a whole person, not just the things you do for your classroom. ' +
    'Your responses will help our PTO/PTA and approved volunteers choose thoughtful classroom supplies ' +
    'and small personal treats. Please answer only what feels comfortable; there are no wrong answers. ' +
    'A wish is not a promise of a gift.\n\n' +
    'Estimated time: 5–7 minutes. Your school should share responses only with its designated project coordinators. ' +
    'Do not include medical, financial, family, home-address, or other private information. ' +
    'The project supplements—never replaces—appropriate school funding.'
  );
  form.setCollectEmail(false);
  form.setLimitOneResponsePerUser(false);
  form.setShuffleQuestions(false);
  form.setShowLinkToRespondAgain(false);
  form.setPublishingSummary(false);
  form.setConfirmationMessage('Thank you for letting us get to know you a little better! Your answers will help our community appreciate you thoughtfully. 🍎 — Apples of My Eyes / msmarypoppins.com');

  function section(name, detail) {
    form.addSectionHeaderItem().setTitle(name).setHelpText(detail);
  }
  function short(question, help, required) {
    const item = form.addTextItem().setTitle(question).setRequired(Boolean(required));
    if (help) item.setHelpText(help);
  }
  function long(question, help) {
    const item = form.addParagraphTextItem().setTitle(question).setRequired(false);
    if (help) item.setHelpText(help);
  }
  function single(question, choices, help) {
    const item = form.addMultipleChoiceItem().setTitle(question).setChoiceValues(choices).setRequired(false);
    if (help) item.setHelpText(help);
  }
  function many(question, choices, help) {
    const item = form.addCheckboxItem().setTitle(question).setChoiceValues(choices).setRequired(false);
    if (help) item.setHelpText(help);
  }

  section('🍎 1. Getting to know you', 'Only your teacher name or approved display label is required. Your coordinators can work out the rest with you.');
  short('Name or name you would like on your apple', 'Example: Ms. Rivera, Coach J, or a code agreed upon with your PTO.', true);
  short('Grade, subject, or role', 'Please include specials, support services, and other school roles.', false);
  single('What kind of appreciation feels most meaningful to you?', [
    'A thoughtful handwritten note', 'A practical item I can use', 'A small surprise tied to my interests',
    'Quality time or a shared experience', 'Quiet, low-key recognition', 'I enjoy a mix of these'
  ], 'Different people feel seen in different ways. There is no best answer.');
  single('How would you prefer to be recognized?', [
    'Privately, with no public announcement', 'A card or note delivered discreetly',
    'A small acknowledgment among colleagues', 'Publicly, if I approve it first'
  ], 'Your privacy and comfort matter.');

  section('✏️ 2. Classroom wishes', 'We want to help meet real needs without assuming every classroom needs the same things.');
  many('Which classroom essentials would make your day easier? (Choose any)', [
    'Pencils / pens', 'Copy paper / cardstock', 'Tissues / paper towels', 'Dry-erase markers / erasers',
    'Art / craft supplies', 'Notebooks / folders', 'Books / classroom reading', 'Storage / organization',
    'Manipulatives / hands-on learning supplies', 'Cleaning items permitted by the school',
    'Classroom snacks (school-approved)', 'Other (describe below)'
  ], 'Choose genuine priorities—not what you think a donor expects.');
  long('What THREE specific classroom items would help most this month?', 'Item, approximate quantity, and preferred specifications or sizes are helpful.');
  long('Is there a small classroom project, activity, or experience you would love to make possible?', 'Optional: This could be a hands-on lesson, student activity, art project, or something else meaningful.');

  section('💜 3. The person behind the classroom door', 'These questions are inspired by strengths-based appreciation: noticing what restores energy, sparks curiosity, and helps someone feel understood.');
  many('When you get a little time to yourself, what tends to bring you joy? (Choose any)', [
    'Reading', 'Gardening / plants', 'Music / concerts', 'Art / crafts', 'Cooking / baking',
    'Walking / outdoors', 'Movies / theater', 'Sports / games', 'Coffee / tea rituals',
    'Puzzles / games', 'Pets / animals', 'Trying new foods', 'Rest / quiet time', 'Other'
  ]);
  short('What is a small everyday treat you genuinely enjoy?', 'Favorite snack, drink, scent-free item, stationery, etc. Specifics are welcome.');
  long('If someone gave you a free hour to spend however you liked, what would you enjoy doing?', 'This is about what restores or delights you—not about what you ought to do.');
  long('What is something you are curious about or would love to try?', 'For example, a craft, hobby, local class, book genre, or new experience.');
  short('What little object or comfort helps make a demanding school day feel better?', 'Maybe a favorite mint, type of pen, mug, tea, notebook, or plant.');
  long('What is a meaningful, low-cost way somebody could brighten your day?', 'Think $0–$15; notes, creative gestures, small items, or simple treats count.');

  section('🌼 4. Thoughtfulness, comfort & boundaries', 'Good appreciation feels welcome to the recipient. It should never create an obligation.');
  long('Are there gifts, foods, scents, activities, or forms of recognition you would rather NOT receive?', 'Share only preferences needed to avoid unwanted gifts. You do not need to explain why.');
  single('Would you enjoy a small surprise, or would you prefer choosing from a wish list?', [
    'Surprises are lovely', 'I would rather choose', 'Either is fine'
  ]);
  single('Would you be comfortable with your approved wish list displayed publicly on a school bulletin board?', [
    'Yes, with my name', 'Yes, with a first name / approved display name only',
    'Only in a private PTO list', 'Please ask me before displaying anything'
  ], 'The school should confirm what it plans to publish and honor this preference.');
  long('Anything else that would help our volunteers appreciate you in a way that feels genuinely thoughtful?', 'Optional—please avoid personal or sensitive information.');

  section('🌳 5. A final reflection', 'Our aim is to make care reciprocal: supporting the adults who support students.');
  long('Complete this sentence, if you like: “I feel truly appreciated at school when…”', 'This gives our team a much better guide than guessing at a gift.');

  // Teacher responses are linked to a new, PRIVATE spreadsheet owned by the person running this script.
  const sheet = SpreadsheetApp.create('Apples of My Eyes — Teacher Survey Responses');
  form.setDestination(FormApp.DestinationType.SPREADSHEET, sheet.getId());

  console.log('FORM EDIT LINK: ' + form.getEditUrl());
  console.log('TEACHER RESPONSE LINK: ' + form.getPublishedUrl());
  console.log('PRIVATE RESPONSE SHEET: ' + sheet.getUrl());
  console.log('IMPORTANT: Review settings and question wording with your school before sharing the response link.');
}
