diff --git a/Gemfile b/Gemfile index 9873055..2ca1739 100644 --- a/Gemfile +++ b/Gemfile @@ -48,5 +48,5 @@ group :assets do gem 'turbo-sprockets-rails3' end -# better timeouts -# gem "system_timer", "~> 1.2.4" +# badges for our users +gem 'merit' diff --git a/app/models/competency.rb b/app/models/competency.rb index 55143d0..12e30d5 100644 --- a/app/models/competency.rb +++ b/app/models/competency.rb @@ -67,8 +67,8 @@ class Competency < ActiveRecord::Base belongs_to :exercise def Competency.update(user,exercise) - scores = Score.where( :exercise_id => exercise.id, - :user_id => user.id ) + scores = ::Score.where( :exercise_id => exercise.id, + :user_id => user.id ).order(:created_at).limit( 35 ) observations = scores.collect{ |x| x.summary } @@ -76,7 +76,7 @@ def Competency.update(user,exercise) conditions = { :user_id => user.id, - :exercise_id => exercise } + :exercise_id => exercise.id } @competency = Competency.where(conditions).limit(1).first || Competency.create(conditions) @competency.estimate = p diff --git a/app/models/merit/badge_rules.rb b/app/models/merit/badge_rules.rb index c8a34b5..6e04326 100644 --- a/app/models/merit/badge_rules.rb +++ b/app/models/merit/badge_rules.rb @@ -21,6 +21,18 @@ class BadgeRules include Merit::BadgeRulesMethods def initialize + grant_on ['users#create', 'users#update'], :badge => 'autobiographer', :temporary => true do |user| + user.name.present? + end + + grant_on ['score#attempt'], :badge => 'answerer', :level => 5, :to => :user do |score| + score.user.scores.count > 5 + end + + grant_on ['score#attempt'], :badge => 'answerer', :level => 5, :to => :user do |score| + score.user.scores.count > 5 + end + # If it creates user, grant badge # Should be "current_user" after registration for badge to be granted. # grant_on 'users#create', :badge => 'just-registered', :to => :itself diff --git a/config/initializers/merit.rb b/config/initializers/merit.rb index e52362b..8f39b9e 100644 --- a/config/initializers/merit.rb +++ b/config/initializers/merit.rb @@ -14,7 +14,10 @@ end # Create application badges (uses https://github.com/norman/ambry) -# Badge.create!({ -# :id => 1, -# :name => 'just-registered' -# }) +Badge.create!({ + :id => 1, + :name => 'answerer', + :level => 5, + :description => 'Submitted answers' +}) + diff --git a/db/schema.rb b/db/schema.rb index 4d34620..7845688 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130104152512) do +ActiveRecord::Schema.define(:version => 20130104194637) do create_table "authentications", :force => true do |t| t.integer "user_id" @@ -22,6 +22,17 @@ t.datetime "updated_at", :null => false end + create_table "badges_sashes", :force => true do |t| + t.integer "badge_id" + t.integer "sash_id" + t.boolean "notified_user", :default => false + t.datetime "created_at" + end + + add_index "badges_sashes", ["badge_id", "sash_id"], :name => "index_badges_sashes_on_badge_id_and_sash_id" + add_index "badges_sashes", ["badge_id"], :name => "index_badges_sashes_on_badge_id" + add_index "badges_sashes", ["sash_id"], :name => "index_badges_sashes_on_sash_id" + create_table "competencies", :force => true do |t| t.float "estimate" t.float "uncertainty" @@ -59,6 +70,31 @@ t.datetime "updated_at", :null => false end + create_table "merit_actions", :force => true do |t| + t.integer "user_id" + t.string "action_method" + t.integer "action_value" + t.boolean "had_errors", :default => false + t.string "target_model" + t.integer "target_id" + t.boolean "processed", :default => false + t.string "log" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "merit_score_points", :force => true do |t| + t.integer "score_id" + t.integer "num_points", :default => 0 + t.string "log" + t.datetime "created_at" + end + + create_table "merit_scores", :force => true do |t| + t.integer "sash_id" + t.string "category", :default => "default" + end + create_table "problems", :force => true do |t| t.string "name" t.integer "exercise_id" @@ -69,20 +105,14 @@ add_index "problems", ["exercise_id"], :name => "index_problems_on_exercise_id" - create_table "scores", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - t.integer "time_taken" - t.integer "attempt_number" - t.boolean "complete" - t.integer "count_hints" - t.string "attempt_content" - t.integer "seed" - t.integer "problem_id" - t.integer "exercise_id" + create_table "sashes", :force => true do |t| + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end +# Could not dump table "scores" because of following StandardError +# Unknown type 'reference' for column 'exercise_id' + create_table "users", :force => true do |t| t.string "name" t.datetime "created_at", :null => false @@ -98,6 +128,8 @@ t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.string "coursera_id" + t.integer "sash_id" + t.integer "level", :default => 0 end add_index "users", ["email"], :name => "index_users_on_email", :unique => true diff --git a/test/fixtures/developers.yml b/test/fixtures/developers.yml index ab21d79..d125d93 100644 --- a/test/fixtures/developers.yml +++ b/test/fixtures/developers.yml @@ -1,28 +1,28 @@ bart-snapp: name: Bart Snapp photo: bart-snapp - description: Bart Snapp teaches mathematics at The Ohio State University. His research interests include commutative ring theory, number theory, and recreational mathematics. He enjoys exploring connections between mathematics and the real-world problems, art, and music. As an undergraduate, he was involved in distance teaching and learning though OSU's CROSU program. Prior to OSU, he worked at Coastal Carolina University. Bart earned his Ph.D. from the University Illinois at Urbana-Champaign. + description: Bart Snapp teaches mathematics at OSU. His research interests include commutative ring theory, number theory, and recreational mathematics. He enjoys exploring connections between mathematics and the real-world problems, art, and music. As an undergraduate, he was involved in distance teaching and learning though OSU's CROSU program. Prior to OSU, he worked at Coastal Carolina University. Bart earned his Ph.D. from the University Illinois at Urbana-Champaign. For Calculus One, Bart leads the development of the the textbook and contributes to exercises. link: http://www.math.osu.edu/~snapp/ email: snapp@math.osu.edu jim-fowler: name: Jim Fowler photo: jim-fowler - description: Jim is at OSU. + description: Jim Fowler teaches mathematics at OSU. His research interests broadly include geometry and topology, and more specifically, his interests focus on the topology of high-dimensional manifolds and geometric group theory, which means he gets to think about highly symmetric (and therefore very beautiful) geometric objects. He's particularly fond of using computational techniques to attack problems in pure mathematics. Prior to OSU, he received an undergraduate degree from Harvard University and received a Ph.D. from the University of Chicago. Jim is the head instructor (“project manager”) for Calculus One. link: http://www.math.osu.edu/~fowler/ email: fowler@math.osu.edu steve-gubkin: name: Steven Gubkin photo: steve-gubkin - description: Steve is at OSU. + description: Steve Gubkin is a mathematics Ph.D. student at OSU. Steve has extensive experience with the khan exercise framework, so for Calculus One, he leads the development of our interactive exercises. email: gubkin@math.osu.edu link: http://www.math.osu.edu/people/gubkin.1/view ryan-kowalick: name: Ryan Kowalick photo: ryan-kowalick - description: Ryan Kowalick + description: Ryan Kowalick is a mathematics Ph.D. student at OSU. For Calculus One, Ryan uses his extensive backgroud in Rails to handle coding tasks for this website. email: rkowalick@math.osu.edu link: http://www.math.osu.edu/people/kowalick.1 @@ -43,7 +43,7 @@ roman-holowinsky: sean-corey: name: Sean Corey photo: sean-corey - description: Sean Corey + description: Sean teaches mathematics in secondary schools and is a proponent of independent learning. Game theory and the development of artificial intelligence are prominent interests of his. For Calculus One, Sean has developed some of the interactive exercises and edited the textbook. email: corey.osumath@gmail.com sean-collins: @@ -59,5 +59,5 @@ kevin-jones: isaac-smith: name: Isaac Smith - description: Isaac is an undergraduate at Ohio State; he is a teaching assistant for Calculus One. + description: Isaac Smith is an undergraduate at Ohio State; he is a teaching assistant for Calculus One. email: smith.7914@osu.edu