export function cybersecurityAssessmentQuiz(form: FormTs) {
form.setTitle(() => '🔒 How Secure Is Your Business?');
// ============ SCORING SYSTEM ============
const scores = form.state<Record<string, number>>({});
const updateScore = (category: string, points: number) => {
scores.update(current => ({ ...current, [category]: points }));
};
const getTotalScore = () => {
const s = scores();
return Object.values(s).reduce((sum, val) => sum + (val || 0), 0);
};
const getMaxScore = () => 100; // Max possible score
const getScorePercentage = () => Math.round((getTotalScore() / getMaxScore()) * 100);
const getRiskLevel = (): 'critical' | 'high' | 'medium' | 'low' => {
const pct = getScorePercentage();
if (pct >= 80) return 'low';
if (pct >= 60) return 'medium';
if (pct >= 40) return 'high';
return 'critical';
};
const getRiskLabel = () => {
const level = getRiskLevel();
const labels = {
critical: '🚨 CRITICAL RISK',
high: '⚠️ HIGH RISK',
medium: '⚡ MEDIUM RISK',
low: '✅ LOW RISK'
};
return labels[level];
};
const getRiskColor = () => {
const level = getRiskLevel();
const colors = {
critical: '#dc2626',
high: '#ea580c',
medium: '#ca8a04',
low: '#16a34a'
};
return colors[level];
};
// ============ COMPLETION SCREEN ============
form.configureCompletionScreen({
type: 'text',
title: () => `${getRiskLabel()}`,
message: () => {
const pct = getScorePercentage();
const level = getRiskLevel();
const messages = {
critical: `Your security score is ${pct}%. Your business faces serious cybersecurity vulnerabilities that require immediate attention. Download your detailed report to see specific recommendations.`,
high: `Your security score is ${pct}%. Several significant gaps in your security posture need addressing. Review your personalized report for priority actions.`,
medium: `Your security score is ${pct}%. You have a foundation in place but there's room for improvement. Your report contains targeted recommendations.`,
low: `Excellent! Your security score is ${pct}%. Your business demonstrates strong security practices. Review your report to maintain and enhance your posture.`
};
return messages[level];
}
});
// ============ PAGES SETUP ============
const pages = form.addPages('quiz-pages', {
heightMode: 'current-page'
});
// ============ PAGE 1: Company Profile ============
const page1 = pages.addPage('company-profile', { mobileBreakpoint: 500 });
page1.addRow(row => {
row.addTextPanel('header1', {
label: 'Step 1 of 8: Company Profile',
computedValue: () => 'Tell us about your organization to customize the assessment',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page1.addSpacer({ height: '24px' });
page1.addRow(row => {
row.addDropdown('companySize', {
label: 'Company Size',
isRequired: true,
options: [
{ id: '1-10', name: '1-10 employees' },
{ id: '11-50', name: '11-50 employees' },
{ id: '51-200', name: '51-200 employees' },
{ id: '201-500', name: '201-500 employees' },
{ id: '500+', name: '500+ employees' }
],
placeholder: 'Select company size'
}, '1fr');
row.addDropdown('industry', {
label: 'Industry',
isRequired: true,
options: [
{ id: 'healthcare', name: '🏥 Healthcare' },
{ id: 'finance', name: '🏦 Finance & Banking' },
{ id: 'retail', name: '🛒 Retail & E-commerce' },
{ id: 'tech', name: '💻 Technology' },
{ id: 'manufacturing', name: '🏭 Manufacturing' },
{ id: 'professional', name: '💼 Professional Services' },
{ id: 'education', name: '🎓 Education' },
{ id: 'government', name: '🏛️ Government' },
{ id: 'other', name: '📦 Other' }
],
placeholder: 'Select industry'
}, '1fr');
});
page1.addRow(row => {
row.addCheckboxList('dataTypes', {
label: 'What types of sensitive data do you handle?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'pii', name: '👤 Personal Identifiable Information (PII)' },
{ id: 'financial', name: '💳 Financial/Payment Data' },
{ id: 'health', name: '🏥 Health Records (PHI)' },
{ id: 'intellectual', name: '🔬 Intellectual Property' },
{ id: 'customer', name: '📊 Customer Business Data' },
{ id: 'employee', name: '👥 Employee Records' }
],
min: 1
});
});
// Conditional compliance section - only visible for regulated industries
const complianceSection = page1.addSubform('complianceSection', {
title: '⚖️ Compliance Requirements',
isVisible: () => {
const industry = page1.dropdown('industry')?.value();
return ['healthcare', 'finance', 'government'].includes(industry || '');
},
isCollapsible: false,
customStyles: {
marginTop: '1rem',
padding: '15px',
background: '#fef2f2',
borderRadius: '8px',
border: '2px solid #fca5a5'
}
});
complianceSection.addRow(row => {
row.addTextPanel('complianceWarning', {
computedValue: () => {
const industry = page1.dropdown('industry')?.value();
if (industry === 'healthcare') return '🏥 HIPAA compliance is mandatory. Patient data breaches can result in fines up to $1.5M per violation.';
if (industry === 'finance') return '🏦 PCI-DSS, SOX, and GLBA regulations apply. Financial data requires enhanced protection.';
if (industry === 'government') return '🏛️ FedRAMP, FISMA, and NIST frameworks may apply. Government data requires strict controls.';
return '';
},
customStyles: {
fontSize: '0.9rem',
color: '#991b1b',
fontWeight: '500'
}
});
});
complianceSection.addRow(row => {
row.addCheckboxList('complianceAwareness', {
label: 'Which compliance frameworks are you familiar with?',
orientation: 'horizontal',
options: () => {
const industry = page1.dropdown('industry')?.value();
if (industry === 'healthcare') return [
{ id: 'hipaa', name: 'HIPAA' },
{ id: 'hitech', name: 'HITECH' },
{ id: 'hitrust', name: 'HITRUST' }
];
if (industry === 'finance') return [
{ id: 'pci', name: 'PCI-DSS' },
{ id: 'sox', name: 'SOX' },
{ id: 'glba', name: 'GLBA' }
];
if (industry === 'government') return [
{ id: 'fedramp', name: 'FedRAMP' },
{ id: 'fisma', name: 'FISMA' },
{ id: 'nist', name: 'NIST' }
];
return [];
}
});
});
// ============ PAGE 2: Access Control ============
const page2 = pages.addPage('access-control', { mobileBreakpoint: 500 });
page2.addRow(row => {
row.addTextPanel('header2', {
label: 'Step 2 of 8: Access Control',
computedValue: () => 'How do you manage who can access your systems?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page2.addSpacer({ height: '24px' });
page2.addRow(row => {
row.addMatrixQuestion('accessControlMatrix', {
label: 'Rate your implementation of these access control measures:',
isRequired: true,
rows: [
{ id: 'mfa', label: 'Multi-Factor Authentication (MFA)', description: 'Two or more verification steps' },
{ id: 'password', label: 'Password Policy', description: 'Complexity, rotation, length requirements' },
{ id: 'accessReview', label: 'Access Permission Reviews', description: 'Regular audits of user permissions' }
],
columns: [
{ id: 'none', label: 'Not Implemented' },
{ id: 'partial', label: 'Partial' },
{ id: 'basic', label: 'Basic' },
{ id: 'full', label: 'Fully Implemented' }
],
selectionMode: 'single',
striped: true,
fullWidth: true,
onValueChange: (val) => {
if (!val) return;
const pointsMap: Record<string, Record<string, number>> = {
mfa: { none: 0, partial: 3, basic: 6, full: 10 },
password: { none: 0, partial: 1, basic: 3, full: 5 },
accessReview: { none: 0, partial: 1, basic: 3, full: 5 }
};
for (const [row, col] of Object.entries(val)) {
if (col && pointsMap[row]) {
updateScore(row, pointsMap[row][col as string] || 0);
}
}
}
});
});
// Score display for this section
page2.addRow(row => {
row.addTextPanel('accessScore', {
computedValue: () => {
const s = scores();
const sectionScore = (s['mfa'] || 0) + (s['password'] || 0) + (s['accessReview'] || 0);
const color = sectionScore >= 15 ? '#059669' : sectionScore >= 10 ? '#ca8a04' : '#dc2626';
return `🔐 Access Control Score: ${sectionScore}/20`;
},
customStyles: () => {
const s = scores();
const sectionScore = (s['mfa'] || 0) + (s['password'] || 0) + (s['accessReview'] || 0);
const color = sectionScore >= 15 ? '#059669' : sectionScore >= 10 ? '#ca8a04' : '#dc2626';
return {
fontSize: '1rem',
fontWeight: '600',
color: color,
textAlign: 'center',
padding: '12px',
background: sectionScore >= 15 ? '#ecfdf5' : sectionScore >= 10 ? '#fefce8' : '#fef2f2',
borderRadius: '8px',
marginTop: '1rem',
border: `2px solid ${color}`
};
}
});
});
// ============ PAGE 3: Data Protection ============
const page3 = pages.addPage('data-protection', { mobileBreakpoint: 500 });
page3.addRow(row => {
row.addTextPanel('header3', {
label: 'Step 3 of 8: Data Protection',
computedValue: () => 'How do you protect your sensitive data?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page3.addSpacer({ height: '24px' });
page3.addRow(row => {
row.addRadioButton('encryption', {
label: 'Do you encrypt sensitive data?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'full', name: '🔒 Yes, at rest AND in transit' },
{ id: 'transit', name: '🔄 Only in transit (HTTPS/TLS)' },
{ id: 'rest', name: '💾 Only at rest' },
{ id: 'none', name: '❌ No encryption' }
],
onValueChange: (val) => {
const points = { full: 8, transit: 4, rest: 4, none: 0 };
updateScore('encryption', points[val as keyof typeof points] || 0);
}
});
});
page3.addRow(row => {
row.addRadioButton('backups', {
label: 'How do you handle data backups?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'auto-offsite', name: '☁️ Automated daily backups, offsite/cloud storage, tested regularly' },
{ id: 'auto-onsite', name: '💾 Automated backups, same location' },
{ id: 'manual', name: '👤 Manual backups occasionally' },
{ id: 'none', name: '❌ No backup strategy' }
],
onValueChange: (val) => {
const points = { 'auto-offsite': 7, 'auto-onsite': 4, manual: 2, none: 0 };
updateScore('backups', points[val as keyof typeof points] || 0);
}
});
});
page3.addRow(row => {
row.addRadioButton('dataClassification', {
label: 'Do you classify data by sensitivity level?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'formal', name: '📋 Yes, formal classification system with handling procedures' },
{ id: 'informal', name: '📝 Informal understanding of sensitive vs non-sensitive' },
{ id: 'none', name: '❌ No data classification' }
],
onValueChange: (val) => {
const points = { formal: 5, informal: 2, none: 0 };
updateScore('classification', points[val as keyof typeof points] || 0);
}
});
});
page3.addRow(row => {
row.addTextPanel('dataScore', {
computedValue: () => {
const s = scores();
const sectionScore = (s['encryption'] || 0) + (s['backups'] || 0) + (s['classification'] || 0);
return `💾 Data Protection Score: ${sectionScore}/20`;
},
customStyles: {
fontSize: '1rem',
fontWeight: '600',
color: '#1e40af',
textAlign: 'center',
padding: '12px',
background: '#dbeafe',
borderRadius: '8px',
marginTop: '1rem'
}
});
});
// ============ PAGE 4: Network Security ============
const page4 = pages.addPage('network-security', { mobileBreakpoint: 500 });
page4.addRow(row => {
row.addTextPanel('header4', {
label: 'Step 4 of 8: Network Security',
computedValue: () => 'How protected is your network infrastructure?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page4.addSpacer({ height: '24px' });
page4.addRow(row => {
row.addRadioButton('firewall', {
label: 'What firewall protection do you have?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'ngfw', name: '🛡️ Next-gen firewall with intrusion prevention' },
{ id: 'standard', name: '🔥 Standard business firewall' },
{ id: 'basic', name: '🖥️ Basic router firewall only' },
{ id: 'none', name: '❌ No firewall' }
],
onValueChange: (val) => {
const points = { ngfw: 7, standard: 5, basic: 2, none: 0 };
updateScore('firewall', points[val as keyof typeof points] || 0);
}
});
});
page4.addRow(row => {
row.addRadioButton('wifi', {
label: 'How is your WiFi secured?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'wpa3-segmented', name: '📶 WPA3, separate guest/IoT networks, hidden SSID' },
{ id: 'wpa2-segmented', name: '📡 WPA2, separate guest network' },
{ id: 'wpa2-shared', name: '🔐 WPA2, single network for all' },
{ id: 'weak', name: '⚠️ WEP or no password' }
],
onValueChange: (val) => {
const points = { 'wpa3-segmented': 6, 'wpa2-segmented': 4, 'wpa2-shared': 2, weak: 0 };
updateScore('wifi', points[val as keyof typeof points] || 0);
}
});
});
page4.addRow(row => {
row.addRadioButton('remoteAccess', {
label: 'How do remote employees access company resources?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'vpn-mfa', name: '🔒 VPN with MFA and endpoint security' },
{ id: 'vpn', name: '🌐 VPN only' },
{ id: 'direct', name: '🔓 Direct access (RDP, etc.)' },
{ id: 'none', name: '🚫 No remote access allowed' }
],
onValueChange: (val) => {
const points = { 'vpn-mfa': 7, vpn: 4, direct: 1, none: 5 };
updateScore('remote', points[val as keyof typeof points] || 0);
}
});
});
page4.addRow(row => {
row.addTextPanel('networkScore', {
computedValue: () => {
const s = scores();
const sectionScore = (s['firewall'] || 0) + (s['wifi'] || 0) + (s['remote'] || 0);
return `🌐 Network Security Score: ${sectionScore}/20`;
},
customStyles: {
fontSize: '1rem',
fontWeight: '600',
color: '#1e40af',
textAlign: 'center',
padding: '12px',
background: '#dbeafe',
borderRadius: '8px',
marginTop: '1rem'
}
});
});
// ============ PAGE 5: Employee Training ============
const page5 = pages.addPage('employee-training', { mobileBreakpoint: 500 });
page5.addRow(row => {
row.addTextPanel('header5', {
label: 'Step 5 of 8: Security Awareness',
computedValue: () => 'Human error causes 95% of breaches. How trained is your team?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page5.addSpacer({ height: '24px' });
page5.addRow(row => {
row.addRatingScale('securityTraining', {
label: 'How comprehensive is your security awareness training?',
isRequired: true,
preset: 'custom',
min: 0,
max: 4,
lowLabel: 'None',
highLabel: 'Regular & comprehensive',
size: 'md',
alignment: 'center',
variant: 'segmented',
onValueChange: (val) => {
if (val == null) return;
const points = [0, 2, 4, 6, 8]; // Maps 0-4 to point values
updateScore('training', points[val] || 0);
}
});
});
page5.addRow(row => {
row.addTextPanel('trainingHint', {
computedValue: () => {
const val = page5.ratingScale('securityTraining')?.value();
if (val === 0) return '0 = No training program';
if (val === 1) return '1 = Onboarding only';
if (val === 2) return '2 = Annual training';
if (val === 3) return '3 = Bi-annual training';
if (val === 4) return '4 = Quarterly+ with testing';
return 'Select your training frequency';
},
customStyles: {
fontSize: '0.8rem',
color: '#6b7280',
textAlign: 'center',
marginTop: '0.25rem'
}
});
});
page5.addRow(row => {
row.addRadioButton('phishingTests', {
label: 'Do you conduct phishing simulation tests?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'regular', name: '🎣 Yes, regular simulated phishing campaigns' },
{ id: 'occasional', name: '📧 Occasionally' },
{ id: 'never', name: '❌ No phishing tests' }
],
onValueChange: (val) => {
const points = { regular: 7, occasional: 3, never: 0 };
updateScore('phishing', points[val as keyof typeof points] || 0);
}
});
});
page5.addRow(row => {
row.addRadioButton('reportingCulture', {
label: 'Do employees know how to report suspicious activity?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'clear', name: '✅ Clear process, employees actively report threats' },
{ id: 'exists', name: '📋 Process exists but rarely used' },
{ id: 'informal', name: '💬 Informal (just tell IT)' },
{ id: 'none', name: '❌ No reporting process' }
],
onValueChange: (val) => {
const points = { clear: 5, exists: 3, informal: 1, none: 0 };
updateScore('reporting', points[val as keyof typeof points] || 0);
}
});
});
page5.addRow(row => {
row.addTextPanel('trainingScore', {
computedValue: () => {
const s = scores();
const sectionScore = (s['training'] || 0) + (s['phishing'] || 0) + (s['reporting'] || 0);
return `👥 Security Awareness Score: ${sectionScore}/20`;
},
customStyles: {
fontSize: '1rem',
fontWeight: '600',
color: '#1e40af',
textAlign: 'center',
padding: '12px',
background: '#dbeafe',
borderRadius: '8px',
marginTop: '1rem'
}
});
});
// ============ PAGE 6: Incident Response ============
const page6 = pages.addPage('incident-response', { mobileBreakpoint: 500 });
page6.addRow(row => {
row.addTextPanel('header6', {
label: 'Step 6 of 8: Incident Response',
computedValue: () => 'Are you prepared when (not if) a security incident occurs?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page6.addSpacer({ height: '24px' });
page6.addRow(row => {
row.addRadioButton('incidentPlan', {
label: 'Do you have a documented incident response plan?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'tested', name: '📋 Yes, documented and tested/drilled regularly' },
{ id: 'documented', name: '📄 Yes, documented but not tested' },
{ id: 'informal', name: '💭 Informal understanding of what to do' },
{ id: 'none', name: '❌ No incident response plan' }
],
onValueChange: (val) => {
const points = { tested: 8, documented: 5, informal: 2, none: 0 };
updateScore('incidentPlan', points[val as keyof typeof points] || 0);
}
});
});
page6.addRow(row => {
row.addRadioButton('monitoring', {
label: 'Do you have security monitoring and logging?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'siem', name: '🖥️ SIEM/SOC with 24/7 monitoring' },
{ id: 'logging', name: '📊 Centralized logging with alerts' },
{ id: 'basic', name: '📝 Basic system logs' },
{ id: 'none', name: '❌ No monitoring' }
],
onValueChange: (val) => {
const points = { siem: 7, logging: 5, basic: 2, none: 0 };
updateScore('monitoring', points[val as keyof typeof points] || 0);
}
});
});
page6.addRow(row => {
row.addRadioButton('cyberInsurance', {
label: 'Do you have cyber insurance?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'comprehensive', name: '🛡️ Yes, comprehensive cyber liability coverage' },
{ id: 'basic', name: '📜 Yes, basic coverage' },
{ id: 'considering', name: '🤔 Currently evaluating options' },
{ id: 'none', name: '❌ No cyber insurance' }
],
onValueChange: (val) => {
const points = { comprehensive: 5, basic: 3, considering: 1, none: 0 };
updateScore('insurance', points[val as keyof typeof points] || 0);
}
});
});
page6.addRow(row => {
row.addTextPanel('incidentScore', {
computedValue: () => {
const s = scores();
const sectionScore = (s['incidentPlan'] || 0) + (s['monitoring'] || 0) + (s['insurance'] || 0);
return `🚨 Incident Response Score: ${sectionScore}/20`;
},
customStyles: {
fontSize: '1rem',
fontWeight: '600',
color: '#1e40af',
textAlign: 'center',
padding: '12px',
background: '#dbeafe',
borderRadius: '8px',
marginTop: '1rem'
}
});
});
// ============ PAGE 7: Results & Lead Capture ============
const page7 = pages.addPage('results', { mobileBreakpoint: 500 });
page7.addRow(row => {
row.addTextPanel('header7', {
label: 'Step 7 of 8: Your Results',
computedValue: () => 'Your personalized security assessment results',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page7.addSpacer({ height: '24px' });
// ============ FINAL SCORE SUMMARY ============
page7.addRow(row => {
row.addTextPanel('finalScoreLabel', {
label: '📊 Your Security Assessment Results',
computedValue: () => '',
customStyles: {
fontSize: '1.2rem',
fontWeight: '700',
textAlign: 'center'
}
});
});
page7.addRow(row => {
row.addTextPanel('finalRiskLevel', {
computedValue: () => getRiskLabel(),
customStyles: {
fontSize: '1.5rem',
fontWeight: '800',
textAlign: 'center',
color: getRiskColor(),
padding: '15px',
background: '#f9fafb',
borderRadius: '12px',
border: `3px solid ${getRiskColor()}`
}
});
});
page7.addRow(row => {
row.addTextPanel('scoreBreakdown', {
computedValue: () => {
const total = getTotalScore();
const pct = getScorePercentage();
return `Total Score: ${total}/${getMaxScore()} (${pct}%)`;
},
customStyles: {
fontSize: '1.1rem',
fontWeight: '600',
textAlign: 'center',
color: '#374151',
marginTop: '10px'
}
});
});
page7.addRow(row => {
row.addTextPanel('recommendation', {
computedValue: () => {
const level = getRiskLevel();
const recommendations = {
critical: '🚨 Immediate action required. Your business is highly vulnerable to cyber attacks. Submit the form to receive your detailed security improvement roadmap.',
high: '⚠️ Significant improvements needed. Several critical gaps put your business at risk. Get your personalized remediation plan.',
medium: '⚡ Room for improvement. You have foundations in place but gaps remain. Review your detailed recommendations.',
low: '✅ Strong security posture! Maintain vigilance and consider advanced protections. Download your maintenance checklist.'
};
return recommendations[level];
},
customStyles: {
fontSize: '0.95rem',
color: '#4b5563',
textAlign: 'center',
padding: '15px',
background: '#f3f4f6',
borderRadius: '8px',
marginTop: '15px',
lineHeight: '1.5'
}
});
});
// Collapsible detailed breakdown
const detailsSection = page7.addSubform('detailsBreakdown', {
title: '📊 Detailed Score Breakdown (click to expand)',
isCollapsible: true,
customStyles: {
marginTop: '1rem',
background: '#f9fafb',
borderRadius: '8px'
}
});
detailsSection.addRow(row => {
row.addTextPanel('accessDetail', {
label: '🔐 Access Control',
computedValue: () => {
const s = scores();
const score = (s['mfa'] || 0) + (s['password'] || 0) + (s['accessReview'] || 0);
return `${score}/20 points`;
},
customStyles: {
fontSize: '0.9rem',
padding: '8px 12px',
background: '#dbeafe',
borderRadius: '6px'
}
}, '1fr');
row.addTextPanel('dataDetail', {
label: '💾 Data Protection',
computedValue: () => {
const s = scores();
const score = (s['encryption'] || 0) + (s['backups'] || 0) + (s['classification'] || 0);
return `${score}/20 points`;
},
customStyles: {
fontSize: '0.9rem',
padding: '8px 12px',
background: '#dbeafe',
borderRadius: '6px'
}
}, '1fr');
});
detailsSection.addRow(row => {
row.addTextPanel('networkDetail', {
label: '🌐 Network Security',
computedValue: () => {
const s = scores();
const score = (s['firewall'] || 0) + (s['wifi'] || 0) + (s['remote'] || 0);
return `${score}/20 points`;
},
customStyles: {
fontSize: '0.9rem',
padding: '8px 12px',
background: '#dbeafe',
borderRadius: '6px'
}
}, '1fr');
row.addTextPanel('trainingDetail', {
label: '👥 Security Awareness',
computedValue: () => {
const s = scores();
const score = (s['training'] || 0) + (s['phishing'] || 0) + (s['reporting'] || 0);
return `${score}/20 points`;
},
customStyles: {
fontSize: '0.9rem',
padding: '8px 12px',
background: '#dbeafe',
borderRadius: '6px'
}
}, '1fr');
});
detailsSection.addRow(row => {
row.addTextPanel('incidentDetail', {
label: '🚨 Incident Response',
computedValue: () => {
const s = scores();
const score = (s['incidentPlan'] || 0) + (s['monitoring'] || 0) + (s['insurance'] || 0);
return `${score}/20 points`;
},
customStyles: {
fontSize: '0.9rem',
padding: '8px 12px',
background: '#dbeafe',
borderRadius: '6px'
}
}, '1fr');
row.addEmpty('1fr');
});
// ============ PAGE 8: Lead Capture ============
const page8 = pages.addPage('lead-capture', { mobileBreakpoint: 500 });
page8.addRow(row => {
row.addTextPanel('header8', {
label: 'Step 8 of 8: Get Your Report',
computedValue: () => 'Enter your details to receive your personalized security report',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page8.addSpacer({ height: '24px' });
page8.addRow(row => {
row.addTextPanel('leadCapture', {
label: '📧 Get Your Detailed Security Report',
computedValue: () => 'Enter your details to receive a comprehensive PDF report with personalized recommendations',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280'
}
});
});
page8.addRow(row => {
row.addTextbox('name', {
label: 'Your Name',
isRequired: true,
placeholder: 'John Smith'
}, '1fr');
row.addEmail('email', {
label: 'Work Email',
isRequired: true,
placeholder: 'john@company.com'
}, '1fr');
});
page8.addRow(row => {
row.addTextbox('company', {
label: 'Company Name',
placeholder: 'Acme Inc.'
}, '1fr');
row.addTextbox('phone', {
label: 'Phone (optional)',
placeholder: '+1 (555) 123-4567'
}, '1fr');
});
page8.addRow(row => {
row.addCheckboxList('consent', {
options: [
{
id: 'report',
name: '📄 Send me the detailed PDF security report',
isRequired: true
},
{
id: 'tips',
name: '💡 Send me weekly security tips and updates'
},
{
id: 'consultation',
name: '📞 I\'d like a free 15-min security consultation'
}
],
defaultValue: ['report'],
orientation: 'vertical'
});
});
// ============ PDF REPORT ============
form.configurePdf('security-report', pdf => {
pdf.configure({
filename: 'cybersecurity-assessment-report.pdf',
pageSize: 'A4',
allowUserDownload: true,
downloadButtonLabel: '📄 Download Security Report',
header: {
title: 'Cybersecurity Risk Assessment Report',
subtitle: 'Confidential Security Analysis'
},
footer: {
text: 'Generated by FormTs Security Assessment Tool',
showPageNumbers: true
}
});
pdf.addSection('Executive Summary', section => {
section.addRow(row => {
row.addField('Overall Risk Level', getRiskLabel());
row.addField('Security Score', `${getScorePercentage()}%`);
});
section.addRow(row => {
row.addField('Assessment Date', new Date().toLocaleDateString());
row.addField('Total Points', `${getTotalScore()} / ${getMaxScore()}`);
});
});
pdf.addSection('Category Breakdown', section => {
const s = scores();
section.addTable(
['Security Category', 'Score', 'Max', 'Status'],
[
['Access Control', `${s['access'] || 0}`, '20', (s['access'] || 0) >= 15 ? '✅ Good' : '⚠️ Needs Work'],
['Data Protection', `${s['data'] || 0}`, '20', (s['data'] || 0) >= 15 ? '✅ Good' : '⚠️ Needs Work'],
['Network Security', `${s['network'] || 0}`, '20', (s['network'] || 0) >= 15 ? '✅ Good' : '⚠️ Needs Work'],
['Employee Training', `${s['training'] || 0}`, '20', (s['training'] || 0) >= 15 ? '✅ Good' : '⚠️ Needs Work'],
['Incident Response', `${s['incident'] || 0}`, '20', (s['incident'] || 0) >= 15 ? '✅ Good' : '⚠️ Needs Work'],
]
);
});
pdf.addPageBreak();
pdf.addSection('Detailed Responses', section => {
const companySize = page1.dropdown('companySize')?.value();
const industry = page1.dropdown('industry')?.value();
section.addRow(row => {
row.addField('Company Size', companySize || 'Not specified');
row.addField('Industry', industry || 'Not specified');
});
section.addSpacer(10);
const mfa = page2.radioButton('mfa')?.value();
const passwordPolicy = page2.radioButton('passwordPolicy')?.value();
section.addRow(row => {
row.addField('MFA Implementation', mfa === 'all' ? 'All systems ✅' : mfa === 'some' ? 'Partial ⚠️' : 'None ❌');
row.addField('Password Policy', passwordPolicy === 'strong' ? 'Strong ✅' : passwordPolicy === 'basic' ? 'Basic ⚠️' : 'Weak ❌');
});
});
pdf.addSection('Priority Recommendations', section => {
const level = getRiskLevel();
if (level === 'critical' || level === 'high') {
section.addText('🚨 IMMEDIATE ACTIONS REQUIRED:');
section.addText('1. Implement Multi-Factor Authentication across all systems');
section.addText('2. Conduct emergency security awareness training');
section.addText('3. Review and update all access permissions');
section.addText('4. Engage a security professional for penetration testing');
} else if (level === 'medium') {
section.addText('⚡ RECOMMENDED IMPROVEMENTS:');
section.addText('1. Strengthen password policies and rotation');
section.addText('2. Implement regular security training schedule');
section.addText('3. Review backup and recovery procedures');
} else {
section.addText('✅ MAINTENANCE RECOMMENDATIONS:');
section.addText('1. Continue regular security audits');
section.addText('2. Stay updated on emerging threats');
section.addText('3. Consider advanced threat detection tools');
}
});
});
// ============ SUBMIT BUTTON ============
form.configureSubmitButton({
label: () => `🔒 Get My Security Report (Score: ${getScorePercentage()}%)`
});
form.configureSubmitBehavior({
sendToServer: true
});
}