Models for trivia game app

33 views
Skip to first unread message

Joseph Wilks

unread,
Sep 28, 2014, 12:18:19 AM9/28/14
to rubyonra...@googlegroups.com
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! :)

Joe

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Sep 28, 2014, 3:41:54 AM9/28/14
to rubyonra...@googlegroups.com
On 28 September 2014 05:17, Joseph Wilks <li...@ruby-forum.com> wrote:
> 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..).

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

Joseph Wilks

unread,
Sep 28, 2014, 10:35:36 AM9/28/14
to rubyonra...@googlegroups.com
Colin Law wrote in post #1158601:
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!

Colin Law

unread,
Sep 28, 2014, 11:49:54 AM9/28/14
to rubyonra...@googlegroups.com
On 28 September 2014 15:33, Joseph Wilks <li...@ruby-forum.com> wrote:
> Colin Law wrote in post #1158601:
>> On 28 September 2014 05:17, Joseph Wilks <li...@ruby-forum.com> wrote:
>>> 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

Joseph Wilks

unread,
Sep 30, 2014, 1:11:58 PM9/30/14
to rubyonra...@googlegroups.com
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?

Sai Ch

unread,
Sep 30, 2014, 8:43:23 PM9/30/14
to rubyonra...@googlegroups.com
Yup, you can get perfect routes by using above mentioned method...!
Reply all
Reply to author
Forward
0 new messages