Creating a quiz (from scratch) in HubL?

forms

#1

Hi there, I’m new here so I hope I’m asking this in the right place. We’re proposing a big ol’ interactive thing to a client that we’d like to build in COS. A key part of this will be a multi-question, multiple choice quiz. Basically we want visitors to click through and answer a bunch of questions, then give them a score and save that score as a contact property.

I’d be able to do this no problem using standard html/js. I think it should work like the steps below but I’m new to HubL so your help is appreciated!

  1. User clicks answer in multiple choice question (e.g. A, B, C, or D).
  2. Answer is checked against a variable in the code (e.g. {% set question1Answer = ‘A’ %}).
  3. A score is tallied from their correct answers (e.g. {% set quizScore += 1 %}).
  4. After answering the final question the user is given a percentage based on the number of correct answers given (e.g. {% set quizScorePercentage = (quizScore / numberOfQuestions) * 100 %})
  5. Save contact property via API?

As I say, I’ve never done anything in HubL so I could be way off. ¯_(ツ)_/¯


#2

Hi @pete,

That sounds like it should work. As an aside, the HubSpot CMS supports JavaScript, so you could opt to do the quiz in HTML/JavaScript if you prefer.

You’ll likely want to look at the Forms API:


#3

Excellent, thank’s for your help @Derek_Gervais :slight_smile: