Models for trivia game app

I'm building my first ever rails app, which consists of various 'trivia challenges' based around tv shows, which the user can complete, and then receives 'gamified' rewards via the merit gem.

I've created a user model, but then I got stuck thinking about how to model the challenges.

There will be 3-5 challenge sets/courses, each consisting of 10-20 quizzes (where the user briefly reviews or learns the info and then is quizzed on it). However I can't decide how this integrates with the REST/CRUD actions (i'm not creating, updating, or destroying anything... they're just doing a quiz and getting badges and xp when they complete them..).

Any advice on how to model this, or alter my perspective somehow? Thanks in advance! :slight_smile:

Joe

Do the quiz information and challenge set data change over time? If so then you need to create, update and destroy them.

What other information needs to be remembered from one session to the next?

Colin

Colin Law wrote in post #1158601:

REST/CRUD actions (i'm not creating, updating, or destroying anything... they're just doing a quiz and getting badges and xp when they complete them..).

Do the quiz information and challenge set data change over time? If so then you need to create, update and destroy them.

What other information needs to be remembered from one session to the next?

Colin

Hi Colin

The quizzes will remain the same, although obviously I will add new ones myself over time. The user just reads some information (which could be on the same page as the quiz, using a little ajax box with multiple tabs), does a small quiz, and all that needs to be remembered is a boolean which says whether that quiz has been successfully completed or not (I think).

I want to have it so that the URL's are like:

example.com/comedy/1 (for quiz 1 of the comedy tv section of questions)

and then if it has multiple pages I guess I'd need it to be /comedy/1/3 or whatever.

What's the standard way to do this?

Thanks for the help!

Joe

Colin Law wrote in post #1158601:

REST/CRUD actions (i'm not creating, updating, or destroying anything... they're just doing a quiz and getting badges and xp when they complete them..).

Do the quiz information and challenge set data change over time? If so then you need to create, update and destroy them.

What other information needs to be remembered from one session to the next?

Colin

Hi Colin

The quizzes will remain the same, although obviously I will add new ones myself over time.

So you need to be able to create, edit, destroy those. So pretty standard REST interface there. You could use the rails scaffold for this as it is only an admin interface rather than a user i/f.

The user just reads some information (which could be on the same page as the quiz, using a little ajax box with multiple tabs), does a small quiz, and all that needs to be remembered is a boolean which says whether that quiz has been successfully completed or not (I think).

So that is a boolean saying that this user has completed that quiz? So you could use a join table between users and quiz for that.

I want to have it so that the URL's are like:

example.com/comedy/1 (for quiz 1 of the comedy tv section of questions)

and then if it has multiple pages I guess I'd need it to be /comedy/1/3 or whatever.

Don't worry about what the urls look like, work out what functionality you want, and go from there. The requirements drive the urls not the other way round. Think of it as an application not a series of web pages.

What's the standard way to do this?

Standard way to do what?

Colin

Thanks Colin.

Another person suggested this:

resources :comedy do    collection do     get :play_quiz    end end

class ComedyController < ApplicationController    def play_quiz

    end end

Would this be preferable?

Yup, you can get perfect routes by using above mentioned method...!