From 6e1dac9869217df639eaa41e69cf9524ba7d138a Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:37:42 -0400 Subject: [PATCH 01/44] Update README.md to include last semester's data --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 57d9118cade..6488ca3535d 100644 --- a/README.md +++ b/README.md @@ -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) From d9124e8ab6c8579dc3ae50198bf54d0d76e9ed97 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:16:57 -0400 Subject: [PATCH 02/44] Create mentor_meeting_controller.rb - per PR 2772 --- .../controllers/mentor_meeting_controller.rb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/controllers/app/controllers/mentor_meeting_controller.rb diff --git a/app/controllers/app/controllers/mentor_meeting_controller.rb b/app/controllers/app/controllers/mentor_meeting_controller.rb new file mode 100644 index 00000000000..330cf49a66c --- /dev/null +++ b/app/controllers/app/controllers/mentor_meeting_controller.rb @@ -0,0 +1,41 @@ +class MentorMeetingController < ApplicationController + include MentorMeetingsHelper + + # Method to get meeting dates for a particular assignment + def get_dates + @mentor_meetings = MentorMeeting.all + render json: @mentor_meetings + 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) + @mentor_meeting.save + render :json => { :status => 'success', :message => "Ok"} + 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 + render :json => { :status => 'success', :message => "Ok"} + end + 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 + @meeting.destroy + render :json => { :status => 'success', :message => "Ok"} + end + +end From 79eec1c2734caf809c0228fee32326c4370992eb Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:18:42 -0400 Subject: [PATCH 03/44] Delete app/controllers/app directory --- .../controllers/mentor_meeting_controller.rb | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 app/controllers/app/controllers/mentor_meeting_controller.rb diff --git a/app/controllers/app/controllers/mentor_meeting_controller.rb b/app/controllers/app/controllers/mentor_meeting_controller.rb deleted file mode 100644 index 330cf49a66c..00000000000 --- a/app/controllers/app/controllers/mentor_meeting_controller.rb +++ /dev/null @@ -1,41 +0,0 @@ -class MentorMeetingController < ApplicationController - include MentorMeetingsHelper - - # Method to get meeting dates for a particular assignment - def get_dates - @mentor_meetings = MentorMeeting.all - render json: @mentor_meetings - 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) - @mentor_meeting.save - render :json => { :status => 'success', :message => "Ok"} - 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 - render :json => { :status => 'success', :message => "Ok"} - end - 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 - @meeting.destroy - render :json => { :status => 'success', :message => "Ok"} - end - -end From e475012b8bba45c5a36bee63387d111558936715 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:20:47 -0400 Subject: [PATCH 04/44] Create mentor_meeting_controller.rb Created aand made directory for controller updates per this project --- .../mentor_meeting_controller.rb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/controllers/E2460 Updates/mentor_meeting_controller.rb diff --git a/app/controllers/E2460 Updates/mentor_meeting_controller.rb b/app/controllers/E2460 Updates/mentor_meeting_controller.rb new file mode 100644 index 00000000000..330cf49a66c --- /dev/null +++ b/app/controllers/E2460 Updates/mentor_meeting_controller.rb @@ -0,0 +1,41 @@ +class MentorMeetingController < ApplicationController + include MentorMeetingsHelper + + # Method to get meeting dates for a particular assignment + def get_dates + @mentor_meetings = MentorMeeting.all + render json: @mentor_meetings + 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) + @mentor_meeting.save + render :json => { :status => 'success', :message => "Ok"} + 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 + render :json => { :status => 'success', :message => "Ok"} + end + 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 + @meeting.destroy + render :json => { :status => 'success', :message => "Ok"} + end + +end From 4ff187e5a47a7a6a7b75172f7944cf574f7ebdc1 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:21:49 -0400 Subject: [PATCH 05/44] Delete app/controllers/E2460 Updates directory --- .../mentor_meeting_controller.rb | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 app/controllers/E2460 Updates/mentor_meeting_controller.rb diff --git a/app/controllers/E2460 Updates/mentor_meeting_controller.rb b/app/controllers/E2460 Updates/mentor_meeting_controller.rb deleted file mode 100644 index 330cf49a66c..00000000000 --- a/app/controllers/E2460 Updates/mentor_meeting_controller.rb +++ /dev/null @@ -1,41 +0,0 @@ -class MentorMeetingController < ApplicationController - include MentorMeetingsHelper - - # Method to get meeting dates for a particular assignment - def get_dates - @mentor_meetings = MentorMeeting.all - render json: @mentor_meetings - 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) - @mentor_meeting.save - render :json => { :status => 'success', :message => "Ok"} - 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 - render :json => { :status => 'success', :message => "Ok"} - end - 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 - @meeting.destroy - render :json => { :status => 'success', :message => "Ok"} - end - -end From 35febd49700148caea6107305137dab08db99db7 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:23:56 -0400 Subject: [PATCH 06/44] Create mentor_meeting_controller.rb - created per changes from PR2772 --- app/controllers/mentor_meeting_controller.rb | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/controllers/mentor_meeting_controller.rb diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb new file mode 100644 index 00000000000..330cf49a66c --- /dev/null +++ b/app/controllers/mentor_meeting_controller.rb @@ -0,0 +1,41 @@ +class MentorMeetingController < ApplicationController + include MentorMeetingsHelper + + # Method to get meeting dates for a particular assignment + def get_dates + @mentor_meetings = MentorMeeting.all + render json: @mentor_meetings + 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) + @mentor_meeting.save + render :json => { :status => 'success', :message => "Ok"} + 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 + render :json => { :status => 'success', :message => "Ok"} + end + 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 + @meeting.destroy + render :json => { :status => 'success', :message => "Ok"} + end + +end From 9e1bdd1fddd72f1c89ccda8498eed090f1633024 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:48:43 -0400 Subject: [PATCH 07/44] Update teams_controller.rb - PR 2772 --- app/controllers/teams_controller.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 1d2fd966a3d..055a7cc29ed 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -1,6 +1,7 @@ class TeamsController < ApplicationController include AuthorizationHelper - + include MentorMeetingsHelper + autocomplete :user, :name # Check if the current user has TA privileges @@ -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 @@ -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 @@ -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) From 15660892195b070e3211b8bc0984b23e08e753dc Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:16:58 -0400 Subject: [PATCH 08/44] Update mailer_helper.rb - PR 2772 --- app/helpers/mailer_helper.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 568f35788c1..bc052d0aa81 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -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, From 06022541e43af7fcf6c5f2527d0bb085009c0e00 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:18:32 -0400 Subject: [PATCH 09/44] Create mentor_meetings_helper.rb - PR2772 --- app/helpers/mentor_meetings_helper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/helpers/mentor_meetings_helper.rb diff --git a/app/helpers/mentor_meetings_helper.rb b/app/helpers/mentor_meetings_helper.rb new file mode 100644 index 00000000000..4618be97634 --- /dev/null +++ b/app/helpers/mentor_meetings_helper.rb @@ -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 From b41855232601b366c6225f04c5f718b7b07c1a82 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:20:18 -0400 Subject: [PATCH 10/44] Update mailer.rb - PR2772 --- app/mailers/mailer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index b96924fbf6c..4d4ccf1e3ef 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -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 From 055a14980c5647fdaa1d1d0616916ed2f5e3fd34 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:40:06 -0400 Subject: [PATCH 11/44] Create mentor_meeting.rb - PR 2772 --- app/models/mentor_meeting.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/models/mentor_meeting.rb diff --git a/app/models/mentor_meeting.rb b/app/models/mentor_meeting.rb new file mode 100644 index 00000000000..1281200e41b --- /dev/null +++ b/app/models/mentor_meeting.rb @@ -0,0 +1,5 @@ +class MentorMeeting < ApplicationRecord + def self.table + 'mentor_meetings' + end +end From 82dc488b2c0fa22a830fba6765fe75d12b5d35c4 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:46:17 -0400 Subject: [PATCH 12/44] Update mentored_team.rb - PR2772 --- app/models/mentored_team.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/mentored_team.rb b/app/models/mentored_team.rb index daccd65d37d..e009d8948e2 100644 --- a/app/models/mentored_team.rb +++ b/app/models/mentored_team.rb @@ -12,6 +12,13 @@ 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 : "" + if MentorManagement.user_a_mentor?(user) + MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver + elsif !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 + end end if can_add_member MentorManagement.assign_mentor(_assignment_id, id) From 0a9b23678569a9959432ef19669b98f1cfbbb145 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:49:49 -0400 Subject: [PATCH 13/44] Update team.rb - PR 2772 --- app/models/team.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/models/team.rb b/app/models/team.rb index 9786c55431b..9298e1b32d7 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -88,6 +88,18 @@ 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 : "" + # Now that a new team member has been added to a team, send an email to them letting them know + if MentorManagement.user_a_mentor?(user) + MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver + elsif !user.is_a?(Participant) + # If the user is a participant, then we don't went to send them emails since that class is something + # completely out of the scope of this project + MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "user_added_to_team", "#{name}", assignment_name).deliver + end + end can_add_member end From 33d23ac2e8575be7b1d81f0450fe194f75f03223 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:52:12 -0400 Subject: [PATCH 14/44] Update user.rb - PR2772 --- app/models/user.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 38e80f15b36..2e0d8582f9d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 From c793563d5b00a5d31ba5e8341b785749c39c410e Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:58:27 -0400 Subject: [PATCH 15/44] Create _mentor_added_to_team_html.html.erb - PR2772 --- .../mailer/partials/_mentor_added_to_team_html.html.erb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 app/views/mailer/partials/_mentor_added_to_team_html.html.erb diff --git a/app/views/mailer/partials/_mentor_added_to_team_html.html.erb b/app/views/mailer/partials/_mentor_added_to_team_html.html.erb new file mode 100644 index 00000000000..1fc320c8ec1 --- /dev/null +++ b/app/views/mailer/partials/_mentor_added_to_team_html.html.erb @@ -0,0 +1,8 @@ +Hi <%= @first_name %>, +
+

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

