Support

Account

Home Forums General Issues Random repeater rows passed to external page via POST

Solved

Random repeater rows passed to external page via POST

  • Hello,

    What I have set out to do is create a “quiz” using ACF.
    Below is an image that represents my ACF repeater structure.

    Repeater Fields

    Pulling in the relevant topics, questions and correct answer is fine, I have done this, however here is where it gets difficult.

    I have been able to display 5 random questions displayed from a pool of Questions with their relevant correct answer, but what I need to do is send this data through $_POST when a user submits a form, so I can store which questions were randomly selected and the correct answer associated with it.

    I thought about using a counter for each outputted question but I would lose consistency when submitting the questions as the counter would not tell what the correct associated answer is.

    Here is a link to my single template file
    http://upl.io/4mb6jv

    and here is a link to my external script to do a comparison
    External Grading script

    Can anyone point me towards an approach so I can start passing the associated correct answer to my other script?

  • Update: Okay so I decided to approach this from a completely different POV.

    Instead of relying on ACF functions, I spoke directly to the DB.

    Here is my result so far.

    I’m sure there is probably an easier way so if anyone has any advice on how to polish this, feel free to drop in.

  • Hi @drizzlyowl

    Glad you found solution. I must admit, I’m confused in regards to your question and don’t understand the issue here.

    Personally, I would have displayed the question within a form and just posted the data to the same page. Then above all other code in the template, I would run the logic to deal with the posted data.

    Thanks
    E

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Random repeater rows passed to external page via POST’ is closed to new replies.