export function researchDebriefSurvey(form: FormTs) {
// Post-Study Debrief Survey - Comprehensive research participant feedback
// Demonstrates: MatrixQuestion, RatingScale, EmojiRating, StarRating, Slider, conditional visibility
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Post-Study Debrief',
computedValue: () => 'Thank you for participating in our research study. Your feedback helps us improve future studies and ensures participant wellbeing.',
customStyles: {
backgroundColor: '#7c3aed',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Overall Experience
// ============================================
const overallSection = form.addSubform('overallExperience', {
title: 'Overall Study Experience'
});
overallSection.addRow(row => {
row.addEmojiRating('overallFeeling', {
label: 'How do you feel about your participation in this study?',
preset: 'mood',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
overallSection.addSpacer();
overallSection.addRow(row => {
row.addRatingScale('satisfactionScore', {
preset: 'satisfaction',
label: 'How satisfied are you with your overall experience?',
size: 'md',
alignment: 'center'
});
});
// ============================================
// SECTION 2: Study Components Matrix
// ============================================
const componentsSection = form.addSubform('studyComponents', {
title: 'Study Components Evaluation',
isVisible: () => overallSection.emojiRating('overallFeeling')?.value() !== null
});
componentsSection.addRow(row => {
row.addMatrixQuestion('componentRatings', {
label: 'Please rate each aspect of the study:',
rows: [
{ id: 'instructions', label: 'Clarity of instructions', isRequired: true },
{ id: 'procedures', label: 'Study procedures', isRequired: true },
{ id: 'duration', label: 'Study duration', isRequired: false },
{ id: 'environment', label: 'Study environment', isRequired: false },
{ id: 'equipment', label: 'Equipment/materials used', isRequired: false },
{ id: 'breaks', label: 'Rest breaks provided', isRequired: false }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'fair', label: 'Fair' },
{ id: 'good', label: 'Good' },
{ id: 'excellent', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 3: Researcher Interaction
// ============================================
const researcherSection = form.addSubform('researcherInteraction', {
title: 'Researcher Interaction',
isVisible: () => overallSection.emojiRating('overallFeeling')?.value() !== null
});
researcherSection.addRow(row => {
row.addStarRating('researcherProfessionalism', {
label: 'Rate the professionalism of the research team',
maxStars: 5,
size: 'lg',
alignment: 'center',
showConfettiOnMax: true
});
});
researcherSection.addRow(row => {
row.addStarRating('communicationClarity', {
label: 'How clearly did the researcher explain the study?',
maxStars: 5,
size: 'lg',
alignment: 'center'
});
});
researcherSection.addRow(row => {
row.addThumbRating('questionsAnswered', {
label: 'Were all your questions answered satisfactorily?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'center'
});
});
// Follow-up for unanswered questions
researcherSection.addRow(row => {
row.addTextarea('unansweredQuestions', {
label: 'What questions remained unanswered?',
placeholder: 'Please describe any questions or concerns that were not addressed...',
rows: 3,
isVisible: () => researcherSection.thumbRating('questionsAnswered')?.value() === 'down'
});
});
// ============================================
// SECTION 4: Comfort & Concerns
// ============================================
const comfortSection = form.addSubform('comfortConcerns', {
title: 'Comfort & Concerns',
isVisible: () => overallSection.emojiRating('overallFeeling')?.value() !== null,
customStyles: () => {
const feeling = overallSection.emojiRating('overallFeeling')?.value();
if (feeling === 'sad' || feeling === 'down') {
return { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' };
}
return {};
}
});
comfortSection.addRow(row => {
row.addSlider('comfortLevel', {
label: 'How comfortable did you feel during the study?',
min: 1,
max: 10,
step: 1,
defaultValue: 5,
showValue: true,
unit: '/ 10'
});
});
comfortSection.addRow(row => {
row.addRadioButton('experiencedDiscomfort', {
label: 'Did you experience any discomfort during the study?',
options: [
{ id: 'none', name: 'No discomfort' },
{ id: 'mild', name: 'Mild discomfort' },
{ id: 'moderate', name: 'Moderate discomfort' },
{ id: 'significant', name: 'Significant discomfort' }
],
orientation: 'vertical'
});
});
// Conditional discomfort details
const discomfortDetails = comfortSection.addSubform('discomfortDetails', {
title: 'Please describe your discomfort',
isVisible: () => {
const discomfort = comfortSection.radioButton('experiencedDiscomfort')?.value();
return discomfort === 'mild' || discomfort === 'moderate' || discomfort === 'significant';
},
customStyles: { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' }
});
discomfortDetails.addRow(row => {
row.addCheckboxList('discomfortTypes', {
label: 'What type of discomfort did you experience?',
options: [
{ id: 'physical', name: 'Physical discomfort' },
{ id: 'mental', name: 'Mental fatigue' },
{ id: 'emotional', name: 'Emotional distress' },
{ id: 'boredom', name: 'Boredom/tedium' },
{ id: 'confusion', name: 'Confusion about tasks' },
{ id: 'time-pressure', name: 'Time pressure/stress' },
{ id: 'privacy', name: 'Privacy concerns' },
{ id: 'other', name: 'Other' }
],
orientation: 'vertical'
});
});
discomfortDetails.addSpacer();
discomfortDetails.addRow(row => {
row.addTextarea('discomfortDescription', {
label: 'Please describe the discomfort in detail:',
placeholder: 'Your detailed feedback helps us improve participant experience...',
rows: 3,
isRequired: () => {
const discomfort = comfortSection.radioButton('experiencedDiscomfort')?.value();
return discomfort === 'moderate' || discomfort === 'significant';
}
});
});
// ============================================
// SECTION 5: Data & Privacy
// ============================================
const privacySection = form.addSubform('dataPrivacy', {
title: 'Data & Privacy',
isVisible: () => overallSection.emojiRating('overallFeeling')?.value() !== null
});
privacySection.addRow(row => {
row.addRatingScale('privacyConfidence', {
preset: 'likert-5',
label: 'I am confident my data will be handled securely and anonymously',
lowLabel: 'Strongly disagree',
highLabel: 'Strongly agree',
alignment: 'center'
});
});
privacySection.addRow(row => {
row.addThumbRating('consentUnderstood', {
label: 'Did you fully understand the consent form you signed?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'center'
});
});
privacySection.addRow(row => {
row.addTextarea('privacyConcerns', {
label: 'Any concerns about data handling or privacy?',
placeholder: 'Share any concerns you have...',
rows: 2,
isVisible: () => {
const confidence = privacySection.ratingScale('privacyConfidence')?.value();
return confidence !== null && confidence !== undefined && confidence <= 2;
}
});
});
// ============================================
// SECTION 6: Future Participation
// ============================================
const futureSection = form.addSubform('futureParticipation', {
title: 'Future Participation',
isVisible: () => overallSection.ratingScale('satisfactionScore')?.value() !== null
});
futureSection.addRow(row => {
row.addRatingScale('participateAgain', {
preset: 'nps',
label: 'How likely are you to participate in future studies with our team?',
showCategoryLabel: true,
showSegmentColors: true,
alignment: 'center'
});
});
futureSection.addRow(row => {
row.addCheckboxList('preferredStudyTypes', {
label: 'What types of studies would you be interested in?',
options: [
{ id: 'online', name: 'Online surveys' },
{ id: 'lab', name: 'Lab-based studies' },
{ id: 'interviews', name: 'Interviews' },
{ id: 'focus-groups', name: 'Focus groups' },
{ id: 'field', name: 'Field studies' },
{ id: 'longitudinal', name: 'Longitudinal studies' }
],
orientation: 'vertical',
isVisible: () => {
const score = futureSection.ratingScale('participateAgain')?.value();
return score !== null && score !== undefined && score >= 7;
}
});
});
// ============================================
// SECTION 7: Suggestions for Improvement
// ============================================
const suggestionsSection = form.addSubform('suggestions', {
title: 'Suggestions for Improvement',
isVisible: () => overallSection.emojiRating('overallFeeling')?.value() !== null
});
suggestionsSection.addSpacer();
suggestionsSection.addRow(row => {
row.addTextarea('improvementSuggestions', {
label: () => {
const feeling = overallSection.emojiRating('overallFeeling')?.value();
if (feeling === 'sad' || feeling === 'down') {
return 'What could we have done to make your experience better?';
}
return 'Do you have any suggestions to improve future studies?';
},
placeholder: 'Your suggestions are valuable for improving our research...',
rows: 4,
autoExpand: true
});
});
// ============================================
// SECTION 8: Contact for Follow-up
// ============================================
const contactSection = form.addSubform('contactSection', {
title: 'Follow-up Contact (Optional)',
isVisible: () => overallSection.emojiRating('overallFeeling')?.value() !== null
});
contactSection.addRow(row => {
row.addCheckbox('allowFollowUp', {
label: 'The research team may contact me regarding my feedback'
});
});
contactSection.addRow(row => {
row.addEmail('contactEmail', {
label: 'Email address',
placeholder: 'your@email.com',
isRequired: () => contactSection.checkbox('allowFollowUp')?.value() === true,
isVisible: () => contactSection.checkbox('allowFollowUp')?.value() === true
});
});
// ============================================
// SECTION 9: Summary
// ============================================
const summarySection = form.addSubform('summary', {
title: 'Feedback Summary',
isVisible: () => {
const feeling = overallSection.emojiRating('overallFeeling')?.value();
const satisfaction = overallSection.ratingScale('satisfactionScore')?.value();
return feeling !== null && satisfaction !== null;
}
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const feeling = overallSection.emojiRating('overallFeeling')?.value();
const satisfaction = overallSection.ratingScale('satisfactionScore')?.value();
const comfort = comfortSection.slider('comfortLevel')?.value() ?? 5;
const researcherRating = researcherSection.starRating('researcherProfessionalism')?.value();
const npsScore = futureSection.ratingScale('participateAgain')?.value();
if (!feeling || satisfaction === null || satisfaction === undefined) return '';
const moodLabels: Record<string, string> = {
'sad': 'Negative',
'down': 'Somewhat negative',
'neutral': 'Neutral',
'happy': 'Positive',
'excited': 'Very positive'
};
let summary = 'Debrief Summary\n';
summary += '═'.repeat(25) + '\n\n';
summary += `Overall feeling: ${moodLabels[feeling] || feeling}\n`;
summary += `Satisfaction: ${satisfaction}/5\n`;
summary += `Comfort level: ${comfort}/10\n`;
if (researcherRating) {
summary += `Researcher rating: ${researcherRating}/5 stars\n`;
}
if (npsScore !== null && npsScore !== undefined) {
const category = futureSection.ratingScale('participateAgain')?.npsCategory();
summary += `\nFuture participation: ${npsScore}/10`;
if (category) {
summary += ` (${category})`;
}
}
return summary;
},
customStyles: () => {
const feeling = overallSection.emojiRating('overallFeeling')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (feeling === 'happy' || feeling === 'excited') {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (feeling === 'neutral') {
return { ...baseStyles, backgroundColor: '#e0e7ff', borderLeft: '4px solid #6366f1' };
} else {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
}
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Debrief Feedback',
isVisible: () => overallSection.emojiRating('overallFeeling')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank you for your feedback!',
message: 'Your responses will help us improve our research practices and ensure a positive experience for future participants. If you have any additional concerns, please contact the research team.'
});
}