+

+ Expertiza Team +

From 58491f93652eff30720b9c548a9baad753760ed7 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:59:23 -0400 Subject: [PATCH 16/44] Create _mentor_added_to_team_plain.html.erb - PR2772 --- .../mailer/partials/_mentor_added_to_team_plain.html.erb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/views/mailer/partials/_mentor_added_to_team_plain.html.erb diff --git a/app/views/mailer/partials/_mentor_added_to_team_plain.html.erb b/app/views/mailer/partials/_mentor_added_to_team_plain.html.erb new file mode 100644 index 00000000000..c943a3a8f3f --- /dev/null +++ b/app/views/mailer/partials/_mentor_added_to_team_plain.html.erb @@ -0,0 +1,5 @@ +Hi <%= @first_name %>, + +You are now mentoring Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza. + +Expertiza Team From 445980a454a8557a1b76021675edaaefa619ef7d Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:00:12 -0400 Subject: [PATCH 17/44] Create _user_added_to_team_html.html.erb - PR2772 --- .../mailer/partials/_user_added_to_team_html.html.erb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 app/views/mailer/partials/_user_added_to_team_html.html.erb diff --git a/app/views/mailer/partials/_user_added_to_team_html.html.erb b/app/views/mailer/partials/_user_added_to_team_html.html.erb new file mode 100644 index 00000000000..eb8e15d7df5 --- /dev/null +++ b/app/views/mailer/partials/_user_added_to_team_html.html.erb @@ -0,0 +1,8 @@ +Hi <%= @first_name %>, +
+

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

+

+ Expertiza Team +

