Skip to content

Commit

Permalink
Meeting Scheduling (#20)
Browse files Browse the repository at this point in the history
* Added meetings overview to tutors dashboard and added ability to cancel meetings for students and ability to edit tutor requests

* Created integration test for meetings

* Removed failing test

* Fixed remaining tests

* Added status to tutor meetings
  • Loading branch information
cdvillegas authored Dec 14, 2019
1 parent db06cdd commit afdeb8a
Show file tree
Hide file tree
Showing 34 changed files with 19,450 additions and 215 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified app/.DS_Store
Binary file not shown.
Binary file modified app/assets/.DS_Store
Binary file not shown.
Binary file added app/assets/javascripts/.DS_Store
Binary file not shown.
11 changes: 11 additions & 0 deletions app/assets/javascripts/tutor.js
Original file line number Diff line number Diff line change
@@ -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 += `<div> ${element} </div>`;
document.getElementById('testing').appendChild(div);
}
}
16 changes: 16 additions & 0 deletions app/assets/stylesheets/tutors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 19 additions & 3 deletions app/controllers/meetings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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])

Expand All @@ -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
34 changes: 33 additions & 1 deletion app/controllers/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/tutees_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions app/controllers/tutors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/models/meeting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified app/views/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion app/views/application/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<div class="topnav">
<a href=<%= tutors_path %>>Logout</a>
<a href=<% tutor_path(@tutor) %>><%= @tutor.first_name + "'s Profile"%></a>
<a href="">Meetings</a>
<a href=<%= tutor_find_students_path(@tutor) %>>Find a Student</a>

</div>
40 changes: 31 additions & 9 deletions app/views/meetings/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'}
40 changes: 39 additions & 1 deletion app/views/requests/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
});
6 changes: 3 additions & 3 deletions app/views/tutees/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Binary file modified app/views/tutors/.DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion app/views/tutors/find_students.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-8 offset-md-2 col-lg-6 offset-lg-3 m-top-10">
<form action=<%= tutor_path(@tutor) %> method="GET">
<input type="submit" class="btn btn-primary" value="Back"/>
</form>
</div>
<div class="col-12 col-md-8 offset-md-2 col-lg-6 offset-lg-3 m-top-10">
<h1 class="text-center">Students on the Queue</h1>
Expand Down Expand Up @@ -120,7 +123,7 @@
<input name="Location3" id="Location3" type="text" placeholder="Location" required>
</div>
</div>
<input name="addMore" id="addMore" type="button" value="Add Another" onclick="addElement();">
<input name="addMore" class = "btn btn-primary m-top-10" id="addMore" type="button" value="Add Another" onclick="addElement();">
<button class="btn btn-primary m-top-10" type="reset">Reset</button>
<input class="btn btn-primary m-top-10" type="submit" value="Submit">
</div>
Expand Down
Loading

0 comments on commit afdeb8a

Please sign in to comment.