Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6e1dac9
Update README.md to include last semester's data
gavint7 Oct 16, 2024
d9124e8
Create mentor_meeting_controller.rb - per PR 2772
gavint7 Oct 21, 2024
79eec1c
Delete app/controllers/app directory
gavint7 Oct 21, 2024
e475012
Create mentor_meeting_controller.rb
gavint7 Oct 21, 2024
4ff187e
Delete app/controllers/E2460 Updates directory
gavint7 Oct 21, 2024
35febd4
Create mentor_meeting_controller.rb - created per changes from PR2772
gavint7 Oct 21, 2024
9e1bdd1
Update teams_controller.rb - PR 2772
gavint7 Oct 21, 2024
1566089
Update mailer_helper.rb - PR 2772
gavint7 Oct 21, 2024
0602254
Create mentor_meetings_helper.rb - PR2772
gavint7 Oct 21, 2024
b418552
Update mailer.rb - PR2772
gavint7 Oct 21, 2024
055a149
Create mentor_meeting.rb - PR 2772
gavint7 Oct 21, 2024
82dc488
Update mentored_team.rb - PR2772
gavint7 Oct 21, 2024
0a9b236
Update team.rb - PR 2772
gavint7 Oct 21, 2024
33d23ac
Update user.rb - PR2772
gavint7 Oct 21, 2024
c793563
Create _mentor_added_to_team_html.html.erb - PR2772
gavint7 Oct 21, 2024
58491f9
Create _mentor_added_to_team_plain.html.erb - PR2772
gavint7 Oct 21, 2024
445980a
Create _user_added_to_team_html.html.erb - PR2772
gavint7 Oct 21, 2024
ae6f2aa
Create _user_added_to_team_plain.html.erb - PR2772
gavint7 Oct 21, 2024
99638ba
Update _team.html.erb - PR2772
gavint7 Oct 21, 2024
ee83371
Create _entry_assignments.html.erb - PR2772
gavint7 Oct 21, 2024
e640f86
Create _page_footer_assignments.html.erb - PR2772
gavint7 Oct 21, 2024
6719e4c
Update routes.rb - PR2772
gavint7 Oct 21, 2024
5c2b777
Create 20240318185959_create_mentor_meetings.rb - PR2772
gavint7 Oct 21, 2024
18ab7c2
Create 20240318200827_remove_assignment_id_from_mentor_meetings.rb - …
gavint7 Oct 21, 2024
77dabe9
Update team_spec.rb - PR2772
gavint7 Oct 21, 2024
a849b91
Added + Add Meeting button to add meeting dates and added headings to…
gavint7 Oct 21, 2024
c1e6c75
added meeting capacity requirement and mentor/instructor functionalit…
gavint7 Oct 21, 2024
0ca7372
Implemented CRUD operations and added notifications for mentor meetings
akkireddyanusha Oct 23, 2024
c8f4bd4
Removed submodule, added CRUD operations for mentor meetings
akkireddyanusha Oct 24, 2024
1835407
Merge pull request #6 from gavint7/mentor-meeting-crud
akkireddyanusha Oct 24, 2024
7d188d3
added parameter handling and meeting record info
gavint7 Oct 24, 2024
cae33ff
Update _team.html.erb
gavint7 Oct 29, 2024
ba3f4e8
added current team mentor functionality to allow them to remove meeti…
gavint7 Oct 29, 2024
c3813e9
created meeting_date factory for testing
gavint7 Oct 29, 2024
23c412f
Create mentor_meeting_management_spec.rb
gavint7 Oct 29, 2024
255080b
Delete spec/models/mentor_meeting_management_spec.rb - did not need a…
gavint7 Oct 29, 2024
3fdc72c
add test for auto assign mentor false
gavint7 Oct 29, 2024
cdc54af
Update mentor_meeting_controller.rb
akkireddyanusha Oct 29, 2024
6cdab8d
Update mentor_meeting_notifications.rb
akkireddyanusha Oct 29, 2024
eb9b75b
Update mentor_meeting_controller.rb
akkireddyanusha Oct 29, 2024
25fc960
Implement mentor meeting controller with CRUD and notification features
akkireddyanusha Oct 29, 2024
34042b8
Add Dockerfile for Docker setup
akkireddyanusha Oct 29, 2024
7d890ee
modification to email
Oct 30, 2024
2db26cf
added test for new feature
Oct 30, 2024
a93285c
changed model to handle dual case
Oct 30, 2024
0317f67
Merge pull request #7 from gavint7/email_test
simong2 Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use an official Ruby runtime as a parent image
FROM ruby:2.7

# Install dependencies
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client

# Set up the working directory
WORKDIR /app

# Copy the Gemfile and Gemfile.lock into the container
COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock

# Install gems
RUN bundle install

# Copy the rest of the application files into the container
COPY . /app

# Precompile assets (if your app has assets)
RUN bundle exec rake assets:precompile || true

# Expose the port that the app runs on
EXPOSE 3000