From ae6f2aa0659eb44b53e1473902acb3ba50212a28 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:03:28 -0400 Subject: [PATCH 18/44] Create _user_added_to_team_plain.html.erb - PR2772 --- app/views/mailer/partials/_user_added_to_team_plain.html.erb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/views/mailer/partials/_user_added_to_team_plain.html.erb diff --git a/app/views/mailer/partials/_user_added_to_team_plain.html.erb b/app/views/mailer/partials/_user_added_to_team_plain.html.erb new file mode 100644 index 00000000000..4ca128adf37 --- /dev/null +++ b/app/views/mailer/partials/_user_added_to_team_plain.html.erb @@ -0,0 +1,5 @@ +Hi <%= @first_name %>, + +You have been added to Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza. + +Expertiza Team From 99638ba435dde2cc5cd0cd21a80091f45511259f Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:05:07 -0400 Subject: [PATCH 19/44] Update _team.html.erb - PR2772 --- app/views/teams/_team.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb index a45b599012b..b2bc6338818 100644 --- a/app/views/teams/_team.html.erb +++ b/app/views/teams/_team.html.erb @@ -1,3 +1,8 @@ +<% if @model == MentoredTeam %> + <%= render :partial => '/tree_display/page_footer_assignments', :locals => { :assignment_id => @root_node.node_object_id, :@meeting_map => @meeting_map } %>
+<% else %> + <%= render :partial => '/tree_display/page_footer' %>
+ Show all team members <%= render :partial => '/tree_display/page_footer' %>
<% session[:return_to] = request.url %> From ee83371c8bf67a4dbc0d05c1b78b4f2ab42bf7f1 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:06:24 -0400 Subject: [PATCH 20/44] Create _entry_assignments.html.erb - PR2772 --- .../tree_display/_entry_assignments.html.erb | 243 ++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 app/views/tree_display/_entry_assignments.html.erb diff --git a/app/views/tree_display/_entry_assignments.html.erb b/app/views/tree_display/_entry_assignments.html.erb new file mode 100644 index 00000000000..a3f778f0a72 --- /dev/null +++ b/app/views/tree_display/_entry_assignments.html.erb @@ -0,0 +1,243 @@ +<% + team_name = prefix.split('_').first + team_id = team_name.to_i +%> +<% + def find_date(team_id, index) + @meeting_map[team_id].length !=0 ? @meeting_map[team_id][index].to_s : '' + end +%> +<% child_nodes = node.get_children(@sortvar,@sortorder,session[:user].id,@show,@search) %> +<% + @student_full_names = [] + @student_email = [] + @student_names = [] + @student_count = 0 + @student_ids = [] + child_nodes.each_with_index do |child_node,index| + child_node_name = child_node.get_name(session[:ip]) + if child_node_name.include?("(Mentor)") + child_node_name = child_node_name.gsub(" (Mentor)", "") + end + @user = User.get_user_details(child_node_name) + @full_name = @user.fullname.gsub(/(\d+),\s*(\w+)/, '\2 \1') + if child_node.get_name(session[:ip]).include?("(Mentor)") + @ta_name = @full_name + @ta_username = @user.name + else + @student_full_names << @full_name + @student_email << @user.email + @student_names << @user.name + @student_ids << child_node.node_object_id + end + end + + @student_count = @student_names.length + while @student_names.length < 3 + @student_names << "" + end + @combined_full_names = @student_full_names.join(", ") + @combined_emails = @student_email.join(", ") +%> +<% + @can_edit = (session["user"].role_id == 2 or (session["user"].name == @ta_username)) +%> + +class="<%= rowtype %>" id="<%= prefix %>" + <% elsif prefix != nil %>id="<%= prefix %>" style="display: none;" name="team member" + <% end %> +> + + <%= team_name %> + + + <%= @combined_full_names %> + + <% @student_names.each_with_index do |name, idx| %> + <% if not name.empty? %> + <%= name %>
+ <%= link_to image_tag("delete_icon.png", :border=>0, :alt => "Delete Team User", :title => "Delete Team User"), :controller=>'teams_users', :action=>'delete', :id => @student_ids[idx] %> + + <% else + @can_edit = false + %> + + <% end %> + <% end %> + + <%= @combined_emails %> + + <% if @student_count == 3 %> + + <%= @ta_name %> + + <% else %> + + <% end %> + <%= render :partial => '/tree_display/actions/'+node.get_partial_name, + :locals => {:node => node} %> + <% + (1..@max_dates_length).each do |index| + %> + + > + + <% + end + %> + + + <%= image_tag("plus.png", :border=>0, :alt => "Add new date column", :title => "Add new date column") %> + + + + + From e640f86b3d82171a0a8b926536cde4b7e4cbe9b8 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:11:36 -0400 Subject: [PATCH 21/44] Create _page_footer_assignments.html.erb - PR2772 --- .../_page_footer_assignments.html.erb | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 app/views/tree_display/_page_footer_assignments.html.erb diff --git a/app/views/tree_display/_page_footer_assignments.html.erb b/app/views/tree_display/_page_footer_assignments.html.erb new file mode 100644 index 00000000000..1391fb28b03 --- /dev/null +++ b/app/views/tree_display/_page_footer_assignments.html.erb @@ -0,0 +1,50 @@ +<% + max_dates_length = 0 + + @meeting_map.each_value do |value| + max_dates_length = value.length if value.length > max_dates_length + end + + if max_dates_length < 3 + max_dates_length = 3 + end +%> +<% if @child_nodes.length > 0 %> + + + + + + + + + + + + <% + (3..max_dates_length - 1).each do |index| + %> + + <% + end + %> + + + + <% + @child_nodes.each_with_index do |node,index| + if index.odd? + rowtype = "odd" + else + rowtype = "even" + end + %> + + + <%= render :partial=> '/tree_display/entry_assignments', :locals => {:search => @search, :node => node, :prefix => node.node_object_id.to_s+"_"+index.to_s, :depth => 0, :rowtype => rowtype, :assignment_id => assignment_id, :@meeting_map => @meeting_map, :@max_dates_length => max_dates_length} %> + + <% + end + %> +
+<% end %> From 6719e4cad6873b83007ec52398260768b28366e5 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:16:04 -0400 Subject: [PATCH 22/44] Update routes.rb - PR2772 --- config/routes.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index c2ae428631d..e573ebc667b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -664,5 +664,11 @@ post '/sample_reviews/unmap/:id' => 'sample_reviews#unmap_from_assignment' post 'student_task/publishing_rights_update', controller: :student_task, action: :publishing_rights_update, method: :put get 'student_view/flip_view', controller: :student_view, action: :flip_view + + get 'get_dates', controller: :mentor_meeting, action: :get_dates + post 'add_date', controller: :mentor_meeting, action: :add_date + patch 'edit_date', controller: :mentor_meeting, action: :edit_date + post 'delete_date', controller: :mentor_meeting, action: :delete_date + # updated route and added specific controller action upon accessing this route end From 5c2b777580923ceeab00ab72b91797922f97e592 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:21:36 -0400 Subject: [PATCH 23/44] Create 20240318185959_create_mentor_meetings.rb - PR2772 --- .../20240318185959_create_mentor_meetings.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/migrate/20240318185959_create_mentor_meetings.rb diff --git a/db/migrate/20240318185959_create_mentor_meetings.rb b/db/migrate/20240318185959_create_mentor_meetings.rb new file mode 100644 index 00000000000..bf06e112232 --- /dev/null +++ b/db/migrate/20240318185959_create_mentor_meetings.rb @@ -0,0 +1,18 @@ +class CreateMentorMeetings < ActiveRecord::Migration[5.1] + def self.up + create_table :mentor_meetings do |t| + t.column :team_id, :integer, null: false + t.column :assignment_id, :integer, null: false + t.column :meeting_date, :string, null: false + end + + execute "ALTER TABLE `mentor_meetings` + ADD CONSTRAINT `fk_mentor_meetings_mapping_team` + FOREIGN KEY (team_id) references teams(id)" + + execute "ALTER TABLE `mentor_meetings` + ADD CONSTRAINT `fk_mentor_meetings_mapping_assignment` + FOREIGN KEY (assignment_id) references assignments(id)" + + end +end From 18ab7c233a2c39612a2c1350624ffffa1a835658 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:24:32 -0400 Subject: [PATCH 24/44] Create 20240318200827_remove_assignment_id_from_mentor_meetings.rb - PR2772 --- ...18200827_remove_assignment_id_from_mentor_meetings.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20240318200827_remove_assignment_id_from_mentor_meetings.rb diff --git a/db/migrate/20240318200827_remove_assignment_id_from_mentor_meetings.rb b/db/migrate/20240318200827_remove_assignment_id_from_mentor_meetings.rb new file mode 100644 index 00000000000..e7d1c6a6911 --- /dev/null +++ b/db/migrate/20240318200827_remove_assignment_id_from_mentor_meetings.rb @@ -0,0 +1,9 @@ +class RemoveAssignmentIdFromMentorMeetings < ActiveRecord::Migration[5.1] + def up + # Remove the foreign key constraint + execute "ALTER TABLE `mentor_meetings` DROP FOREIGN KEY `fk_mentor_meetings_mapping_assignment`" + + # Remove the column + remove_column :mentor_meetings, :assignment_id + end +end From 77dabe9026389aa78f69e859abd07d96b2fe947d Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:39:54 -0400 Subject: [PATCH 25/44] Update team_spec.rb - PR2772 --- spec/models/team_spec.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb index 146d3e6bfea..51d5af72776 100644 --- a/spec/models/team_spec.rb +++ b/spec/models/team_spec.rb @@ -97,13 +97,32 @@ context 'when parameterized user did not join in current team yet' do context 'when current team is not full' do - it 'does not raise an error' do + before do allow_any_instance_of(Team).to receive(:user?).with(user).and_return(false) allow_any_instance_of(Team).to receive(:full?).and_return(false) allow(TeamsUser).to receive(:create).with(user_id: 1, team_id: 1).and_return(team_user) allow(TeamNode).to receive(:find_by).with(node_object_id: 1).and_return(double('TeamNode', id: 1)) allow_any_instance_of(Team).to receive(:add_participant).with(1, user).and_return(double('Participant')) + end + + it 'sends mail to mentor if user is a mentor' do + allow(MentorManagement).to receive(:user_a_mentor?).with(user).and_return(true) + allow(Assignment).to receive(:find).with(1).and_return(assignment) + allow(MailerHelper).to receive(:send_team_confirmation_mail_to_user).and_return(double('Mail', deliver: true)) + + expect(MailerHelper).to receive(:send_team_confirmation_mail_to_user).with(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{team.name}", "").and_return(double('Mail', deliver: true)) + + expect(team.add_member(user)).to be true + end + + it 'sends mail to user if user is a user' do + allow(MentorManagement).to receive(:user_a_mentor?).with(user).and_return(false) + allow(Assignment).to receive(:find).with(1).and_return(assignment) + allow(MailerHelper).to receive(:send_team_confirmation_mail_to_user).and_return(double('Mail', deliver: true)) + + expect(MailerHelper).to receive(:send_team_confirmation_mail_to_user).with(user, "[Expertiza] Added to a Team", "user_added_to_team", "#{team.name}", "").and_return(double('Mail', deliver: true)) expect(team.add_member(user)).to be true + end end end From a849b915f2d8b3504aaed3bd059115afa0c569e4 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:36:30 -0400 Subject: [PATCH 26/44] Added + Add Meeting button to add meeting dates and added headings to clarify team view a bit --- app/views/teams/_team.html.erb | 40 ++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb index b2bc6338818..51ac90245c6 100644 --- a/app/views/teams/_team.html.erb +++ b/app/views/teams/_team.html.erb @@ -7,13 +7,15 @@ <%= render :partial => '/tree_display/page_footer' %>
<% session[:return_to] = request.url %> <% @model %> + +

