export function employeeEngagementQuiz(form: FormTs) {
form.setTitle(() => '📊 Employee Engagement Score: Is Your Team Thriving?');
// ========== STATE ==========
type CategoryKey = 'recognition' | 'growth' | 'leadership' | 'culture' | 'worklife';
const scores = form.state<Record<CategoryKey, number>>({
recognition: 0,
growth: 0,
leadership: 0,
culture: 0,
worklife: 0
});
// ========== SCORING FUNCTIONS ==========
const updateScore = (category: CategoryKey, points: number) => {
scores.update(current => ({
...current,
[category]: (current[category] || 0) + points
}));
};
const getTotalScore = () => {
const s = scores();
return (Object.values(s) as number[]).reduce((sum: number, val: number) => sum + val, 0);
};
const getMaxScore = () => 100;
const getScorePercentage = () => Math.round((getTotalScore() / getMaxScore()) * 100);
const getEngagementLevel = (): 'thriving' | 'engaged' | 'neutral' | 'disengaged' | 'critical' => {
const pct = getScorePercentage();
if (pct >= 80) return 'thriving';
if (pct >= 65) return 'engaged';
if (pct >= 50) return 'neutral';
if (pct >= 35) return 'disengaged';
return 'critical';
};
const getEngagementLabel = () => {
const level = getEngagementLevel();
const labels = {
thriving: 'Thriving Team',
engaged: 'Engaged Team',
neutral: 'Neutral Engagement',
disengaged: 'Disengaged Team',
critical: 'Critical - Immediate Action Needed'
};
return labels[level];
};
const getCategoryScore = (category: CategoryKey) => {
const s = scores();
const maxPerCategory = 20;
return Math.round((s[category] / maxPerCategory) * 100);
};
const getWeakestArea = (): CategoryKey => {
const s = scores();
const entries = Object.entries(s) as [CategoryKey, number][];
const sorted = entries.sort((a, b) => a[1] - b[1]);
return sorted[0]?.[0] || 'recognition';
};
const getCategoryLabel = (category: CategoryKey) => {
const labels: Record<CategoryKey, string> = {
recognition: 'Recognition & Appreciation',
growth: 'Growth & Development',
leadership: 'Leadership & Management',
culture: 'Team Culture',
worklife: 'Work-Life Balance'
};
return labels[category];
};
// ========== COMPLETION SCREEN ==========
form.configureCompletionScreen({
type: 'text',
title: '📊 Your Engagement Report Is Ready!',
message: () => `Your team engagement score is ${getScorePercentage()}% (${getEngagementLabel()}). Check your email for detailed insights and action recommendations.`
});
// ========== PAGES ==========
const pages = form.addPages('quiz-pages', { heightMode: 'current-page' });
// ========== PAGE 1: Recognition ==========
const page1 = pages.addPage('recognition', { mobileBreakpoint: 500 });
page1.addRow(row => {
row.addTextPanel('header1', {
label: 'Step 1 of 6: Recognition & Appreciation',
computedValue: () => 'How well does your organization recognize employees?',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page1.addSpacer({ height: '24px' });
page1.addRow(row => {
row.addRatingScale('recognitionFrequency', {
label: 'How often do employees receive recognition for their work?',
preset: 'likert-5',
lowLabel: 'Rarely',
highLabel: 'Very Often',
onValueChange: (v) => {
if (v) updateScore('recognition', v * 2);
}
});
});
page1.addRow(row => {
row.addRatingScale('recognitionMeaningful', {
label: 'How meaningful is the recognition employees receive?',
preset: 'likert-5',
lowLabel: 'Not meaningful',
highLabel: 'Very meaningful',
onValueChange: (v) => {
if (v) updateScore('recognition', v * 2);
}
});
});
// ========== PAGE 2: Growth ==========
const page2 = pages.addPage('growth', { mobileBreakpoint: 500 });
page2.addRow(row => {
row.addTextPanel('header2', {
label: 'Step 2 of 6: Growth & Development',
computedValue: () => 'Evaluate learning and career opportunities',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page2.addSpacer({ height: '24px' });
page2.addRow(row => {
row.addRadioButton('learningOpportunities', {
label: 'What learning opportunities are available?',
options: [
{ id: 'comprehensive', name: 'Comprehensive L&D program with budget' },
{ id: 'some', name: 'Some training available on request' },
{ id: 'limited', name: 'Limited to job-specific training' },
{ id: 'none', name: 'No formal learning programs' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'comprehensive') updateScore('growth', 10);
else if (v === 'some') updateScore('growth', 7);
else if (v === 'limited') updateScore('growth', 4);
else if (v === 'none') updateScore('growth', 1);
}
});
});
page2.addRow(row => {
row.addRatingScale('careerPath', {
label: 'How clear are career advancement paths?',
preset: 'likert-5',
lowLabel: 'Very unclear',
highLabel: 'Very clear',
onValueChange: (v) => {
if (v) updateScore('growth', v * 2);
}
});
});
// ========== PAGE 3: Leadership ==========
const page3 = pages.addPage('leadership', { mobileBreakpoint: 500 });
page3.addRow(row => {
row.addTextPanel('header3', {
label: 'Step 3 of 6: Leadership & Management',
computedValue: () => 'Assess management effectiveness',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page3.addSpacer({ height: '24px' });
page3.addRow(row => {
row.addMatrixQuestion('leadershipQualities', {
label: 'Rate your leadership team on:',
rows: [
{ id: 'communication', label: 'Clear communication', isRequired: true },
{ id: 'trust', label: 'Building trust', isRequired: true },
{ id: 'feedback', label: 'Giving feedback', isRequired: true },
{ id: 'support', label: 'Supporting team', isRequired: true }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
onValueChange: (v) => {
if (!v) return;
let points = 0;
Object.values(v).forEach(rating => {
if (rating === 'excellent') points += 5;
else if (rating === 'good') points += 4;
else if (rating === 'fair') points += 2;
else if (rating === 'poor') points += 1;
});
updateScore('leadership', Math.min(points, 20));
}
});
});
// ========== PAGE 4: Culture ==========
const page4 = pages.addPage('culture', { mobileBreakpoint: 500 });
page4.addRow(row => {
row.addTextPanel('header4', {
label: 'Step 4 of 6: Team Culture',
computedValue: () => 'Evaluate workplace culture and collaboration',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page4.addSpacer({ height: '24px' });
page4.addRow(row => {
row.addSuggestionChips('cultureStrengths', {
label: 'Select cultural strengths present in your organization:',
suggestions: [
{ id: 'collaboration', name: '🤝 Collaboration' },
{ id: 'innovation', name: '💡 Innovation' },
{ id: 'transparency', name: '👁️ Transparency' },
{ id: 'diversity', name: '🌈 Diversity & Inclusion' },
{ id: 'fun', name: '🎉 Fun & Social' },
{ id: 'purpose', name: '🎯 Shared Purpose' }
],
onValueChange: (v) => {
const count = (v || []).length;
updateScore('culture', Math.min(count * 3, 15));
}
});
});
page4.addRow(row => {
row.addRatingScale('belonging', {
label: 'How strong is employees\' sense of belonging?',
preset: 'likert-5',
lowLabel: 'Very weak',
highLabel: 'Very strong',
onValueChange: (v) => {
if (v) updateScore('culture', v);
}
});
});
// ========== PAGE 5: Work-Life Balance ==========
const page5 = pages.addPage('worklife', { mobileBreakpoint: 500 });
page5.addRow(row => {
row.addTextPanel('header5', {
label: 'Step 5 of 6: Work-Life Balance',
computedValue: () => 'Assess flexibility and wellbeing support',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page5.addSpacer({ height: '24px' });
page5.addRow(row => {
row.addRadioButton('flexibility', {
label: 'What flexibility options are available?',
options: [
{ id: 'full', name: 'Full flexibility (remote, flexible hours, unlimited PTO)' },
{ id: 'hybrid', name: 'Hybrid model with some flexibility' },
{ id: 'limited', name: 'Limited flexibility (occasional WFH)' },
{ id: 'none', name: 'Traditional office, fixed hours' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'full') updateScore('worklife', 10);
else if (v === 'hybrid') updateScore('worklife', 7);
else if (v === 'limited') updateScore('worklife', 4);
else if (v === 'none') updateScore('worklife', 2);
}
});
});
page5.addRow(row => {
row.addRatingScale('burnout', {
label: 'How well does leadership address burnout concerns?',
preset: 'likert-5',
lowLabel: 'Very poorly',
highLabel: 'Very well',
onValueChange: (v) => {
if (v) updateScore('worklife', v * 2);
}
});
});
// ========== PAGE 6: Results ==========
const page6 = pages.addPage('results', { mobileBreakpoint: 500 });
page6.addRow(row => {
row.addTextPanel('header6', {
label: 'Step 6 of 6: Your Engagement Score',
computedValue: () => 'See how your team is doing',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page6.addSpacer({ height: '24px' });
page6.addRow(row => {
row.addTextPanel('mainScore', {
label: 'Team Engagement Score',
computedValue: () => `${getScorePercentage()}%`,
customStyles: () => {
const score = getScorePercentage();
return {
fontSize: '56px',
fontWeight: 'bold',
textAlign: 'center',
padding: '20px',
borderRadius: '12px',
color: score >= 65 ? '#059669' : score >= 50 ? '#ca8a04' : '#dc2626',
background: score >= 65 ? '#ecfdf5' : score >= 50 ? '#fefce8' : '#fef2f2'
};
}
});
});
page6.addRow(row => {
row.addTextPanel('engagementLevel', {
label: '',
computedValue: () => `🏆 ${getEngagementLabel()}`,
customStyles: { textAlign: 'center', fontSize: '24px', fontWeight: 'bold', padding: '10px' }
});
});
const categorySection = page6.addSubform('categoryBreakdown', {
title: '📊 Category Breakdown (click to expand)',
isCollapsible: true,
customStyles: { background: '#f9fafb', borderRadius: '8px', marginTop: '20px' }
});
categorySection.addRow(row => {
row.addTextPanel('recognitionScore', {
label: '🏅 Recognition',
computedValue: () => `${getCategoryScore('recognition')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('recognition') >= 60 ? '#ecfdf5' : '#fef2f2',
borderRadius: '4px'
})
});
row.addTextPanel('growthScore', {
label: '📈 Growth',
computedValue: () => `${getCategoryScore('growth')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('growth') >= 60 ? '#ecfdf5' : '#fef2f2',
borderRadius: '4px'
})
});
});
categorySection.addRow(row => {
row.addTextPanel('leadershipScore', {
label: '👔 Leadership',
computedValue: () => `${getCategoryScore('leadership')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('leadership') >= 60 ? '#ecfdf5' : '#fef2f2',
borderRadius: '4px'
})
});
row.addTextPanel('cultureScore', {
label: '🤝 Culture',
computedValue: () => `${getCategoryScore('culture')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('culture') >= 60 ? '#ecfdf5' : '#fef2f2',
borderRadius: '4px'
})
});
});
categorySection.addRow(row => {
row.addTextPanel('worklifeScore', {
label: '⚖️ Work-Life',
computedValue: () => `${getCategoryScore('worklife')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('worklife') >= 60 ? '#ecfdf5' : '#fef2f2',
borderRadius: '4px'
})
});
row.addEmpty('1fr');
});
page6.addRow(row => {
row.addTextPanel('priorityArea', {
label: '🎯 Priority Focus Area',
computedValue: () => `Focus on ${getCategoryLabel(getWeakestArea())} to improve overall engagement.`,
customStyles: { padding: '15px', background: '#fef3c7', borderRadius: '8px', marginTop: '15px' }
});
});
// ========== PAGE 7: Lead Capture ==========
const page7 = pages.addPage('lead-capture', { mobileBreakpoint: 500 });
page7.addRow(row => {
row.addTextPanel('header7', {
label: 'Get Your Full Engagement Report',
computedValue: () => 'Receive detailed insights and action recommendations',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page7.addSpacer({ height: '24px' });
page7.addRow(row => {
row.addTextbox('name', { label: 'Your Name', isRequired: true, placeholder: 'Jane Smith' }, '1fr');
row.addEmail('email', { label: 'Work Email', isRequired: true, placeholder: 'jane@company.com' }, '1fr');
});
page7.addRow(row => {
row.addTextbox('company', { label: 'Company Name', isRequired: true, placeholder: 'Acme Inc.' }, '1fr');
row.addDropdown('companySize', {
label: 'Company Size',
options: [
{ id: 'small', name: '1-50 employees' },
{ id: 'medium', name: '51-200 employees' },
{ id: 'large', name: '201-1000 employees' },
{ id: 'enterprise', name: '1000+ employees' }
]
}, '1fr');
});
page7.addRow(row => {
row.addDropdown('role', {
label: 'Your Role',
options: [
{ id: 'hr', name: 'HR / People Ops' },
{ id: 'manager', name: 'Manager / Team Lead' },
{ id: 'exec', name: 'Executive / C-Level' },
{ id: 'other', name: 'Other' }
]
}, '1fr');
row.addEmpty('1fr');
});
page7.addRow(row => {
row.addCheckboxList('consent', {
options: [
{ id: 'report', name: '📄 Send me the detailed engagement report', isRequired: true },
{ id: 'benchmark', name: '📊 Include industry benchmarks' },
{ id: 'consultation', name: '📞 I\'d like to discuss engagement strategies' }
],
defaultValue: ['report'],
orientation: 'vertical'
});
});
// ========== SUBMIT BUTTON ==========
form.configureSubmitButton({
label: () => `📊 Get My Report (Score: ${getScorePercentage()}%)`
});
// ========== PDF REPORT ==========
form.configurePdf('engagement-report', pdf => {
pdf.configure({
filename: 'employee-engagement-report.pdf',
pageSize: 'A4',
allowUserDownload: true,
downloadButtonLabel: '📊 Download Engagement Report',
header: {
title: 'Employee Engagement Assessment',
subtitle: 'Team Health Analysis'
},
footer: {
text: 'Generated by FormTs',
showPageNumbers: true
}
});
pdf.addSection('Executive Summary', section => {
section.addRow(row => {
row.addField('Overall Score', `${getScorePercentage()}%`);
row.addField('Status', getEngagementLabel());
});
});
pdf.addSection('Category Scores', section => {
section.addTable(
['Category', 'Score', 'Status'],
[
['Recognition', `${getCategoryScore('recognition')}%`, getCategoryScore('recognition') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['Growth', `${getCategoryScore('growth')}%`, getCategoryScore('growth') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['Leadership', `${getCategoryScore('leadership')}%`, getCategoryScore('leadership') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['Culture', `${getCategoryScore('culture')}%`, getCategoryScore('culture') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['Work-Life', `${getCategoryScore('worklife')}%`, getCategoryScore('worklife') >= 60 ? '✅ Good' : '⚠️ Needs Work']
]
);
});
pdf.addPageBreak();
pdf.addSection('Recommendations', section => {
section.addText(`Priority Focus: ${getCategoryLabel(getWeakestArea())}`);
section.addSpacer(10);
section.addText('1. Conduct regular pulse surveys to track engagement');
section.addText('2. Implement recognition programs (peer-to-peer, manager)');
section.addText('3. Create clear career development paths');
section.addText('4. Train managers on effective feedback');
section.addText('5. Review and improve flexibility policies');
});
});
form.configureSubmitBehavior({ sendToServer: true });
}