# Start the server by default
CMD ["rails", "server", "-b", "0.0.0.0"]
1 change: 1 addition & 0 deletions E2460-MentorMeetingManagement
Submodule E2460-MentorMeetingManagement added at c1e6c7
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Expertiza
=========

MMM Last Semester's Pull Requests
Pull Request: (https://github.com/expertiza/expertiza/pull/2769)
Pull Request: (https://github.com/expertiza/expertiza/pull/2772)

Their Wiki (https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2403_Mentor-Meeting_Management)


[![Build Status](https://travis-ci.org/expertiza/expertiza.svg?branch=main)](https://travis-ci.org/expertiza/expertiza)
[![Coverage Status](https://coveralls.io/repos/github/expertiza/expertiza/badge.svg?branch=main)](https://coveralls.io/github/expertiza/expertiza?branch=main)
[![Maintainability](https://api.codeclimate.com/v1/badges/23b8a211854207919986/maintainability)](https://codeclimate.com/github/expertiza/expertiza/maintainability)
Expand Down
74 changes: 74 additions & 0 deletions app/controllers/mentor_meeting_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class MentorMeetingController < ApplicationController
include MentorMeetingsHelper

before_action :set_team_and_meeting, only: [:edit_date, :delete_date]

# Method to get meeting dates for a particular assignment
def get_dates
@mentor_meetings = MentorMeeting.all
render json: @mentor_meetings, status::ok
end

# Method to add meetings dates to the mentor_meetings table.
def add_date
team_id = params[:team_id]
meeting_date = params[:meeting_date]
@mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date)

if @mentor_meeting.save
MentorMeetingNotifications.send_notification(team_id, meeting_date)
render json: { status: 'success', message: "Meeting date added" }
else
render json: { status: 'error', message: "Unable to add meeting date" }
end
end


def edit_date
team_id = params[:team_id]
old_meeting_date = params[:old_date]
new_meeting_date = params[:new_date]

@meeting = MentorMeeting.where(team_id: team_id.to_i, meeting_date: old_meeting_date).first
if @meeting
@meeting.meeting_date = new_meeting_date
if @meeting.save
# Trigger notification after editing
ActiveSupport::Notifications.instrument('mentor_meeting.updated', team_id: team_id, old_meeting_date: old_meeting_date, new_meeting_date: new_meeting_date)
render json: { status: 'success', message: 'Meeting updated successfully' }
else
render json: { status: 'error', message: 'Failed to update meeting' }
end
else
render json: { status: 'error', message: 'Meeting not found' }
end
end


def delete_date
team_id = params[:team_id]
meeting_date = params[:meeting_date]
@meeting = MentorMeeting.where(team_id: team_id.to_i, meeting_date: meeting_date).first

if @meeting
@meeting.destroy
# Trigger notification after deletion
ActiveSupport::Notifications.instrument('mentor_meeting.deleted', team_id: team_id, meeting_date: meeting_date)
render json: { status: 'success', message: 'Meeting deleted successfully' }
else
render json: { status: 'error', message: 'Meeting not found' }
end
end

private

def meeting_dates_params #permitting parameters through the model
params.require(:meeting_dates).permit(:team_id, :date)
end

def set_team_and_meeting #means by which a specific team meeting can be found based on its parameters
@meeting = MentorMeeting.find_by(team_id: params[:team_id].to_i, meeting_date: params[:meeting_date])
render json: { status: 'error', message: 'Meeting not found' }, status: :not_found unless @meeting
end
end

21 changes: 20 additions & 1 deletion app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class TeamsController < ApplicationController
include AuthorizationHelper

include MentorMeetingsHelper

autocomplete :user, :name

# Check if the current user has TA privileges
Expand Down Expand Up @@ -53,6 +54,8 @@ def list
unless @assignment.nil?
if @assignment.auto_assign_mentor
@model = MentoredTeam
# MentorMeeting.delete_all
@mentor_meetings = MentorMeeting.all
else
@model = AssignmentTeam
end
Expand All @@ -61,6 +64,8 @@ def list
begin
@root_node = Object.const_get(session[:team_type] + 'Node').find_by(node_object_id: params[:id])
@child_nodes = @root_node.get_teams

@meetings_map = get_dates_for_team(@child_nodes)
rescue StandardError
flash[:error] = $ERROR_INFO
end
Expand Down Expand Up @@ -171,6 +176,20 @@ def copy_teams(operation)
redirect_to controller: 'teams', action: 'list', id: assignment.id
end

# Method to get meeting dates for a particular assignment
def get_mentor_meeting_dates
mentor_meetings = MentorMeeting.all # Or your query to fetch data
render json: mentor_meetings
end

# Method to add meetings dates to the mentor_meetings table.
def add_mentor_meeting_date
team_id = params[:team_id]
meeting_date = params[:meeting_date]
MentorMeeting.create(team_id: team_id, meeting_date: meeting_date)
render :json => { :status => 'success', :message => "Ok"}
end

# Abstraction over different methods
def choose_copy_type(assignment, operation)
course = Course.find(assignment.course_id)
Expand Down
16 changes: 16 additions & 0 deletions app/helpers/mailer_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ def self.send_mail_to_user(user, subject, partial_name, password)
)
end

def self.send_team_confirmation_mail_to_user(user, subject, partial_name, team_name, assignment_name)
# This function serves as a helper to send emails to users letting them know they have added to a team
# note that the below hash is sent to a view html that has the partial_name
Mailer.generic_message(
to: user.email,
subject: subject,
body: {
user: user,
first_name: ApplicationHelper.get_user_first_name(user),
partial_name: partial_name,
team: team_name,
assignment: assignment_name
}
)
end

def self.send_mail_to_all_super_users(super_user, user, subject)
Mailer.request_user_message(
to: super_user.email,
Expand Down
14 changes: 14 additions & 0 deletions app/helpers/mentor_meetings_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module MentorMeetingsHelper

def get_dates_for_team(children)
@meeting_map = {}

children.each do |child|
team_id = child.node_object_id.to_i
@meeting_map[team_id] = MentorMeeting.where(team_id: team_id).pluck(:meeting_date)
end

@meeting_map
end

end
3 changes: 2 additions & 1 deletion app/mailers/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def generic_message(defn)
@avg_pct = defn[:body][:avg_pct]
@assignment = defn[:body][:assignment]
@conference_variable = defn[:body][:conference_variable]

@team = defn[:body][:team] # team name

if Rails.env.development? || Rails.env.test?
defn[:to] = 'expertiza.mailer@gmail.com'
end
Expand Down
5 changes: 5 additions & 0 deletions app/models/mentor_meeting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MentorMeeting < ApplicationRecord
def self.table
'mentor_meetings'
end
end
9 changes: 9 additions & 0 deletions app/models/mentor_meeting_notifications.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class MentorMeetingNotifications
def self.send_notification(team_id, meeting_date)
ActiveSupport::Notifications.instrument('mentor_meeting.created', team_id: team_id, meeting_date: meeting_date)
end
end

ActiveSupport::Notifications.subscribe('mentor_meeting.created') do |name, start, finish, id, payload|
puts "New meeting created for team #{payload[:team_id]} on #{payload[:meeting_date]}"
end
13 changes: 13 additions & 0 deletions app/models/mentored_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@ def add_member(user, _assignment_id = nil)
TeamUserNode.create(parent_id: parent.id, node_object_id: t_user.id)
add_participant(parent_id, user)
ExpertizaLogger.info LoggerMessage.new('Model:Team', user.name, "Added member to the team #{id}")

assignment_name = _assignment_id ? Assignment.find(_assignment_id).name.to_s : ""
# mentor only
if MentorManagement.user_a_mentor?(user) && !user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver
# participant only
elsif !MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "user_added_to_team", "#{name}", assignment_name).deliver
# dual case
elsif MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "dual_role_added_to_team", "#{name}", assignment_name).deliver
end
end

if can_add_member
MentorManagement.assign_mentor(_assignment_id, id)
end
Expand Down
19 changes: 19 additions & 0 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ def add_member(user, _assignment_id = nil)
TeamUserNode.create(parent_id: parent.id, node_object_id: t_user.id)
add_participant(parent_id, user)
ExpertizaLogger.info LoggerMessage.new('Model:Team', user.name, "Added member to the team #{id}")

# if assignment_id is nil, then don't send an assignment name
assignment_name = _assignment_id ? Assignment.find(_assignment_id).name.to_s : ""

# addressing efg's comment in previous PR
# if just mentor
if MentorManagement.user_a_mentor?(user) && !user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver

# only a participant
elsif !MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "user_added_to_team", "#{name}", assignment_name).deliver

# both mentor and participant
elsif MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "dual_role_added_to_team", "#{name}", assignment_name).deliver

end

end
can_add_member
end
Expand Down
7 changes: 7 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,10 @@ def self.search_users(role, user_id, letter, search_by)
users
end
end


def get_user_details(name)
user = User.where('name = ?', name).first
end

public :get_user_details
11 changes: 11 additions & 0 deletions app/views/mailer/partials/_dual_role_added_to_team_html.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Hi <%= @first_name %>,
<BR>
<p>
You have been added to Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza.
</p>
<p>
Please note that you are assigned both as a <strong>mentor</strong> and a <strong>participant</strong> for this team.
</p>
<p>
Expertiza Team
</p>
8 changes: 8 additions & 0 deletions app/views/mailer/partials/_mentor_added_to_team_html.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Hi <%= @first_name %>,
<BR>
<p>
You are now mentoring Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza.
</p>
<p>
Expertiza Team
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Hi <%= @first_name %>,

You are now mentoring Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza.

Expertiza Team
8 changes: 8 additions & 0 deletions app/views/mailer/partials/_user_added_to_team_html.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Hi <%= @first_name %>,
<BR>
<p>
You have been added to Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza.
</p>
<p>
Expertiza Team
</p>
5 changes: 5 additions & 0 deletions app/views/mailer/partials/_user_added_to_team_plain.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Hi <%= @first_name %>,

You have been added to Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza.

Expertiza Team
Loading