Team List

+
<%= link_to 'Create Team', :action => 'new', :id=> @root_node.node_object_id, :model => @model %> -<% if @root_node.class == AssignmentNode %> - <% modelType = 'AssignmentTeam' %> -<% else %> - <% modelType = 'CourseTeam' %> -<% end %> -| <%= link_to 'Import Teams', +<% modelType = @root_node.class == AssignmentNode ? 'AssignmentTeam' : 'CourseTeam' %> + +// reformat team actions +
+ <%= link_to 'Import Teams', :controller=>'import_file', :action=>'start', :model => modelType, @@ -27,4 +29,28 @@ :id=>@root_node.node_object_id %> |<%= link_to 'Delete All Teams', :action => 'delete_all', :id=> @root_node.node_object_id, :model => @model %> |<%= link_to 'Bequeath All Teams', :action=>'bequeath_all', :id => @root_node.node_object_id, :model => @model %> -|<%= render :partial => '/shared_scripts/back' %> +
+ +// additional functionality to include meeting dates and add the + button to add more meetings. LLM assisted in developing this coede. +
+

Mentor Meeting Dates

+
+
+ +
+
+ +
+ + <%= render partial: '/shared_scripts/back' %> +
+ + From c1e6c750acc39255283558f7b97c869f644f09a3 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:59:21 -0400 Subject: [PATCH 27/44] added meeting capacity requirement and mentor/instructor functionality to edit/remove meetings contingent upon team % capacity --- app/views/teams/_team.html.erb | 41 ++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb index 51ac90245c6..123526fbdfe 100644 --- a/app/views/teams/_team.html.erb +++ b/app/views/teams/_team.html.erb @@ -35,22 +35,45 @@

