diff --git a/ruby/lib/jam_ruby/models/active_music_session.rb b/ruby/lib/jam_ruby/models/active_music_session.rb index cca5d6eda..dc10df5d1 100644 --- a/ruby/lib/jam_ruby/models/active_music_session.rb +++ b/ruby/lib/jam_ruby/models/active_music_session.rb @@ -767,8 +767,8 @@ module JamRuby feed.active = true feed.save - GoogleAnalyticsEvent.track_session_duration(self) - GoogleAnalyticsEvent.track_band_real_session(self) + #GoogleAnalyticsEvent.track_session_duration(self) + #GoogleAnalyticsEvent.track_band_real_session(self) end def open_jam_track(user, jam_track) diff --git a/ruby/lib/jam_ruby/models/connection.rb b/ruby/lib/jam_ruby/models/connection.rb index b8a2afdaf..5b1444fc7 100644 --- a/ruby/lib/jam_ruby/models/connection.rb +++ b/ruby/lib/jam_ruby/models/connection.rb @@ -162,7 +162,7 @@ module JamRuby self.connected? && self.as_musician? && 0 < (count = self.music_session.connected_participant_count) - GoogleAnalyticsEvent.report_session_participant(count) + #GoogleAnalyticsEvent.report_session_participant(count) end true end diff --git a/ruby/lib/jam_ruby/models/recording.rb b/ruby/lib/jam_ruby/models/recording.rb index 67585f678..c9550ba1a 100644 --- a/ruby/lib/jam_ruby/models/recording.rb +++ b/ruby/lib/jam_ruby/models/recording.rb @@ -224,7 +224,7 @@ module JamRuby recording.video = record_video if recording.save - GoogleAnalyticsEvent.report_band_recording(recording.band) + #GoogleAnalyticsEvent.report_band_recording(recording.band) # make quick mixes *before* the audio/video tracks, because this will give them precedence in list_uploads music_session.users.uniq.each do |user| diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 79eeaee36..91321138e 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -199,6 +199,7 @@ module JamRuby has_many :jam_track_session, :class_name => "JamRuby::JamTrackSession" + has_many :taken_lessons, :class_name => "JamRuby::LessonSession", inverse_of: :user, foreign_key: :user_id has_many :taught_lessons, :class_name => "JamRuby::LessonSession", inverse_of: :teacher, foreign_key: :teacher_id belongs_to :school, :class_name => "JamRuby::School", inverse_of: :students has_one :owned_school, :class_name => "JamRuby::School", inverse_of: :user @@ -1925,6 +1926,14 @@ module JamRuby lesson_purchases.where('lesson_package_type_id in (?)', LessonPackageType.test_drive_package_ids).where('created_at > ?', APP_CONFIG.test_drive_wait_period_year.years.ago).count == 0 end + def lessons_with_teacher(teacher) + taken_lessons.where(teacher_id: teacher.id) + end + + def lessons_with_student(student) + taught_lessons.where(user_id: student.id) + end + def has_test_drives? remaining_test_drives > 0 end diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 0a85887cf..1c00aac3e 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -2514,6 +2514,15 @@ }) } + function ratingDecision(options) { + return $.ajax({ + type: "GET", + url: '/api/lesson_sessions/rating_decision?' + $.param(options), + dataType: "json", + contentType: 'application/json' + }) + } + function initialize() { return self; } @@ -2739,6 +2748,7 @@ this.lessonStartTime = lessonStartTime; this.createReview = createReview; this.askSearchHelp = askSearchHelp; + this.ratingDecision = ratingDecision; return this; }; })(window,jQuery); diff --git a/web/app/assets/javascripts/react-components/RateUserDialog.js.jsx.coffee b/web/app/assets/javascripts/react-components/RateUserDialog.js.jsx.coffee index e460ba4b0..914859f5d 100644 --- a/web/app/assets/javascripts/react-components/RateUserDialog.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/RateUserDialog.js.jsx.coffee @@ -29,9 +29,14 @@ context = window logger.debug("RateUserDialog.beforeShow", args.d1) parsed = @parseId(args.d1) - @setState({student: null, teacher: null, type: parsed.type, id: parsed.id, rating: null}) + @setState({rating_decision: null, type: parsed.type, id: parsed.id, rating: null, willUpdate: false, description:''}) - rest.getUserDetail({id: parsed.id}).done((response) => @userLookupDone(response)).fail((jqXHR) => @userLookupFail(jqXHR)) + as_student = parsed.type == 'teacher' + rest.ratingDecision({ + as_student: as_student, + teacher_id: parsed.id, + student_id: parsed.id + }).done((response) => @userLookupDone(response)).fail((jqXHR) => @userLookupFail(jqXHR)) afterHide: () -> @@ -42,10 +47,10 @@ context = window @state.type == 'student' userLookupDone: (response) -> - if @isRatingTeacher() - @setState({teacher: response}) - else - @setState({student: response}) + value = response.rating?.rating + if value? + @setState({rating: value, description: response.rating?.description}) + @setState({rating_decision: response}) userLookupFail: (jqXHR) -> @app.ajaxError(jqXHR, null, null) @@ -123,62 +128,71 @@ context = window @app.ajaxError(jqXHR, null, null) disabled: () -> - !@state.rating? || (!@state.teacher? && !@state.student?) + !@state.rating? || (!@state.rating_decision?) + + willUpdate: (e) -> + e.preventDefault() + + @setState({willUpdate: true}) render: () -> submitClasses = classNames({'button-orange': true, disabled: @disabled()}) - if @isRatingTeacher() - title = 'Rate Teacher' - help = `