# Quiz Fields

**URL:** <https://community.prismic.io/t/quiz-fields/14592>\
**Category:** Developing with Prismic\
**Tags:** slice-machine\
**Created:** [November 27, 2023, 9:30pm UTC](https://community.prismic.io/t/quiz-fields/14592 "2023-11-27T21:30:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![traek.wells](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/traek.wells/32/6579_2.png) [@traek.wells](https://community.prismic.io/u/traek.wells)\
**Post date:** [November 27, 2023, 9:30pm UTC](https://community.prismic.io/t/quiz-fields/14592/1 "2023-11-27T21:30:56Z")

</div>

Hello fellow prismic people. I have a question and I'm hoping to get some guidance.

I have a Quiz page that looks like this and I'm struggling with how to build this out in Prismic.

 ![Screenshot 2023-11-27 at 3.23.06 PM](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/9/97804352aaf1c26554dc380fd8142cc9ca71b188.png)

I need the content author to have the ability to put in a question and four answers with one of them being the correct one. I've created a reusable custom type and gave it five key text fields for the question and answers. But I have no idea how I would let the content author choose which one is the correct answer The idea is that the content author would create a new 'Quiz Question' document. Is that the right approach? It seems like there'd be a lot of documents in the dashboard called 'Quiz Question.

Any advice?

---

<div class="post-metadata">

**Author:** ![nf\_mastroianni](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/nf_mastroianni/32/7071_2.png) [@nf\_mastroianni](https://community.prismic.io/u/nf_mastroianni)\
**Post date:** [November 28, 2023, 12:57am UTC](https://community.prismic.io/t/quiz-fields/14592/2 "2023-11-28T00:57:04Z")

</div>

Seems to me a way to look at this would be to have a slice that is a question. Inside that slice, in the non-repeatable zone you have your question. Let's say that your default variation is a multiple-choice. In the repeatable zone you have key text field and a boolean field. This allows editors to write answers and then they toggle true for the one(s) that are correct.

Slices would then allow you to arrange their order as needed, and are indexed as well. Thus, their number will correspond to their order.

Was that clear?

---

<div class="post-metadata">

**Author:** ![traek.wells](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/traek.wells/32/6579_2.png) [@traek.wells](https://community.prismic.io/u/traek.wells)\
**Post date:** [November 28, 2023, 1:13pm UTC](https://community.prismic.io/t/quiz-fields/14592/3 "2023-11-28T13:13:23Z")

</div>

Yes that makes perfect sense and it worked! You're a genius. Thank you 🦉

---

<div class="post-metadata">

**Author:** ![traek.wells](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/traek.wells/32/6579_2.png) [@traek.wells](https://community.prismic.io/u/traek.wells)\
**Post date:** [December 1, 2023, 3:45am UTC](https://community.prismic.io/t/quiz-fields/14592/4 "2023-12-01T03:45:24Z")

</div>

@nf_mastroianni Follow up question. Any ideas on how I'd be able to get a count of all 'Question' slices? For example, if I wanted to show something like "Question 2 of 10". From what I gather, I don't really have a reference of the other Question slices inside of a given slice.

---

<div class="post-metadata">

**Author:** ![nf\_mastroianni](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/nf_mastroianni/32/7071_2.png) [@nf\_mastroianni](https://community.prismic.io/u/nf_mastroianni)\
**Post date:** [December 1, 2023, 11:03pm UTC](https://community.prismic.io/t/quiz-fields/14592/5 "2023-12-01T23:03:51Z")

</div>

Ok @traek.wells let's see what we can figure out here...

```auto
// just guessing here

const { data: { slices}} = page

const questions = slices.filter((slice) => slice.slice_type === 'question')
// replace 'question' with your slice name
const questionCount = questions.length

```

How's that? Does it help at all?

---

<div class="post-metadata">

**Author:** ![traek.wells](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/traek.wells/32/6579_2.png) [@traek.wells](https://community.prismic.io/u/traek.wells)\
**Post date:** [December 2, 2023, 9:00pm UTC](https://community.prismic.io/t/quiz-fields/14592/6 "2023-12-02T21:00:12Z")

</div>

@nf_mastroianni I'm assuming this is at the page level though right? I think this logic will work to the total amount at the page level but I still don't see how I'd pass that info down to the individual slice. I don't think I can pass additional props to the component.

---

<div class="post-metadata">

**Author:** ![nf\_mastroianni](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/nf_mastroianni/32/7071_2.png) [@nf\_mastroianni](https://community.prismic.io/u/nf_mastroianni)\
**Post date:** [December 2, 2023, 9:17pm UTC](https://community.prismic.io/t/quiz-fields/14592/7 "2023-12-02T21:17:03Z")

</div>

Could this be of use:  
[Passing additional Properties in SliceZone with SliceProps - Developing with Prismic - Prismic People](https://community.prismic.io/t/passing-additional-properties-in-slicezone-with-sliceprops/6927)