Mentor Meeting Dates

-
- -
+ <% @teams.each do |team| %> +
+

<%= team.name %>

+

Mentor: <%= team.mentor.name %>

+

Members: <%= team.members.map(&:name).join(', ') %>

+ +
+

Meeting Dates

+ <% team.meeting_dates.each do |date| %> +
+ /> + <% if current_user.instructor? %> + + <% end %> +
+ <% end %> +
-
- - <%= render partial: '/shared_scripts/back' %> +<% end %> + + + + From 0ca7372c69f0b571582a1f506585e6fdf1368259 Mon Sep 17 00:00:00 2001 From: Anusha_Akkireddy Date: Wed, 23 Oct 2024 17:43:37 -0400 Subject: [PATCH 28/44] Implemented CRUD operations and added notifications for mentor meetings --- app/controllers/mentor_meeting_controller.rb | 34 ++++++++++++++++---- app/models/mentor_meeting_notifications.rb | 11 +++++++ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 app/models/mentor_meeting_notifications.rb diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb index 330cf49a66c..101083d6f08 100644 --- a/app/controllers/mentor_meeting_controller.rb +++ b/app/controllers/mentor_meeting_controller.rb @@ -12,30 +12,52 @@ 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) - @mentor_meeting.save - render :json => { :status => 'success', :message => "Ok"} + + 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 - render :json => { :status => 'success', :message => "Ok"} + # 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 - @meeting.destroy - render :json => { :status => 'success', :message => "Ok"} + + 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 + end diff --git a/app/models/mentor_meeting_notifications.rb b/app/models/mentor_meeting_notifications.rb new file mode 100644 index 00000000000..afcebed2e01 --- /dev/null +++ b/app/models/mentor_meeting_notifications.rb @@ -0,0 +1,11 @@ +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 + +# Subscribe to the notification and define what action to take +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]}" + # Here, you can replace the notification logic to send an email, SMS, etc. +end From c8f4bd4baae2b9e898aa6639e5e97616dbefd6c0 Mon Sep 17 00:00:00 2001 From: Anusha_Akkireddy Date: Thu, 24 Oct 2024 17:36:55 -0400 Subject: [PATCH 29/44] Removed submodule, added CRUD operations for mentor meetings --- E2460-MentorMeetingManagement | 1 + 1 file changed, 1 insertion(+) create mode 160000 E2460-MentorMeetingManagement diff --git a/E2460-MentorMeetingManagement b/E2460-MentorMeetingManagement new file mode 160000 index 00000000000..c1e6c750acc --- /dev/null +++ b/E2460-MentorMeetingManagement @@ -0,0 +1 @@ +Subproject commit c1e6c750acc39255283558f7b97c869f644f09a3 From 7d188d33ba68246d0f7d81aeef68a9f62bc8f1c5 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:04:24 -0400 Subject: [PATCH 30/44] added parameter handling and meeting record info --- app/controllers/mentor_meeting_controller.rb | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb index 101083d6f08..77d29f99eea 100644 --- a/app/controllers/mentor_meeting_controller.rb +++ b/app/controllers/mentor_meeting_controller.rb @@ -1,16 +1,19 @@ 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 + 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] + meeting_dates_params.each do |team_id, dates| + dates.each do |date| + next if date.blank? @mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date) if @mentor_meeting.save @@ -21,8 +24,6 @@ def add_date end end - - def edit_date team_id = params[:team_id] old_meeting_date = params[:old_date] @@ -58,6 +59,16 @@ def delete_date 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 + From cae33ff59fdfd59d5162b04d05cf6443910bcb4d Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:14:03 -0400 Subject: [PATCH 31/44] Update _team.html.erb --- app/views/teams/_team.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb index 123526fbdfe..e109e484d68 100644 --- a/app/views/teams/_team.html.erb +++ b/app/views/teams/_team.html.erb @@ -31,7 +31,7 @@ |<%= link_to 'Bequeath All Teams', :action=>'bequeath_all', :id => @root_node.node_object_id, :model => @model %>
-// additional functionality to include meeting dates and add the + button to add more meetings. LLM assisted in developing this coede. +// additional functionality to include meeting dates and add the + button to add more meetings.

Mentor Meeting Dates

