OPScript Language Reference
The declarative, survey-as-code markup language powering PublicOp's advanced conditional flows.
Why Survey-as-Code?
Traditional drag-and-drop builders are slow and messy for complex research. OPScript lets you declare your entire questionnaire structure, routing rules, translations, and scoring metrics in a clean, human-readable text block. It's fast, version-controlled, and instantly compiled.
1. Basic Structure
Every survey template starts with metadata followed by questions defined as block objects. The syntax is a strict, clean markup format designed for rapid drafting.
# q_demographics (Single Choice Question) [Q] What is your age group? - under_18 : Under 18 years old - 18_34 : 18 - 34 years old - 35_54 : 35 - 54 years old - 55_plus : 55 years or older # q_feedback (Open Text Question) [Q] Tell us about your experience using our application: [Type] open-ended [Placeholder] Share your honest feedback...
2. Advanced Question Types
You can quickly declare complex matrix scales, rating stars, or audio-enabled responses using standard bracket tags.
# q_satisfaction (5-Point Likert Scale) [Q] How satisfied are you with our user interface? [Type] matrix-likert [Rows] - row_ui : User Interface Layout - row_speed : Loading Speed & Performance [Columns] - 1 : Very Dissatisfied - 2 : Dissatisfied - 3 : Neutral - 4 : Satisfied - 5 : Very Satisfied # q_voice_review (Audio Recording Response) [Q] Please record a 30-second voice note sharing your thoughts: [Type] audio-response [MaxDuration] 30
3. Conditional Routing & Logic
Logic rules are written directly below options using simple conditional statements. This handles skipping sections or piping dynamic answers instantly.
# q_own_car [Q] Do you own or lease a car? - yes : Yes, I do - no : No, I do not [Logic] IF answer == "no" SKIP TO q_public_transit # q_car_brand [Q] What brand of car do you drive? - brand_toyota : Toyota - brand_tesla : Tesla - brand_other : Other [Logic] IF answer == "brand_tesla" SET score = 100 # q_public_transit [Q] Ali, how often do you use public transit? [Type] dropdown - daily : Daily - weekly : Weekly - never : Never
4. Integration & Best Practices
When you save your OPScript inside the Report Builder or Template editor, the compiler will validate it in real-time. Any syntax error (like unclosed braces or referenced questions that do not exist) will show up immediately.
Reference Guidelines
- Always start a question declaration with a `# question_identifier`
- Use `[Q]` to define the primary question text.
- Options must be formatted as `- identifier : Display Text`
- Question types fallback to `single-choice` if `[Type]` is omitted.