Bergrebell / CyberCoach

1 stars 1 forks source link

Define achievements #79

Closed wanze closed 9 years ago

wanze commented 9 years ago

So finally the AttributeValidator is working. I've created some achievements locally for testing, here are some screenshots:

bildschirmfoto 2014-11-28 um 18 51 47

bildschirmfoto 2014-11-28 um 19 02 37

How to create an achievement:

Rules are written as JSON string. Every attribute from the results object and the sport_session object is available. Also there is a special attribute n_participants holding the number of participants that were joining the session.

Here are some samples to get you started, multiple rules are evaluated with AND:

As you probably notice, we will need to define the units for each attribute!

Cheers and enjoy the weekend

lexruee commented 9 years ago

Awesome! UI chief|

lexruee commented 9 years ago

There is a nil excpetion:

NoMethodError in Achievements#index
Showing /home/lexruee/workspace/ASE/CyberCoachApp/app/views/achievements/index.html.erb where line #22 raised:

undefined method `type' for nil:NilClass
Extracted source (around line #22):

19           <td><%= achievement.points %></td>
20           <td><%= achievement.sport %></td>
21           <td><%= achievement.rules %></td>
22           <td><%= achievement.validator.type %></td>
23           <td><%= link_to 'Show', achievement %></td>
24           <td><%= link_to 'Edit', edit_achievement_path(achievement) %></td>
25           <td><%= link_to 'Destroy', achievement, method: :delete, data: { confirm: 'Are you sure?' } %></td>

Rails.root: /home/lexruee/workspace/ASE/CyberCoachApp
wanze commented 9 years ago

@lexruee
Argh you don't have the attribute validator in the database, sorry. I've put it into the seed file here: https://github.com/Bergrebell/CyberCoach/blob/dev/db/seeds.rb Should be okay if you seed the database

rake db:seed

@svetakrasikova @Bergrebell You need to execute the command above too in order to make the achievements work

wanze commented 9 years ago

I close this one, we need to think about seeding the db when we deploy!