diff --git a/.DS_Store b/.DS_Store index f175ec8b..0f2bcf10 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/app/.DS_Store b/app/.DS_Store index 1ad53b55..0356fcc2 100644 Binary files a/app/.DS_Store and b/app/.DS_Store differ diff --git a/app/assets/.DS_Store b/app/assets/.DS_Store index 96543321..3418a5a7 100644 Binary files a/app/assets/.DS_Store and b/app/assets/.DS_Store differ diff --git a/app/assets/javascripts/.DS_Store b/app/assets/javascripts/.DS_Store new file mode 100644 index 00000000..d025298a Binary files /dev/null and b/app/assets/javascripts/.DS_Store differ diff --git a/app/assets/javascripts/tutor.js b/app/assets/javascripts/tutor.js new file mode 100644 index 00000000..4b1b8cb3 --- /dev/null +++ b/app/assets/javascripts/tutor.js @@ -0,0 +1,11 @@ +/* +* meta = [list as list of Strings] +*/ +function dispMeetings(list) { + const vals = meta[0]; + vals.each {|element| + var div = document.createElement("div"); + div.innerHTML += `
${element}
`; + document.getElementById('testing').appendChild(div); + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/tutors.scss b/app/assets/stylesheets/tutors.scss index 3cc27bd0..41654e77 100644 --- a/app/assets/stylesheets/tutors.scss +++ b/app/assets/stylesheets/tutors.scss @@ -124,6 +124,22 @@ body{ color: #6c757d; cursor: pointer; } + +.profile-new-stud-btn{ + border: none; + border-radius: 15px; + width: 110%; + height: 40px; + font-weight: 600; + color: white; + cursor: pointer; + background-color: #1188ff; +} + +.glyphicon.glyphicon-off { + font-size: 30px; +} + .proile-rating{ font-size: 12px; color: #818182; diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb index 58a8e152..dd187951 100644 --- a/app/controllers/meetings_controller.rb +++ b/app/controllers/meetings_controller.rb @@ -13,10 +13,15 @@ def show @tutee = Tutee.find_by_id(params[:tutee_id]) @req = Request.where(tutee_id: params[:tutee_id]) @meeting = Meeting.where(request_id: @req).last - @eval = Evaluation.where(id: @meeting.evaluation_id).first if not @meeting.nil? - @dates = @meeting.times.map {|time| time.strftime("%A %d at %H:%M")} + @tutor = Tutor.find_by_id(@meeting.tutor_id) + @eval = Evaluation.find_by_id(@meeting.evaluation_id) + if @eval.status == "Complete" + @meeting = nil + return + end + @dates = @meeting.times.map.with_index {|time, i| [time.strftime("%A %d at %l:%M %p at ") + @meeting.locations[i], i]}.to_h end end @@ -32,7 +37,9 @@ def create # Checks if parameters are good @req = Request.where(tutee_id: params[:tutee_id]) @meeting = Meeting.where(request_id: @req).last - @meeting.setTime = params[:meeting][:setTime] + @meeting.set_time = @meeting.times[params[:meeting][:set_time].to_i] + @meeting.set_location = @meeting.locations[params[:meeting][:set_time].to_i] + @meeting.is_scheduled = true @meeting.save! @tutee = Tutee.find_by_id(params[:tutee_id]) @@ -42,5 +49,14 @@ def create def update end def destroy + @req = Request.where(tutee_id: params[:tutee_id]) + @meeting = Meeting.where(request_id: @req).last + @eval = Evaluation.find_by_id(@meeting.evaluation_id) + @meeting.destroy! + @eval.destroy! + @tutee = Tutee.find_by_id(params[:tutee_id]) + + flash[:message] = "Your meeting was successfully cancelled. Another tutor will match with you." + redirect_to tutee_meeting_path(@tutee, 1) end end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 00d8f8b1..35a7c6ef 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -22,6 +22,11 @@ def new @tutee = Tutee.find_by_id(params[:tutee_id]) @course_array = Course.course_array @meeting_time = %w(60\ minutes 90\ minutes 120\ minutes) + @tutee_last_req = @tutee.requests.last + if not @tutee_last_req.nil? + @meet_for_last_req = @tutee.meetings.where(:request_id => @tutee_last_req.id).first + end + if @tutee.privilege == 'No' @has_privilege = false @@ -32,6 +37,26 @@ def new end def edit + # Checks if parameters are good + @request = Request.find_by_id(params[:id]) + @tutee = Tutee.find_by_id(params[:tutee_id]) + if request_params[:subject].blank? + flash[:notice] = "Invalid request: Subject should be filled out." + redirect_to new_tutee_request_path(:tutee_id => params[:tutee_id]) + return + else + @request.course_id = request_params[:course_id] + @request.subject = request_params[:subject] + if @tutee.privilege == 'No' + @request.meeting_length = '60 minutes' + else + @request.meeting_length = request_params[:meeting_length] + end + @request.save! + + flash[:message] = "Tutoring request for class #{@request.course.name} was successfully changed!" + end + redirect_to tutee_path(@tutee) end def create @@ -83,7 +108,14 @@ def email i += 1 end - @meeting = Meeting.create({:tutor_id => tid.to_i, :request_id => requestid.to_i, :evaluation_id => @eval.id, :tutee_id => sid, :times => @times}); + @locs = [] + i = 1 + while not params["Location" + i.to_s].nil? + @locs << params["Location" + i.to_s] + i += 1 + end + + @meeting = Meeting.create({:tutor_id => tid.to_i, :request_id => requestid.to_i, :evaluation_id => @eval.id, :tutee_id => sid, :times => @times, :locations => @locs}); #TutorMailer.invite_student(tid, sid, tutor_message, requestid, @eval.id).deliver_now flash[:notice] = "Successfully matched!" redirect_to tutor_path(tid) diff --git a/app/controllers/tutees_controller.rb b/app/controllers/tutees_controller.rb index 223560ff..a949d982 100644 --- a/app/controllers/tutees_controller.rb +++ b/app/controllers/tutees_controller.rb @@ -17,9 +17,13 @@ def show @tutee = Tutee.find_by_id(params[:id]) @requests = @tutee.requests.where('created_at >= ?', Date.today.beginning_of_week.strftime("%Y-%m-%d")) @evaluations = @tutee.evaluations - @meeting = Meeting.where(request_id: @requests.last).last + @meeting = Meeting.where(request_id: @requests).last if not @meeting.nil? - @lastEval = Evaluation.where(id: @meeting.evaluation_id).first + @lastEval = Evaluation.find_by_id( @meeting.evaluation_id) + if @lastEval.status == "Complete" + @meeting = nil + return + end end end diff --git a/app/controllers/tutors_controller.rb b/app/controllers/tutors_controller.rb index a4ed2bc0..e97950e8 100644 --- a/app/controllers/tutors_controller.rb +++ b/app/controllers/tutors_controller.rb @@ -17,6 +17,21 @@ def find_students # GET /tutors/1.json def show @tutor = Tutor.find_by_id(params[:id]) + @meetings = Meeting.where("set_time > ? and tutor_id = ?", Time.now, params[:id]) + + @test = Request.all + @testing = @test.map{|req| req.evaluation.nil?} + @abc = @testing.last + + @meeting_times = @meetings.map{|meet| meet.set_time.strftime("on %A %d at %l:%M %p")} + @meeting_locations = @meetings.map{|meet| meet.set_location.titleize} + @meeting_evals = @meetings.map{|meet| Evaluation.find_by_id(meet.evaluation_id)} + @meeting_evals_status = @meeting_evals.map{|eval| eval.status} + @meeting_evals_took_place = @meeting_evals.map{|eval| eval.took_place} + @meeting_tutees = @meetings.map{|meet| Tutee.find_by_id(meet.tutee_id)} + @meeting_emails = @meeting_tutees.map{|tutee| tutee.email} + @meeting_names = @meeting_tutees.map{|tutee| tutee.first_name + " " + tutee.last_name} + end # GET /tutors/new diff --git a/app/models/meeting.rb b/app/models/meeting.rb index 16417d16..4976a3fd 100644 --- a/app/models/meeting.rb +++ b/app/models/meeting.rb @@ -5,9 +5,9 @@ class Meeting < ApplicationRecord has_one :tutee def isExpired - if self.setTime.nil? - return true + if self.set_time.nil? + return false end - return self.setTime < Time.now + return self.set_time < Time.now end end diff --git a/app/views/.DS_Store b/app/views/.DS_Store index d016917b..5e500ad2 100644 Binary files a/app/views/.DS_Store and b/app/views/.DS_Store differ diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index 3e137494..bc6e35f7 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -2,7 +2,6 @@
>Logout ><%= @tutor.first_name + "'s Profile"%> - Meetings >Find a Student
\ No newline at end of file diff --git a/app/views/meetings/show.html.haml b/app/views/meetings/show.html.haml index e1fac06b..96cff633 100644 --- a/app/views/meetings/show.html.haml +++ b/app/views/meetings/show.html.haml @@ -3,15 +3,31 @@ .card.mb-3 .card-header You have no scheduled meetings. - -elsif not @meeting.setTime.nil? + -elsif not @meeting.set_time.nil? -if @meeting.isExpired .card.mb-3 - .card-header - You have no scheduled meetings. + .card-header + You have no scheduled meetings. -else .card.mb-3 - .card-header - Your Next Meeting is Scheduled for #{@meeting.setTime.strftime("%A %d at %H:%M")}! + .card-header + %span.glyphicon.glyphicon-map-marker + Your Next Meeting Info + .card-body + %h5 Time & Date: + #{@meeting.set_time.strftime("%A %d at %l:%M %p")} + .card-body + %h5 Location: + #{@meeting.set_location.titleize} + .card-body + %h5 Class: + #{@req.last.course.name} + .card-body + %h5 Tutor: + #{@tutor.first_name + " " + @tutor.last_name} + .card-body + %h5 Tutor Email: + #{@tutor.email} -else / Breadcrumbs %ol.breadcrumb @@ -27,12 +43,18 @@ - if flash[:message] .alert.alert-danger %span.error= flash[:message] - = form_tag tutee_meetings_path(:tutee_id=>1), class: 'container-fluid' do + = form_tag tutee_meetings_path(:tutee_id => params[:tutee_id]), class: 'container-fluid' do .form-row .form-group.col-md-4 - = label :meeting, :tutee_id, 'Please pick a time:' - = select :meeting, :setTime, options_for_select(@dates), class: 'form-control' + Please pick a time: + = select :meeting, :set_time, options_for_select(@dates), class: 'form-control' - = submit_tag 'Set Up Meeting', :id=>'setup_meeting', class: 'btn btn-primary' + = submit_tag 'Schedule Meeting', :id=>'setup_meeting', class: 'btn btn-primary' + .card-body + = form_tag tutee_meeting_path(:tutee_id => params[:tutee_id], :id => 1),:method => :delete, class: 'container-fluid' do + .form-row + .form-group.col-md-6 + If none of these times work you can cancel this meeting and wait to match with another tutor + = submit_tag 'Cancel Meeting', :id=>'cancel_meeting', class: 'btn btn-secondary' .card-footer.small.text-muted Updated at #{ @tutee.updated_at.in_time_zone('Pacific Time (US & Canada)').to_s + ' PST'} diff --git a/app/views/requests/new.html.haml b/app/views/requests/new.html.haml index f552b185..bc753b84 100644 --- a/app/views/requests/new.html.haml +++ b/app/views/requests/new.html.haml @@ -2,7 +2,34 @@ -if @tutee.evaluations.where(:status => 'Pending').first .card.mb-3 .card-header - Please fill out pending evaluation forms. + Your request has been matched! Please fill out the evaluation form after your meeting. + -elsif not @tutee_last_req.nil? and @meet_for_last_req.nil? + .card.mb-3 + .card-header + %span.glyphicon.glyphicon-time + Pending Request + .card-body{:style => "margin-left: 14px;"} + Your request for #{@tutee_last_req.get_class} in #{@tutee_last_req.subject.titleize} hasn't been matched yet + %div + %button{id: "but", class: "btn btn-secondary", :style => "margin-top: 10px;"} Edit Request + .card.mb-3{:hidden => true, :id => "edit_form"} + .card-body + = form_tag edit_tutee_request_path(:tutee_id => params[:tutee_id], :id => @tutee_last_req.id ),:method => :get, class: 'container-fluid' do + .form-row + .form-group.col-md-4 + = label :request, :course_id, 'Please pick a course:' + = select :request, :course_id, options_for_select(@course_array), {:id =>'course_list'}, class: 'form-control' + .form-group.col-md-4 + = label :request, :subject, 'What topics you would like to cover?' + = text_field :request, 'subject', class: 'form-control', :placeholder => 'e.g. Recusrion', :required => "", + :oninput => "this.setCustomValidity('')", :oninvalid => "this.setCustomValidity('Cannot be empty')" + .form-row + .form-group.col-md-6 + - if @has_privilege + = label :request, :meeting_length, 'Please choose how long you would like the meeting be?' + = select :request, :meeting_length, options_for_select(@meeting_time), {:id =>'meeting_time'}, class: 'form-control' + + = submit_tag 'Submit Changes', :id=>'edit_request', class: 'btn btn-primary' -else / Breadcrumbs %ol.breadcrumb @@ -37,3 +64,14 @@ = submit_tag 'Request Tutor', :id=>'request_tutor', class: 'btn btn-primary' .card-footer.small.text-muted Updated at #{ @tutee.updated_at.in_time_zone('Pacific Time (US & Canada)').to_s + ' PST'} + + +:javascript + var form = document.getElementById('edit_form'); + var addButton = document.getElementById('but'); + + $(addButton).click(function(e){ + e.preventDefault(); + form.hidden = false + addButton.hidden = true + }); diff --git a/app/views/tutees/show.html.haml b/app/views/tutees/show.html.haml index 22d9964a..d48d5617 100644 --- a/app/views/tutees/show.html.haml +++ b/app/views/tutees/show.html.haml @@ -14,12 +14,12 @@ .card-body-icon %i.glyphicon.glyphicon-map-marker .mr-5 - -if not @meeting.nil? and @meeting.setTime.nil? + -if not @meeting.nil? and @meeting.set_time.nil? = "Set Up Next Meeting" -elsif @meeting.nil? or @meeting.isExpired = "No Pending Meetings" -else - = "Next Meeting " + @meeting.setTime.strftime("%a %d at %H:%M") + = "Next Meeting " + @meeting.set_time.strftime("%a %d at %l:%M %p") %a.card-footer.text-white.clearfix.small.z-1{:href => tutee_meeting_path(@tutee, 1)} %span.float-left View Details %span.float-right @@ -40,7 +40,7 @@ .card-body-icon %i.glyphicon.glyphicon-shopping-cart .mr-5 #{@requests.count - @evaluations.where(created_at: Date.today.beginning_of_week.strftime("%Y-%m-%d")..Time.now).count} Pending Requests! - %a.card-footer.text-white.clearfix.small.z-1{:href => '#request'} + %a.card-footer.text-white.clearfix.small.z-1{:href => new_tutee_request_path(@tutee)} %span.float-left View Details %span.float-right %i.glyphicon.glyphicon-shopping-cart diff --git a/app/views/tutors/.DS_Store b/app/views/tutors/.DS_Store index f9d4ba41..51ce7a29 100644 Binary files a/app/views/tutors/.DS_Store and b/app/views/tutors/.DS_Store differ diff --git a/app/views/tutors/find_students.html.erb b/app/views/tutors/find_students.html.erb index dadf5755..2d8f87c4 100644 --- a/app/views/tutors/find_students.html.erb +++ b/app/views/tutors/find_students.html.erb @@ -29,6 +29,9 @@
+
method="GET"> + +

Students on the Queue

@@ -120,7 +123,7 @@
- +
diff --git a/app/views/tutors/show.html.erb b/app/views/tutors/show.html.erb index eadd1153..655f2189 100644 --- a/app/views/tutors/show.html.erb +++ b/app/views/tutors/show.html.erb @@ -1,11 +1,22 @@ <% if notice %> <%= render "notice_success" %> <% end %> +<%= javascript_tag "meeting_times = #{@meeting_times.to_json.html_safe};" %> +<%= javascript_tag "meeting_names = #{@meeting_names.to_json.html_safe};" %> +<%= javascript_tag "meeting_emails = #{@meeting_emails.to_json.html_safe};" %> +<%= javascript_tag "meeting_locations = #{@meeting_locations.to_json.html_safe};" %> +<%= javascript_tag "meeting_evals_status = #{@meeting_evals_status.to_json.html_safe};" %> +<%= javascript_tag "meeting_evals_took_place = #{@meeting_evals_took_place.to_json.html_safe};" %> + <%= stylesheet_link_tag "tutors" %> -<%= render "navbar" %> +<%= stylesheet_link_tag "dataTables.bootstrap4.min.css" %> + -
+
+
+ > +
@@ -17,9 +28,18 @@
<%= @tutor.first_name %> <%= @tutor.last_name%>
-
+
<%=@tutor.type_of_tutor%>
+
+ +
    +
+
+
+
@@ -144,7 +167,39 @@
+
+
+
+ +
+
+
- \ No newline at end of file + + + \ No newline at end of file diff --git a/config/.DS_Store b/config/.DS_Store new file mode 100644 index 00000000..9fb05e52 Binary files /dev/null and b/config/.DS_Store differ diff --git a/coverage/index.html b/coverage/index.html index 0a5e976f..95fd7866 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -5,7 +5,7 @@ - + @@ -14,27 +14,27 @@ loading