From ba3f4e899e9aba55e9cef0207300d18ae2a51846 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:48:07 -0400 Subject: [PATCH 32/44] added current team mentor functionality to allow them to remove meetings for only the teams that they mentor. --- app/views/teams/_team.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb index e109e484d68..c2936e9ceb9 100644 --- a/app/views/teams/_team.html.erb +++ b/app/views/teams/_team.html.erb @@ -47,12 +47,12 @@
/> - <% if current_user.instructor? %> + <% if current_user.instructor? || current_user == team.mentor %> //current team mentor and instructor can remove <% end %>
<% end %> - +
<% end %> From c3813e98ffabfc5b951aa64717bed7e46b2fc62f Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:50:56 -0400 Subject: [PATCH 33/44] created meeting_date factory for testing --- spec/factories/factories.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb index c359e784672..2765ebf380c 100644 --- a/spec/factories/factories.rb +++ b/spec/factories/factories.rb @@ -761,4 +761,10 @@ ta_id 1 course_id 1 end + +factory :meeting_date, class: MeetingDate do + date { Date.today } # Default to today's date + team # Assumes you have a team association set up + end + end From 23c412f82edb9a94609d41127d5379ffa396fd81 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:07:45 -0400 Subject: [PATCH 34/44] Create mentor_meeting_management_spec.rb --- spec/models/mentor_meeting_management_spec.rb | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 spec/models/mentor_meeting_management_spec.rb diff --git a/spec/models/mentor_meeting_management_spec.rb b/spec/models/mentor_meeting_management_spec.rb new file mode 100644 index 00000000000..a7a45c186eb --- /dev/null +++ b/spec/models/mentor_meeting_management_spec.rb @@ -0,0 +1,83 @@ +require 'rails_helper' + +#created with help from LLM + +RSpec.describe 'Mentor Meetings Management', type: :system do + before do + driven_by(:rack_test) # or :selenium_chrome if you're using a browser + @mentor = create(:mentor) + @instructor = create(:instructor) + @team = create(:team, capacity: 5) # example capacity + @under_capacity_team = create(:team, capacity: 2, members_count: 1) + @meeting_date = create(:meeting_date, team: @team) + end + + context 'when viewing teams and mentors' do + it 'displays all teams, members, and mentors' do + visit teams_path + expect(page).to have_content(@team.name) + expect(page).to have_content(@mentor.name) + expect(page).to have_content(@instructor.name) + end + end + + context 'when a mentor adds/edit meeting dates for their team' do + it 'allows mentors to add a meeting date' do + sign_in(@mentor) # Assuming you have a method for signing in + visit team_path(@team) + click_button 'Add Meeting Date' + fill_in 'Meeting Date', with: '2024-11-01' + click_button 'Save' + + expect(page).to have_content('Meeting Date added successfully') + expect(page).to have_content('2024-11-01') + end + + it 'allows mentors to edit a meeting date' do + sign_in(@mentor) + visit team_path(@team) + click_link 'Edit Meeting Date' + fill_in 'Meeting Date', with: '2024-11-15' + click_button 'Save' + + expect(page).to have_content('Meeting Date updated successfully') + expect(page).to have_content('2024-11-15') + end + end + + context 'when an instructor edits meeting dates for all teams' do + it 'allows instructors to edit meeting dates' do + sign_in(@instructor) + visit team_path(@team) + click_link 'Edit Meeting Date' + fill_in 'Meeting Date', with: '2024-11-20' + click_button 'Save' + + expect(page).to have_content('Meeting Date updated successfully') + expect(page).to have_content('2024-11-20') + end + end + + context 'when inputting multiple meeting dates' do + it 'allows input of multiple meeting dates' do + sign_in(@mentor) + visit team_path(@team) + click_button 'Add Multiple Meeting Dates' + fill_in 'Meeting Dates', with: '2024-11-01, 2024-11-08' + click_button 'Save' + + expect(page).to have_content('Meeting Dates added successfully') + expect(page).to have_content('2024-11-01') + expect(page).to have_content('2024-11-08') + end + end + + context 'when handling under-capacity teams' do + it 'disables date fields for under-capacity teams' do + sign_in(@mentor) + visit team_path(@under_capacity_team) + + expect(page).to have_selector('input[disabled]', id: 'meeting_date') + end + end +end From 255080b05cf3584342351cc17afb0eb068d814af Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:10:28 -0400 Subject: [PATCH 35/44] Delete spec/models/mentor_meeting_management_spec.rb - did not need as there was an existing spec test to work off of --- spec/models/mentor_meeting_management_spec.rb | 83 ------------------- 1 file changed, 83 deletions(-) delete mode 100644 spec/models/mentor_meeting_management_spec.rb diff --git a/spec/models/mentor_meeting_management_spec.rb b/spec/models/mentor_meeting_management_spec.rb deleted file mode 100644 index a7a45c186eb..00000000000 --- a/spec/models/mentor_meeting_management_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'rails_helper' - -#created with help from LLM - -RSpec.describe 'Mentor Meetings Management', type: :system do - before do - driven_by(:rack_test) # or :selenium_chrome if you're using a browser - @mentor = create(:mentor) - @instructor = create(:instructor) - @team = create(:team, capacity: 5) # example capacity - @under_capacity_team = create(:team, capacity: 2, members_count: 1) - @meeting_date = create(:meeting_date, team: @team) - end - - context 'when viewing teams and mentors' do - it 'displays all teams, members, and mentors' do - visit teams_path - expect(page).to have_content(@team.name) - expect(page).to have_content(@mentor.name) - expect(page).to have_content(@instructor.name) - end - end - - context 'when a mentor adds/edit meeting dates for their team' do - it 'allows mentors to add a meeting date' do - sign_in(@mentor) # Assuming you have a method for signing in - visit team_path(@team) - click_button 'Add Meeting Date' - fill_in 'Meeting Date', with: '2024-11-01' - click_button 'Save' - - expect(page).to have_content('Meeting Date added successfully') - expect(page).to have_content('2024-11-01') - end - - it 'allows mentors to edit a meeting date' do - sign_in(@mentor) - visit team_path(@team) - click_link 'Edit Meeting Date' - fill_in 'Meeting Date', with: '2024-11-15' - click_button 'Save' - - expect(page).to have_content('Meeting Date updated successfully') - expect(page).to have_content('2024-11-15') - end - end - - context 'when an instructor edits meeting dates for all teams' do - it 'allows instructors to edit meeting dates' do - sign_in(@instructor) - visit team_path(@team) - click_link 'Edit Meeting Date' - fill_in 'Meeting Date', with: '2024-11-20' - click_button 'Save' - - expect(page).to have_content('Meeting Date updated successfully') - expect(page).to have_content('2024-11-20') - end - end - - context 'when inputting multiple meeting dates' do - it 'allows input of multiple meeting dates' do - sign_in(@mentor) - visit team_path(@team) - click_button 'Add Multiple Meeting Dates' - fill_in 'Meeting Dates', with: '2024-11-01, 2024-11-08' - click_button 'Save' - - expect(page).to have_content('Meeting Dates added successfully') - expect(page).to have_content('2024-11-01') - expect(page).to have_content('2024-11-08') - end - end - - context 'when handling under-capacity teams' do - it 'disables date fields for under-capacity teams' do - sign_in(@mentor) - visit team_path(@under_capacity_team) - - expect(page).to have_selector('input[disabled]', id: 'meeting_date') - end - end -end From 3fdc72cfd322008f75e5f77781f12ead79d0d6f6 Mon Sep 17 00:00:00 2001 From: gavint7 <33268509+gavint7@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:42:26 -0400 Subject: [PATCH 36/44] add test for auto assign mentor false --- spec/models/mentor_management_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/models/mentor_management_spec.rb b/spec/models/mentor_management_spec.rb index 1a818eafdb4..2df9240b480 100644 --- a/spec/models/mentor_management_spec.rb +++ b/spec/models/mentor_management_spec.rb @@ -1,3 +1,5 @@ +#require 'rails_helper' + describe MentorManagement do # using let! so that state is automatically set up before each example group # this could also be accomplished with before(:each) and instance methods @@ -165,6 +167,14 @@ # There should be no assigning of mentors expect(Team).to receive(:add_member).exactly(0).times end + + describe '#update_mentor_state' do + it 'does not assign if `auto_assign_mentor` is false' do + no_mentor_assignment = create(:assignment, auto_assign_mentor: false) + + expect(Team).not_to receive(:add_member) + MentorManagement.assign_mentor(no_mentor_assignment.id, team.id) + end end context 'when the assignment or team already have a topic' do From cdc54af866e351f07d514b407e72dcaaf63e0cc0 Mon Sep 17 00:00:00 2001 From: Anusha Akkireddy <41582420+akkireddyanusha@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:30:43 -0400 Subject: [PATCH 37/44] Update mentor_meeting_controller.rb --- app/controllers/mentor_meeting_controller.rb | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb index 77d29f99eea..845184a6eec 100644 --- a/app/controllers/mentor_meeting_controller.rb +++ b/app/controllers/mentor_meeting_controller.rb @@ -10,19 +10,20 @@ def get_dates end # Method to add meetings dates to the mentor_meetings table. - def add_date - meeting_dates_params.each do |team_id, dates| - dates.each do |date| - next if date.blank? - @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 +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 + # Trigger notification after saving + ActiveSupport::Notifications.instrument('mentor_meeting.created', team_id: team_id, meeting_date: meeting_date) + render json: { status: 'success', message: 'Meeting created successfully' } + else + render json: { status: 'error', message: 'Failed to create meeting' } end +end + def edit_date team_id = params[:team_id] From 6cdab8daa248e65da925df90af6e93e9e7a1ae1b Mon Sep 17 00:00:00 2001 From: Anusha Akkireddy <41582420+akkireddyanusha@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:48:59 -0400 Subject: [PATCH 38/44] Update mentor_meeting_notifications.rb --- app/models/mentor_meeting_notifications.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/mentor_meeting_notifications.rb b/app/models/mentor_meeting_notifications.rb index afcebed2e01..4ee02f08588 100644 --- a/app/models/mentor_meeting_notifications.rb +++ b/app/models/mentor_meeting_notifications.rb @@ -4,8 +4,6 @@ def self.send_notification(team_id, meeting_date) end end -# Subscribe to the notification and define what action to take 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]}" - # Here, you can replace the notification logic to send an email, SMS, etc. end From eb9b75baaaaa94d4c203a5ccfc751f30d61c10a8 Mon Sep 17 00:00:00 2001 From: Anusha Akkireddy <41582420+akkireddyanusha@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:51:11 -0400 Subject: [PATCH 39/44] Update mentor_meeting_controller.rb --- app/controllers/mentor_meeting_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb index 845184a6eec..c4ec017870f 100644 --- a/app/controllers/mentor_meeting_controller.rb +++ b/app/controllers/mentor_meeting_controller.rb @@ -16,11 +16,10 @@ def add_date @mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date) if @mentor_meeting.save - # Trigger notification after saving - ActiveSupport::Notifications.instrument('mentor_meeting.created', team_id: team_id, meeting_date: meeting_date) - render json: { status: 'success', message: 'Meeting created successfully' } + MentorMeetingNotifications.send_notification(team_id, meeting_date) + render json: { status: 'success', message: "Meeting date added" } else - render json: { status: 'error', message: 'Failed to create meeting' } + render json: { status: 'error', message: "Unable to add meeting date" } end end From 25fc960c93ae074ea68d1fb60379fabe28792cfe Mon Sep 17 00:00:00 2001 From: Anusha_Akkireddy Date: Tue, 29 Oct 2024 18:22:10 -0400 Subject: [PATCH 40/44] Implement mentor meeting controller with CRUD and notification features --- .../mentor_meeting_controller_spec.rb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/controllers/mentor_meeting_controller_spec.rb diff --git a/spec/controllers/mentor_meeting_controller_spec.rb b/spec/controllers/mentor_meeting_controller_spec.rb new file mode 100644 index 00000000000..ce346c536e9 --- /dev/null +++ b/spec/controllers/mentor_meeting_controller_spec.rb @@ -0,0 +1,37 @@ +require 'rails_helper' + +RSpec.describe MentorMeetingController, type: :controller do + describe 'POST #add_date' do + it 'creates a new meeting date and triggers a notification' do + expect { + post :add_date, params: { team_id: 1, meeting_date: '2024-11-01' } + }.to change(MentorMeeting, :count).by(1) + + expect(response.status).to eq(200) + expect(JSON.parse(response.body)['status']).to eq('success') + end + end + + describe 'PATCH #edit_date' do + it 'updates the meeting date' do + mentor_meeting = MentorMeeting.create!(team_id: 1, meeting_date: '2024-11-01') + patch :edit_date, params: { team_id: 1, old_date: '2024-11-01', new_date: '2024-11-02' } + + expect(response.status).to eq(200) + expect(JSON.parse(response.body)['status']).to eq('success') + expect(mentor_meeting.reload.meeting_date).to eq('2024-11-02') + end + end + + describe 'DELETE #delete_date' do + it 'deletes the meeting date' do + mentor_meeting = MentorMeeting.create!(team_id: 1, meeting_date: '2024-11-01') + expect { + delete :delete_date, params: { team_id: 1, meeting_date: '2024-11-01' } + }.to change(MentorMeeting, :count).by(-1) + + expect(response.status).to eq(200) + expect(JSON.parse(response.body)['status']).to eq('success') + end + end +end From 34042b8a7c33f9e24a4fd17a70511507ab52a5ab Mon Sep 17 00:00:00 2001 From: Anusha_Akkireddy Date: Tue, 29 Oct 2024 19:18:07 -0400 Subject: [PATCH 41/44] Add Dockerfile for Docker setup --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..2f1d69f05e1 --- /dev/null +++ b/Dockerfile @@ -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"] From 7d890ee39b85b15641cf38e7a45f047c178f0148 Mon Sep 17 00:00:00 2001 From: Simon Getahun Date: Tue, 29 Oct 2024 21:35:16 -0400 Subject: [PATCH 42/44] modification to email --- app/models/team.rb | 19 +++++++++++++------ .../_dual_role_added_to_team_html.html.erb | 11 +++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 app/views/mailer/partials/_dual_role_added_to_team_html.html.erb diff --git a/app/models/team.rb b/app/models/team.rb index 9298e1b32d7..f2d4a06e210 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -91,14 +91,21 @@ def add_member(user, _assignment_id = nil) # if assignment_id is nil, then don't send an assignment name assignment_name = _assignment_id ? Assignment.find(_assignment_id).name.to_s : "" - # Now that a new team member has been added to a team, send an email to them letting them know - if MentorManagement.user_a_mentor?(user) + + # 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 - elsif !user.is_a?(Participant) - # If the user is a participant, then we don't went to send them emails since that class is something - # completely out of the scope of this project + + # 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 - end + + # 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 diff --git a/app/views/mailer/partials/_dual_role_added_to_team_html.html.erb b/app/views/mailer/partials/_dual_role_added_to_team_html.html.erb new file mode 100644 index 00000000000..e28a835e1c1 --- /dev/null +++ b/app/views/mailer/partials/_dual_role_added_to_team_html.html.erb @@ -0,0 +1,11 @@ +Hi <%= @first_name %>, +
+

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

