VRFS-1577 VRFS-736 session ratings

This commit is contained in:
Jonathan Kolyer 2014-04-30 14:07:23 +00:00
parent c0834c92c7
commit dddc0311c0
13 changed files with 60 additions and 13 deletions

View File

@ -145,4 +145,5 @@ user_progress_tracking2.sql
bands_did_session.sql bands_did_session.sql
email_change_default_sender.sql email_change_default_sender.sql
affiliate_partners.sql affiliate_partners.sql
chat_messages.sql chat_messages.sql
session_ratings.sql

View File

@ -0,0 +1 @@
ALTER TABLE music_sessions_user_history ADD COLUMN rating_comment TEXT;

View File

@ -6,6 +6,7 @@ module JamRuby
self.primary_key = 'id' self.primary_key = 'id'
attr_accessible :max_concurrent_connections, :session_removed_at, :rating attr_accessible :max_concurrent_connections, :session_removed_at, :rating
validates_inclusion_of :rating, :in => -1..1, :allow_nil => true
belongs_to(:user, belongs_to(:user,
:class_name => "JamRuby::User", :class_name => "JamRuby::User",
@ -16,9 +17,6 @@ module JamRuby
:class_name => "MusicSessionHistory", :class_name => "MusicSessionHistory",
:foreign_key => "music_session_id") :foreign_key => "music_session_id")
validates_inclusion_of :rating, :in => 0..2, :allow_nil => true
after_save :track_user_progression
def music_session_history def music_session_history
@msh ||= JamRuby::MusicSessionHistory.find_by_music_session_id(self.music_session_id) @msh ||= JamRuby::MusicSessionHistory.find_by_music_session_id(self.music_session_id)
end end
@ -104,10 +102,13 @@ module JamRuby
self.perf_data.try(:uri) self.perf_data.try(:uri)
end end
def track_user_progression def add_rating(rval, comment='')
if self.rating == 0 rval = rval.to_i
user.update_progression_field(:first_good_music_session_at) if 0 != rval
self.rating += rval
self.rating_comment = comment
end end
end end
end end
end end

View File

@ -26,7 +26,7 @@ describe MusicSessionUserHistory do
describe "out of range" do describe "out of range" do
before(:each) do before(:each) do
user_history1.update_attribute(:rating, 3) user_history1.update_attribute(:rating, 2)
user_history1.save user_history1.save
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1309,7 +1309,8 @@
evt.preventDefault(); evt.preventDefault();
promptLeave = false; promptLeave = false;
context.window.location = '/client#/home'; app.layout.showDialog('leavingSession');
//context.window.location = '/client#/home';
return false; return false;
} }

View File

@ -727,4 +727,26 @@ table.vu td {
#update-session-invite-musicians { #update-session-invite-musicians {
margin: 10px; margin: 10px;
} }
.rate-thumbsup {
width:64px;
height:64px;
display:inline-block;
background-image:url('/assets/content/icon_thumbsup_big_off.png');
}
.rate-thumbsup.selected {
background-image:url('/assets/content/icon_thumbsup_big_on.png');
}
.rate-thumbsdown {
width:64px;
height:64px;
display:inline-block;
background-image:url('/assets/content/icon_thumbsdown_big_off.png');
}
.rate-thumbsdown.selected {
background-image:url('/assets/content/icon_thumbsdown_big_on.png');
}

View File

@ -151,8 +151,8 @@ class ApiMusicSessionsController < ApiController
end end
def participant_rating def participant_rating
@history = MusicSessionUserHistory.find(params[:id]) if @history = MusicSessionUserHistory.find(params[:id])
@history.rating = params[:rating] @history.add_rating(params[:rating])
@history.save @history.save
if @history.errors.any? if @history.errors.any?
@ -161,6 +161,9 @@ class ApiMusicSessionsController < ApiController
else else
render :json => {}, :status => :ok render :json => {}, :status => :ok
end end
else
render :json => { :message => ValidationMessages::SESSION_NOT_FOUND }, :status => 404
end
end end
def track_index def track_index

View File

@ -0,0 +1,18 @@
<div class="dialog" layout="dialog" layout-id="leavingSession" id="leaving-session-dialog">
<div class="dialog-overlay-sm">
<!-- dialog header -->
<div class="content-head">
<img src="images/content/icon_session.png" width="19" height="19" class="content-icon"><h1>please rate your session</h1>
</div>
<div class="dialog-inner">
<div class="center">
<a class="rate-thumbsup" href="javascript:void(0)"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="rate-thumbsdown"></a>
<br clear="left"><br>
<textarea class="w80" rows="3">Tell us more about what you liked or didn't like...</textarea>
<br><br>
<a href="#" class="button-orange">SEND FEEDBACK</a>&nbsp;&nbsp;&nbsp;<a href="#" class="button-grey">NOT NOW, THANKS</a>
</div>
</div>
<!-- end inner -->
</div>
</div>

View File

@ -659,7 +659,7 @@ describe "Music Session API ", :type => :api do
post "/api/participant_histories/#{msuh.id}/rating.json", { :rating => 0 }.to_json, "CONTENT_TYPE" => "application/json" post "/api/participant_histories/#{msuh.id}/rating.json", { :rating => 0 }.to_json, "CONTENT_TYPE" => "application/json"
last_response.status.should == 200 last_response.status.should == 200
msuh.reload msuh.reload
msuh.rating.should == 0 msuh.rating.to_i.should == 0
end end
it "track sync" do it "track sync" do