joaomdmoura / gioco Goto Github PK
View Code? Open in Web Editor NEWA gamification gem to Ruby on Rails applications
A gamification gem to Ruby on Rails applications
In gioco rake taks there some parameter validations like:
if !args.name && !args.points && !args.type
But instead of 'and' concept it should be 'or'
if !args.name || !args.points || !args.type
Hey,
Just setup in rails 3.2 and ran into a few problems...
in the gioco.rake file:
At line 13: the find_or_create_by throws an error...this can be solved by changing line to
badge_string = "kind = Kind.find_by_name('#{args.kind}') || Kind.create(:name=> '#{args.kind}')\n"
Line 27 has "kinds.id" should be
r.points << Point.create({ :kind_id => kind.id, :value => '#{args.points}'})
Also when the generator makes the Models, it will use the user input to name the "Resource" fields, however the foreign key in the Points table has "user_id" hard coded.
line 5 of the ModelGenerator should be
generate("model", "point #{@model_name}_id:integer kind_id:integer value:integer")
Thanks
Before launch the new version the documentation and README must be updated
There would be nice some methods to support a ranking approach for next relase.
Implement a new approach option based on the fact that different type of points can give differenties badges to a resource.
I don't know yet how is the best way to add this feature but it should be scheduled as soon as possible to the next versions.
Nowadays is possible create different types with the same name, it should not be possible.
When calling remove_badge rake gioco:remove_badge[noob]
you don't have to pass the type name, it means that you should not be able to create badges with the same name event for different types. The type_name parameter should be required either.
After all updates that are being made, the website should be updated with the new documentation
Use some of generator snippets to build a better CLI removing some inline parameters.
The sync_resource_by_points is wrong. The points must be calculated correctly.
When there is just one badge related to a resource it isn't being removed cause there is no ponctuation to be added.
When Gioco was installed with the points support and a new Badge is added through Gioco::Badges.add(), all badges before that should be added too, not only the new ponctuation.
Suppose that you start setting up Gioco with --points
and then you perceive that you will gonna need also --types
. Today there is no easy way to migrate, first you will gonna have to completely uninstall Gioco, losing all your badges and data, and then set it up again now with the both optionals.
The best solution would be a method that deal with the existent data and files that was generated. Not only to add option but also to remove.
The uninstall order of Gioco, if configured with only --points
optional, would be:
$ rails g gioco:setup user --points --types;
/Users/rod/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1153:in `async_exec': PG::Error: ERROR: relation "types" does not exist (ActiveRecord::StatementInvalid)
LINE 5: WHERE a.attrelid = '"types"'::regclass
The remove_type method is not in the documentation.
It should be added also insed remove badge method?
Start to write the test ASAP!
Types should be managed without dependency of badges, so, the developer would be able to have types without badges.
There should be a method that return how many points the resource must win to own a new badge.
Only if it's being used with points system.
Hi,
I'd like your job but perhaps I didn't understand all
but it's normal that when I setup gioco and then run
rake gioco:add_badge[base_level,5,true]
rake gioco:add_badge[rookie,10,false]
rake gioco:add_badge[recruit,20,false]
rake gioco:add_badge[commander,50,false]
rake gioco:add_badge[strong,75,false]
rake gioco:add_badge[warior,100,false]
rake gioco:add_badge[powerful,200,false]
rake gioco:add_badge[extreme,500,false]
rake gioco:add_badge[heavy,1000,false]
rake gioco:add_badge[imortal,5000,false]
All my user get 5000 points?
I saw that all the user had a level entry in db for each badge. I thought that only base_level was associated to user, or I'm wrong?
Nunzio
Hi João - I'm having some trouble following the setup instructions.
Without the 'true' at the end, it works, and I see the entry in the database.
Any thoughts?
Thanks, look forward to getting your gem to work with my simple app!
paul@paul-server:~/Development/inhabition$ rake gioco:add_badge[noob,0,teacher,true] --trace
** Invoke gioco:add_badge (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute gioco:add_badge
rake aborted!
Validation failed: Last name can't be blank, Password is too short (minimum is 6 characters), Password confirmation can't be blank
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/validations.rb:56:in save!' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/attribute_methods/dirty.rb:33:in
save!'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:246:in block in save!' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:295:in
block in with_transaction_returning_status'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:208:in
transaction'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:293:in with_transaction_returning_status' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:246:in
save!'
/home/paul/Development/inhabition/lib/tasks/gioco.rake:28:in block (3 levels) in <top (required)>' /home/paul/Development/inhabition/lib/tasks/gioco.rake:25:in
each'
/home/paul/Development/inhabition/lib/tasks/gioco.rake:25:in block (2 levels) in <top (required)>' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in
call'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in block in execute' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in
each'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in execute' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in
block in invoke_with_call_chain'
/home/paul/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in mon_synchronize' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in
invoke_with_call_chain'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in invoke' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in
invoke_task'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block (2 levels) in top_level' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
each'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block in top_level' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
standard_exception_handling'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in top_level' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in
block in run'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in
run'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in <top (required)>' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in
load'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in <main>' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/bin/ruby_noexec_wrapper:14:in
eval'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/bin/ruby_noexec_wrapper:14:in `
Nowadays, with seeds ever time you add a a new badge it will duplicate the other oner in other environments. :(
I couldn't run the rake task following the example in the documentation:
$ rake gioco:add_badge[chuckie, 5, terror]
zsh: bad pattern: gioco:add_badge[chuckie,
When a default badge is added the points related must be automatically add to
Add tests to rakes_generator.rb.
Hi João - how do you move your badges to production?
Is there a way to create the rake task commands given what's in the database in dev?
Or do you have some init code that creates your badges when you deploy?
Cheers,
Paul
Gioco::Core.sync_resource_by_points(self, new_pontuation, kind)
returns:
ActiveRecord::UnknownAttributeError at /
unknown attribute: user_id
some notes:
this only fails when the point count triggers a new badge creation. otherwise it works...
Running rails 3.2.13
The method remove_badge should also require type_name as a parmeter to find the exactly badge in case there exist different badges with the same name from different types.
Just checking, is this updated for Rails 4 or is it compatible at current?
The files used by sync_database rake task have a lot of similar code, it would be great extract it to inside Gioco:Core or another class.
That's a lot of problems related with the optional parameter that should avoid database statements, it should be removed for the next version
Use the eval method isn't a good practice, it should be replace for capitalize and constantize.
TrueSkill is a Bayesian ranking algorithm developed by Microsoft Research and used in the Xbox matchmaking system.
TrueSkill maintains a belief on the skill of each player; every time a player plays a game, the system accordingly changes the perceived skill of the player and acquires more confidence about this perception.
It certainly is the best ranking algorithm nowadays, mostly because it cares about time factor. Would be awesome had this implemented inside Gioco Ranking Class.
Some interesting links about it:
TrueSkill
TrueSkillDetails
The README should be updated to let people know about the new features that are being added, as hwo to move your badges to productions using rake db:seed
The dependent gems must be updated
When a default badge is created the rake task end up by adding its points to the user, it's wrong because that might exist default badges created after some while
Hi João,
I have setup the Gioco by follow the example, the difference is I only use --points option.
then when I call the method Gioco::Resources.change_points(current_user.id, 1), it throws exception as follow:
NameError (undefined local variable or method 'options' for Gioco::Resoureces:Class)
How can I solve this issue?
Thanks.
The get_badge method isn't necessary and should be removed
Change methods that update the gioco data to use transactions to avoid a mess at database.
Some developers are requesting the possibility to add badges while running the code, it might be a good opportunity to rewrite the register badges logic.
There is taking too much time to install gioco, remove the dependencies is the faster approach.
Take a look at:
agaelebe@f4fba07
Unfortunately, the pull request didn't work (shame on you Github)!
best regards
Cuz everybody loves to play
or
Cuz everybody loves playing
sounds better. :)
It's quite a simple logic, you will add badges all the time, and eventually there will gonna be users that already should have a new badged that you are creating cause they already have the amount of points necessary to earn it.
To do this, the create badge rake task need to be changed, the seed generated also have to change.
Without an explicit license, no one can lawfully use your code.
When the change_points method is called, and the operation results in a new badge owned, the Gioco should use a callback informing the application about it.
Hi joao
I'm a little confused about the point system, I created a new project and setup the gem follow the example, everything is ready,
I'm confused about the new record value 1,2,4, why is 1,2,4 not 1,1,1 or 1,2,3 ?
You could make your gem more expressive. Like here:
rake gioco:add_badge[BADGE_NAME, POINTS, DEFAULT]
A example of this rake task would be:
rake gioco:add_badge["xpto", 9000 , true]
Wouldn't it better if you could do:
rake gioco:add_badge name:xpto points:9000 default:9000 (I still think that "default" is kinda off...)
Also, instead of using methods like this:
Gioco::Resources.change_points( Resource_id, Points, Type_id )
You could use
Gioco::Resources.change_points(:resource_id => 1, :points => 2, :type_id => 2 )
Or even better, with method chaining something like this:
GIoco::Resources(@resource).add(100)
It's just a suggestion and I admire you very much for the effort put in it.
I am trying to implement your gem in a rails 4 application. When trying to reference the 'Type' class from the User model, it gives an error. I believe this goes back to your model being named 'Type'.
Add the dependencies like Active Record and any others.
Would be nice if gioco could support "Adventure"
I mean, until now it could be possible only set badges that are "progression" of same points (same type).
However could be nice to earn badge when a particular collection of badges are won ex:
Again, could be useful add,optionally, bonus point to badges to rewards user when badge is assigned.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.