+

+ Please note that you are assigned both as a mentor and a participant for this team. +

+

+ Expertiza Team +

From 2db26cf638a8b5b4403490bb2313de34780f6074 Mon Sep 17 00:00:00 2001 From: Simon Getahun Date: Tue, 29 Oct 2024 21:43:50 -0400 Subject: [PATCH 43/44] added test for new feature --- spec/models/team_spec.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb index 51d5af72776..c7adab57cc6 100644 --- a/spec/models/team_spec.rb +++ b/spec/models/team_spec.rb @@ -115,7 +115,7 @@ expect(team.add_member(user)).to be true end - it 'sends mail to user if user is a user' do + it 'sends mail to user if the user is a participant only' do allow(MentorManagement).to receive(:user_a_mentor?).with(user).and_return(false) allow(Assignment).to receive(:find).with(1).and_return(assignment) allow(MailerHelper).to receive(:send_team_confirmation_mail_to_user).and_return(double('Mail', deliver: true)) @@ -124,6 +124,18 @@ expect(team.add_member(user)).to be true end + + it 'sends dual-role mail if the user is both a mentor and a participant' do + allow(MentorManagement).to receive(:user_a_mentor?).with(user).and_return(true) + allow(user).to receive(:is_a?).with(Participant).and_return(true) + allow(Assignment).to receive(:find).with(1).and_return(assignment) + allow(MailerHelper).to receive(:send_team_confirmation_mail_to_user).and_return(double('Mail', deliver: true)) + + expect(MailerHelper).to receive(:send_team_confirmation_mail_to_user).with(user, "[Expertiza] Added to a Team", "dual_role_added_to_team", "#{team.name}", "").and_return(double('Mail', deliver: true)) + + expect(team.add_member(user)).to be true + end + end end end From a93285cbd5426c49b00e7b0167505f8eab24476f Mon Sep 17 00:00:00 2001 From: Simon Getahun Date: Tue, 29 Oct 2024 21:57:56 -0400 Subject: [PATCH 44/44] changed model to handle dual case --- app/models/mentored_team.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/models/mentored_team.rb b/app/models/mentored_team.rb index e009d8948e2..a43feca21e7 100644 --- a/app/models/mentored_team.rb +++ b/app/models/mentored_team.rb @@ -14,12 +14,18 @@ def add_member(user, _assignment_id = nil) 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 : "" - if MentorManagement.user_a_mentor?(user) - MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver - elsif !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 - end + # 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