export function onlineCourseFinderQuiz(form: FormTs) {
form.setTitle(() => '🎓 Find Your Perfect Online Course');
// ============ RECOMMENDATION SYSTEM ============
const answers = form.state<Record<string, string | string[] | number>>({});
const setAnswer = (key: string, value: string | string[] | number) => {
answers.update(current => ({ ...current, [key]: value }));
};
type LearningGoal = 'career-change' | 'skill-upgrade' | 'hobby' | 'certification' | 'business';
type LearningStyle = 'video' | 'reading' | 'hands-on' | 'mixed';
type Platform = 'coursera' | 'udemy' | 'linkedin' | 'skillshare' | 'masterclass' | 'edx';
const getPlatformRecommendations = (): { platform: Platform; name: string; reason: string; price: string }[] => {
const goal = answers()['learningGoal'] as LearningGoal;
const style = answers()['learningStyle'] as LearningStyle;
const budget = answers()['budget'] as string;
const category = answers()['category'] as string;
const platforms: { platform: Platform; name: string; reason: string; price: string; score: number }[] = [];
// Career-focused platforms
if (goal === 'career-change' || goal === 'certification') {
platforms.push({
platform: 'coursera',
name: 'Coursera',
reason: 'University-backed certificates recognized by employers',
price: '$49-79/month or $399/year',
score: 95
});
platforms.push({
platform: 'edx',
name: 'edX',
reason: 'Harvard, MIT certificates for career advancement',
price: '$50-300 per certificate',
score: 90
});
platforms.push({
platform: 'linkedin',
name: 'LinkedIn Learning',
reason: 'Certificates display directly on your LinkedIn profile',
price: '$29.99/month',
score: 85
});
}
// Skill upgrade
if (goal === 'skill-upgrade' || goal === 'business') {
platforms.push({
platform: 'udemy',
name: 'Udemy',
reason: 'Practical, hands-on courses with lifetime access',
price: '$12-200 per course (frequent sales)',
score: 88
});
platforms.push({
platform: 'linkedin',
name: 'LinkedIn Learning',
reason: '16,000+ professional development courses',
price: '$29.99/month',
score: 85
});
}
// Creative/hobby
if (goal === 'hobby' || category === 'creative') {
platforms.push({
platform: 'skillshare',
name: 'Skillshare',
reason: 'Best for creative skills with project-based learning',
price: '$13.99/month annually',
score: 92
});
platforms.push({
platform: 'masterclass',
name: 'MasterClass',
reason: 'Learn from world-famous experts and celebrities',
price: '$180/year',
score: 80
});
}
// Budget considerations
if (budget === 'free') {
platforms.push({
platform: 'coursera',
name: 'Coursera (Audit)',
reason: 'Free access to course content without certificate',
price: 'Free (audit mode)',
score: 75
});
platforms.push({
platform: 'edx',
name: 'edX (Audit)',
reason: 'Free access to world-class education',
price: 'Free (audit mode)',
score: 75
});
}
// Sort by score and return top 3
return platforms
.sort((a, b) => b.score - a.score)
.slice(0, 3)
.map(({ platform, name, reason, price }) => ({ platform, name, reason, price }));
};
const getTopRecommendation = () => {
const recs = getPlatformRecommendations();
return recs[0] || { name: 'Coursera', reason: 'Great all-around platform', price: '$49/month' };
};
const getCourseRecommendations = () => {
const category = answers()['category'] as string;
const level = answers()['skillLevel'] as string;
const courses: Record<string, { beginner: string[]; intermediate: string[]; advanced: string[] }> = {
tech: {
beginner: ['Python for Everybody', 'Google IT Support', 'Web Development Bootcamp'],
intermediate: ['AWS Cloud Practitioner', 'Full Stack Development', 'Data Science Specialization'],
advanced: ['Machine Learning by Stanford', 'System Design', 'Cloud Architecture']
},
business: {
beginner: ['Business Foundations', 'Digital Marketing', 'Excel Skills for Business'],
intermediate: ['MBA Essentials', 'Product Management', 'Business Analytics'],
advanced: ['Strategic Leadership', 'Corporate Finance', 'Business Strategy']
},
creative: {
beginner: ['Graphic Design Basics', 'Photography Fundamentals', 'Intro to UX Design'],
intermediate: ['Advanced Photoshop', 'Motion Graphics', 'UX Research'],
advanced: ['Brand Identity Design', 'Creative Direction', '3D Animation']
},
personal: {
beginner: ['Learning How to Learn', 'Mindfulness', 'Public Speaking'],
intermediate: ['Emotional Intelligence', 'Negotiation Skills', 'Speed Reading'],
advanced: ['Executive Presence', 'Thought Leadership', 'Life Coaching Certification']
}
};
const categoryCourses = courses[category] || courses['tech'];
return categoryCourses[level as keyof typeof categoryCourses] || categoryCourses['beginner'];
};
// ============ COMPLETION SCREEN ============
form.configureCompletionScreen({
type: 'text',
title: () => '🎓 Your Learning Path Is Ready!',
message: () => {
const top = getTopRecommendation();
return `Based on your goals, we recommend ${top.name}. Download your complete learning guide with course recommendations and study plan!`;
}
});
// ============ PAGES SETUP ============
const pages = form.addPages('quiz-pages', {
heightMode: 'current-page'
});
// ============ PAGE 1: Learning Goals ============
const page1 = pages.addPage('goals', { mobileBreakpoint: 500 });
page1.addRow(row => {
row.addTextPanel('header1', {
label: 'Step 1 of 6: Your Learning Goals',
computedValue: () => 'What do you want to achieve with online learning?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page1.addSpacer({ height: '24px' });
page1.addRow(row => {
row.addRadioButton('learningGoal', {
label: 'What\'s your primary learning goal?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'career-change', name: '🔄 Career Change - Switch to a new field' },
{ id: 'skill-upgrade', name: '📈 Skill Upgrade - Advance in current role' },
{ id: 'certification', name: '📜 Certification - Get credentials for my resume' },
{ id: 'business', name: '💼 Business - Start or grow my own business' },
{ id: 'hobby', name: '🎨 Personal Interest - Learn for fun' }
],
onValueChange: (val) => setAnswer('learningGoal', val || '')
});
});
page1.addRow(row => {
row.addDropdown('category', {
label: 'What area interests you most?',
isRequired: true,
options: [
{ id: 'tech', name: '💻 Technology & Programming' },
{ id: 'business', name: '📊 Business & Management' },
{ id: 'creative', name: '🎨 Creative & Design' },
{ id: 'personal', name: '🧠 Personal Development' },
{ id: 'data', name: '📈 Data & Analytics' },
{ id: 'marketing', name: '📱 Marketing & Social Media' }
],
placeholder: 'Select a category',
onValueChange: (val) => setAnswer('category', val || '')
});
});
// ============ PAGE 2: Current Level ============
const page2 = pages.addPage('level', { mobileBreakpoint: 500 });
page2.addRow(row => {
row.addTextPanel('header2', {
label: 'Step 2 of 6: Your Current Level',
computedValue: () => 'Help us recommend the right difficulty level',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page2.addSpacer({ height: '24px' });
page2.addRow(row => {
row.addRadioButton('skillLevel', {
label: 'What\'s your experience level in this area?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'beginner', name: '🌱 Beginner - New to this topic' },
{ id: 'intermediate', name: '🌿 Intermediate - Some experience/knowledge' },
{ id: 'advanced', name: '🌳 Advanced - Looking to master/specialize' }
],
onValueChange: (val) => setAnswer('skillLevel', val || '')
});
});
page2.addRow(row => {
row.addRadioButton('priorLearning', {
label: 'Have you taken online courses before?',
isRequired: true,
orientation: 'horizontal',
options: [
{ id: 'none', name: 'Never' },
{ id: 'few', name: 'A few courses' },
{ id: 'many', name: 'Many courses' }
],
onValueChange: (val) => setAnswer('priorLearning', val || '')
});
});
// ============ PAGE 3: Learning Style ============
const page3 = pages.addPage('style', { mobileBreakpoint: 500 });
page3.addRow(row => {
row.addTextPanel('header3', {
label: 'Step 3 of 6: Learning Style',
computedValue: () => 'Everyone learns differently - let\'s find what works for you',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page3.addSpacer({ height: '24px' });
page3.addRow(row => {
row.addRadioButton('learningStyle', {
label: 'How do you learn best?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'video', name: '🎬 Video lectures - Watch and learn' },
{ id: 'reading', name: '📚 Reading - Articles and documentation' },
{ id: 'hands-on', name: '🛠️ Hands-on - Projects and exercises' },
{ id: 'mixed', name: '🎯 Mixed - Combination of all' }
],
onValueChange: (val) => setAnswer('learningStyle', val || '')
});
});
page3.addRow(row => {
row.addSuggestionChips('features', {
label: 'What features are important to you?',
suggestions: [
{ id: 'certificates', name: '📜 Certificates' },
{ id: 'projects', name: '🛠️ Hands-on Projects' },
{ id: 'community', name: '👥 Community/Forums' },
{ id: 'mentorship', name: '🧑🏫 Mentorship' },
{ id: 'mobile', name: '📱 Mobile App' },
{ id: 'offline', name: '📥 Offline Access' }
],
alignment: 'left',
onValueChange: (val) => setAnswer('features', val || [])
});
});
// ============ PAGE 4: Time & Commitment ============
const page4 = pages.addPage('time', { mobileBreakpoint: 500 });
page4.addRow(row => {
row.addTextPanel('header4', {
label: 'Step 4 of 6: Time Commitment',
computedValue: () => 'How much time can you dedicate to learning?',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page4.addSpacer({ height: '24px' });
page4.addRow(row => {
row.addSlider('hoursPerWeek', {
label: 'Hours per week you can commit',
isRequired: true,
min: 1,
max: 20,
step: 1,
defaultValue: 5,
unit: 'hours/week',
onValueChange: (val) => setAnswer('hoursPerWeek', val || 5)
});
});
page4.addRow(row => {
row.addRadioButton('timeline', {
label: 'When do you want to complete your learning?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'asap', name: '⚡ ASAP - Intensive learning' },
{ id: '3months', name: '📅 3 months' },
{ id: '6months', name: '📆 6 months' },
{ id: 'flexible', name: '🎯 No deadline - Self-paced' }
],
onValueChange: (val) => setAnswer('timeline', val || '')
});
});
page4.addRow(row => {
row.addRadioButton('structure', {
label: 'Do you prefer structured or self-paced learning?',
isRequired: true,
orientation: 'horizontal',
options: [
{ id: 'structured', name: 'Structured (deadlines)' },
{ id: 'selfpaced', name: 'Self-paced' },
{ id: 'either', name: 'Either works' }
],
onValueChange: (val) => setAnswer('structure', val || '')
});
});
// ============ PAGE 5: Budget ============
const page5 = pages.addPage('budget', { mobileBreakpoint: 500 });
page5.addRow(row => {
row.addTextPanel('header5', {
label: 'Step 5 of 6: Budget',
computedValue: () => 'Let\'s find options that fit your budget',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page5.addSpacer({ height: '24px' });
page5.addRow(row => {
row.addRadioButton('budget', {
label: 'What\'s your learning budget?',
isRequired: true,
orientation: 'vertical',
options: [
{ id: 'free', name: '🆓 Free only' },
{ id: 'low', name: '💵 Under $50/month' },
{ id: 'medium', name: '💰 $50-100/month' },
{ id: 'high', name: '💎 $100+/month or willing to invest in quality' }
],
onValueChange: (val) => setAnswer('budget', val || '')
});
});
page5.addRow(row => {
row.addRadioButton('paymentPreference', {
label: 'Payment preference?',
isRequired: true,
orientation: 'horizontal',
options: [
{ id: 'subscription', name: 'Monthly subscription' },
{ id: 'onetime', name: 'One-time purchase' },
{ id: 'either', name: 'Either works' }
],
onValueChange: (val) => setAnswer('paymentPreference', val || '')
});
});
// ============ PAGE 6: Results ============
const page6 = pages.addPage('results', { mobileBreakpoint: 500 });
page6.addRow(row => {
row.addTextPanel('header6', {
label: 'Step 6 of 6: Your Recommendations',
computedValue: () => 'Here are the best platforms and courses for you',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page6.addSpacer({ height: '24px' });
page6.addRow(row => {
row.addTextPanel('topPick', {
computedValue: () => {
const top = getTopRecommendation();
return `🏆 Top Pick: ${top.name}`;
},
customStyles: {
fontSize: '1.4rem',
fontWeight: '700',
textAlign: 'center',
color: '#7c3aed',
padding: '20px',
background: 'linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%)',
borderRadius: '12px',
border: '2px solid #a78bfa'
}
});
});
page6.addRow(row => {
row.addTextPanel('topPickReason', {
computedValue: () => {
const top = getTopRecommendation();
return `${top.reason}\nPrice: ${top.price}`;
},
customStyles: {
fontSize: '0.95rem',
textAlign: 'center',
color: '#4b5563',
whiteSpace: 'pre-line',
marginTop: '0.5rem'
}
});
});
// Alternative platforms
const alternativesSection = page6.addSubform('alternatives', {
title: '🎯 Other Great Options',
isCollapsible: true,
customStyles: {
marginTop: '1rem',
background: '#f9fafb',
borderRadius: '8px'
}
});
alternativesSection.addRow(row => {
row.addTextPanel('otherPlatforms', {
computedValue: () => {
const recs = getPlatformRecommendations();
return recs.slice(1).map((r, i) => `${i + 2}. ${r.name} - ${r.reason} (${r.price})`).join('\n\n');
},
customStyles: {
fontSize: '0.9rem',
whiteSpace: 'pre-line',
lineHeight: '1.6'
}
});
});
// Recommended courses
const coursesSection = page6.addSubform('courses', {
title: '📚 Recommended Courses to Start',
isCollapsible: true,
customStyles: {
marginTop: '1rem',
background: '#ecfdf5',
borderRadius: '8px'
}
});
coursesSection.addRow(row => {
row.addTextPanel('courseList', {
computedValue: () => {
const courses = getCourseRecommendations();
return courses.map((c, i) => `${i + 1}. ${c}`).join('\n');
},
customStyles: {
fontSize: '0.9rem',
whiteSpace: 'pre-line',
lineHeight: '1.8'
}
});
});
// ============ PAGE 7: Lead Capture ============
const page7 = pages.addPage('lead-capture', { mobileBreakpoint: 500 });
page7.addRow(row => {
row.addTextPanel('header7', {
label: 'Get Your Complete Learning Guide',
computedValue: () => 'Receive your personalized course recommendations with a detailed study plan',
customStyles: {
fontSize: '0.9rem',
color: '#6b7280',
marginBottom: '1rem'
}
});
});
page7.addSpacer({ height: '24px' });
page7.addRow(row => {
row.addTextbox('name', {
label: 'Your Name',
isRequired: true,
placeholder: 'Alex Chen'
}, '1fr');
row.addEmail('email', {
label: 'Email Address',
isRequired: true,
placeholder: 'alex@email.com'
}, '1fr');
});
page7.addRow(row => {
row.addCheckboxList('consent', {
options: [
{ id: 'guide', name: '📧 Send me my personalized learning guide (PDF)', isRequired: true },
{ id: 'tips', name: '💡 Weekly learning tips and course recommendations' },
{ id: 'deals', name: '🏷️ Course deals and discount alerts' }
],
defaultValue: ['guide'],
orientation: 'vertical'
});
});
// ============ PDF REPORT ============
form.configurePdf('learning-report', pdf => {
pdf.configure({
filename: 'your-learning-guide.pdf',
pageSize: 'A4',
allowUserDownload: true,
downloadButtonLabel: '📄 Download Learning Guide',
header: {
title: 'Your Personalized Learning Guide',
subtitle: 'Custom course and platform recommendations'
},
footer: {
text: 'Generated by FormTs Course Finder',
showPageNumbers: true
}
});
pdf.addSection('Your Learning Profile', section => {
section.addRow(row => {
row.addField('Learning Goal', (answers()['learningGoal'] as string) || 'Not specified');
row.addField('Category', (answers()['category'] as string) || 'Not specified');
});
section.addRow(row => {
row.addField('Skill Level', (answers()['skillLevel'] as string) || 'Not specified');
row.addField('Hours/Week', `${answers()['hoursPerWeek'] || 5} hours`);
});
});
pdf.addSection('Platform Recommendations', section => {
const recs = getPlatformRecommendations();
section.addTable(
['Rank', 'Platform', 'Why It\'s Great For You', 'Price'],
recs.map((r, i) => [`#${i + 1}`, r.name, r.reason, r.price])
);
});
pdf.addSection('Recommended Courses', section => {
const courses = getCourseRecommendations();
courses.forEach((c, i) => section.addText(`${i + 1}. ${c}`));
});
pdf.addSection('Your Study Plan', section => {
const hours = (answers()['hoursPerWeek'] as number) || 5;
section.addText(`With ${hours} hours per week, here's your suggested schedule:`);
section.addText(`• Week 1-2: Platform setup and first module`);
section.addText(`• Week 3-4: Complete fundamentals`);
section.addText(`• Week 5-8: Deep dive into core content`);
section.addText(`• Week 9-12: Projects and practical application`);
});
});
// ============ SUBMIT BUTTON ============
form.configureSubmitButton({
label: () => '🎓 Get My Learning Guide'
});
form.configureSubmitBehavior({
sendToServer: true
});
}