VRFS-1577 VRFS-736 session ratings
This commit is contained in:
parent
c0834c92c7
commit
dddc0311c0
|
|
@ -145,4 +145,5 @@ user_progress_tracking2.sql
|
|||
bands_did_session.sql
|
||||
email_change_default_sender.sql
|
||||
affiliate_partners.sql
|
||||
chat_messages.sql
|
||||
chat_messages.sql
|
||||
session_ratings.sql
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE music_sessions_user_history ADD COLUMN rating_comment TEXT;
|
||||
|
|
@ -6,6 +6,7 @@ module JamRuby
|
|||
self.primary_key = 'id'
|
||||
|
||||
attr_accessible :max_concurrent_connections, :session_removed_at, :rating
|
||||
validates_inclusion_of :rating, :in => -1..1, :allow_nil => true
|
||||
|
||||
belongs_to(:user,
|
||||
:class_name => "JamRuby::User",
|
||||
|
|
@ -16,9 +17,6 @@ module JamRuby
|
|||
:class_name => "MusicSessionHistory",
|
||||
:foreign_key => "music_session_id")
|
||||
|
||||
validates_inclusion_of :rating, :in => 0..2, :allow_nil => true
|
||||
after_save :track_user_progression
|
||||
|
||||
def music_session_history
|
||||
@msh ||= JamRuby::MusicSessionHistory.find_by_music_session_id(self.music_session_id)
|
||||
end
|
||||
|
|
@ -104,10 +102,13 @@ module JamRuby
|
|||
self.perf_data.try(:uri)
|
||||
end
|
||||
|
||||
def track_user_progression
|
||||
if self.rating == 0
|
||||
user.update_progression_field(:first_good_music_session_at)
|
||||
def add_rating(rval, comment='')
|
||||
rval = rval.to_i
|
||||
if 0 != rval
|
||||
self.rating += rval
|
||||
self.rating_comment = comment
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ describe MusicSessionUserHistory do
|
|||
|
||||
describe "out of range" do
|
||||
before(:each) do
|
||||
user_history1.update_attribute(:rating, 3)
|
||||
user_history1.update_attribute(:rating, 2)
|
||||
user_history1.save
|
||||
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 |
|
|
@ -1309,7 +1309,8 @@
|
|||
evt.preventDefault();
|
||||
|
||||
promptLeave = false;
|
||||
context.window.location = '/client#/home';
|
||||
app.layout.showDialog('leavingSession');
|
||||
//context.window.location = '/client#/home';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -727,4 +727,26 @@ table.vu td {
|
|||
|
||||
#update-session-invite-musicians {
|
||||
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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ class ApiMusicSessionsController < ApiController
|
|||
end
|
||||
|
||||
def participant_rating
|
||||
@history = MusicSessionUserHistory.find(params[:id])
|
||||
@history.rating = params[:rating]
|
||||
if @history = MusicSessionUserHistory.find(params[:id])
|
||||
@history.add_rating(params[:rating])
|
||||
@history.save
|
||||
|
||||
if @history.errors.any?
|
||||
|
|
@ -161,6 +161,9 @@ class ApiMusicSessionsController < ApiController
|
|||
else
|
||||
render :json => {}, :status => :ok
|
||||
end
|
||||
else
|
||||
render :json => { :message => ValidationMessages::SESSION_NOT_FOUND }, :status => 404
|
||||
end
|
||||
end
|
||||
|
||||
def track_index
|
||||
|
|
|
|||
|
|
@ -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> <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> <a href="#" class="button-grey">NOT NOW, THANKS</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end inner -->
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -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"
|
||||
last_response.status.should == 200
|
||||
msuh.reload
|
||||
msuh.rating.should == 0
|
||||
msuh.rating.to_i.should == 0
|
||||
end
|
||||
|
||||
it "track sync" do
|
||||
|
|
|
|||
Loading…
Reference in New Issue