Jump to content

Quiz Website With Processwire


Ghulam Mustafa
 Share

Recommended Posts

Hello,

Don't consider my answer as the good answer, but I made a quick test to check if an idea could work ("reponses" should be named "answer", and "nouveau" => "add new"):

image.thumb.png.5b81954908b981a6b053f5f063a34ab8.png

So I created this fields:

  • answer: type=Text
  • isGoodAnswer: type=Checkbox
  • quizzAnswer: type=Repeater, content fields=answer, isGoodAnswer
  • question: type=Text
  • quizzEntry: Type=Repeater, content fields=question, quizzAnswer

Added the field quizzEntry to a template, and it looks it's working.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Ghulam Mustafa said:

Can we build a large quiz website containing thousands of quizzes on varried academic subjects.

The only one that can answer that question is you. It only depends on your skills. ProcessWire can likely handle that challenge easily.

1 hour ago, Ghulam Mustafa said:

If yes, how it can done.

What do you expect someone to answer to that question?

1 hour ago, da² said:

quizzAnswer: type=Repeater

My only advice for that project is NOT to use repeaters for questions, answers, whatever. Repeaters are tempting because you get some kind of easy UI for your data, but repeaters really don't scale well and they are a pain when it comes to aggregating data, which is likely an important requirement of such a project. It's much better to store everything in pages and create references via page reference fields. Then aggregating data is easy via RockFinder or findRaw().

Listing data is still a problem, but that can be done with a custom process module https://processwire.com/talk/topic/17709-how-to-create-custom-admin-pages-aka-processmodules-yes-its-that-simple/. You can use libraries like https://tabulator.info/ for listing data. It's more effort than using repeaters, but it's for sure better for UI/UX and you have a lot more possibilities to present your data.

If you don't want to build the last part on your own you can buy a license of RockGrid - it's not on my website yet but it will be soon and I can send it manually to anybody interested. This is how such a grid / table / lister could look like:

AlC7WnZ.png

Instant sorting and filters. All the columns and buttons are totally up to you and added via JavaScript. Every row is a ProcessWire Page ?

 

Link to comment
Share on other sites

8 minutes ago, bernhard said:

My only advice for that project is NOT to use repeaters for questions, answers, whatever. Repeaters are tempting because you get some kind of easy UI for your data, but repeaters really don't scale well and they are a pain when it comes to aggregating data, which is likely an important requirement of such a project. It's much better to store everything in pages and create references via page reference fields

I never used repeaters so my knowledge is poor on this subject. But in my answer the goal is to create a single quiz per page (1000 quiz == 1000 pages with "quiz" template), do you think it's an issue doing that way? And why?

I'm interested in gathering informations on this subject, as it may be useful in the future. ?

Link to comment
Share on other sites

Well it always depends on the exact use case, so Repeaters might be a good option in one scenario or another. But the thing is that your example is very simplified and not the whole story ? Where would you store results for example? You could add another repeater for that, but then you have 3 levels of nesting and things get a nightmare if you want to retrieve data in an efficient way.

When working with repeaters from the API in regular pages it's simple to do this:

<?php
foreach($page->my_repeater as $answers) {
  echo $answer->user . " selected score " . $answer->score;
}

But how would you get all scores by user X and how would you efficiently aggregate that data and build an average for example?

These things are extremely efficient when done via SQL and are extremely expensive when done via PHP foreach ... And querying data from repeater pages is a pain. Or at least I don't know how to do it easily ? 

Link to comment
Share on other sites

If there are results to store, that's a whole question. ? I didn't think about that since OP question is a bit vague and we don't know if he needs that. And I was curious about testing repeaters. ?

Maybe store the results on the quiz page in a separate field (Profields Table ?), or a custom process module, or your RockGrid module. ^^

Since I bought Profields Table, I would try with it, I know it works with findRaw(). Adding a Table field on quiz template, columns would be "user | questionId | score".

I don't see a good way to do this with only core PW, but I don't know everything in PW.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...