Skip to content

Commit

Permalink
Fixed some interactions between our Score and Merit::Score
Browse files Browse the repository at this point in the history
  • Loading branch information
kisonecat committed Jan 4, 2013
1 parent eb57016 commit 3f44924
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
6 changes: 3 additions & 3 deletions app/models/competency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ 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 }

p = Viterbi.viterbi( observations )

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
Expand Down
12 changes: 12 additions & 0 deletions app/models/merit/badge_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions config/initializers/merit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
})

58 changes: 45 additions & 13 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/developers.yml
Original file line number Diff line number Diff line change
@@ -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 <a href="http://socrates.math.osu.edu/">CROSU</a> 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 <a href="http://socrates.math.osu.edu/">CROSU</a> program. Prior to OSU, he worked at <a href="http://www.coastal.edu/">Coastal Carolina University</a>. Bart earned his Ph.D. from the <a href="http://illinois.edu/">University Illinois at Urbana-Champaign</a>. For Calculus One, Bart leads the development of the <a href="/handouts">the textbook</a> and contributes to exercises.
link: http://www.math.osu.edu/~snapp/
email: [email protected]

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 <a href="http://www.harvard.edu/">Harvard University</a> and received a Ph.D. from the <a href="http://www.uchicago.edu/">University of Chicago</a>. Jim is the head instructor (&ldquo;project manager&rdquo;) for Calculus One.
link: http://www.math.osu.edu/~fowler/
email: [email protected]

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 <a href="https://github.com/Khan/khan-exercises/" rel="external">khan exercise framework</a>, so for Calculus One, he leads the development of <a href="/exercises">our interactive exercises</a>.
email: [email protected]
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 <a href="http://rubyonrails.org/" rel="external">Rails</a> to handle coding tasks for this website.
email: [email protected]
link: http://www.math.osu.edu/people/kowalick.1

Expand All @@ -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: [email protected]

sean-collins:
Expand All @@ -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: [email protected]

0 comments on commit 3f44924

Please sign in to comment.