CSC/ECE 517 Fall 2019 - E1961. Email notification to reviewers and instructors
E1961 Email notification to reviewers and instructors
Brief Introduction
- E1961 Project aims to fix the problems of making the email notification function more reliable.
- The forked git repository for this project can be found wangdavid84/expertiza.git
- Deployed on VCL: VCL
Problem Statement
The following tasks were accomplished in this project:
- Issue1: Fix the problem that the author(reviewee) cannot receive the email notification about the review from someone else. The Expertiza is supposed to email authors each time a review of their work is submitted.
- Issue2: Fix the bugs to make Expertiza emails reviewers each time an author that they have reviewed submits new work.
- Issue3: The instructor could get a Blind carbon copy every time.
- Issue4: The users can turn off those email notifications by unchecking boxes on their profile page.
Issue1: email to reviewee
- Add a method in both "update" and "create" functions to call the email function to make the Experiza send the email to reviewee when reviewers submit the reviews
Changed files: app/controllers/response_controller.rb:
- previous version
def send_email_to_reviewee(map) participant = Participant.find(map.reviewer_id) defn = {body: {type: "Peer Review", obj_name: "Test Assgt", partial_name: "new_submission"} } map.email(defn, participant, Assignment.find(Participant.find(map.reviewer_id).parent_id)) end
- current version
def send_email_to_reviewee(map) defn = {body: {type: "Peer Review", partial_name: "new_submission"} } map.email(defn, Assignment.find(Participant.find(map.reviewer_id).parent_id)) end
- refactor the email method, which is called by send_email_to_reviewee.
Changed files: app/models/review_response_map.rb:
def email(defn, assignment) defn[:body][:type] = "Peer Review" AssignmentTeam.find(reviewee_id).users.each do |user| instructor = User.find(user.parent_id) bcc_mail_address = "" if instructor.copy_of_emails == true && user.email_on_review == true bcc_mail_address = instructor.email end if user.email_on_review? defn[:bcc] = bcc_mail_address defn[:body][:obj_name] = assignment.name defn[:body][:first_name] = User.find(user.id).fullname defn[:to] = User.find(user.id).email Mailer.sync_message(defn).deliver_now end end end
Issue2: email to reviewer(new submission)
- Add new function to email all reviewers a new submission is ready to review:
- In the first round, there is no reviewer before they take a request
- Except the first round, reviewers get an email every time when there is a new submission
Changed files: app/controllers/submitted_content_controller.rb:
email_all_reviewers(@participant) end redirect_to action: 'edit', id: @participant.id end
def email_all_reviewers(participant) if participant.reviewers != [] participant.reviewers.each do |reviewer| map = ReviewResponseMap.where(['reviewer_id = ? and reviewee_id = ?', reviewer.id, participant.team.id]).first responses = Response.where(:map_id => map.id) responses = responses.sort_by { |obj| obj.updated_at } # the latest response will be the last latest_response = responses.last # we need to pass the id of lastest_response in the URL mentioned in the mail. # this will open the correct /response/edit?id=#{latest_response.id} page for the reviewer when (s)he clicks on it. user = User.find(reviewer.user_id) instructor = User.find(user.parent_id) bcc_mail_address = "" if instructor.copy_of_emails? bcc_mail_address = instructor.email else # do noting end if user.email_on_submission? MailerHelper.send_mail_to_reviewer(user, bcc_mail_address, "You have a new submission to review", "update", "Please visit https://expertiza.ncsu.edu/response/edit?id=#{latest_response.id} and proceed to peer reviews.").deliver end end end end
Changed files: app/helpers/mailer_helper.rb:
def self.send_mail_to_reviewer(user, bcc_mail_address, subject, partial_name, note) Mailer.new_review_request_message ({ to: user.email, bcc: bcc_mail_address, subject: subject, body: { user: user, first_name: ApplicationHelper.get_user_first_name(user), message: note, partial_name: partial_name } }) end
- Changing the email content, which is the message content send toward the receiver.
Changed files: app/views/mailer/new_review_message.html.erb:
<!DOCTYPE html> <html> <head> <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> </head> <body> <%= render :partial => 'mailer/partials/'+@partial_name+'_html' %> <hr> This message has been generated by <A HREF="http://expertiza.ncsu.edu">Expertiza</A><BR/> http://expertiza.ncsu.edu </body> </html>
Changed files: app/views/mailer/partials/update.html.html.erb:
Hi <%= @first_name %>,</br> <p> One of the assignments you are reviewing has just been entered or revised. "<%= @message %>" </p> <br/>
Issue3: bcc to Instructor
- The instructor is able to get copies of emails that are sent to students by the system. Also the instructor could cancel the function by editing the checkbox on the profile page.
Changed files: app/controllers/submitted_content_controller.rb:
instructor = User.find(user.parent_id) bcc_mail_address = "" if instructor.copy_of_emails? bcc_mail_address = instructor.email else # do noting end
Changed files: app/models/review_response_map.rb:
instructor = User.find(user.parent_id) bcc_mail_address = "" if instructor.copy_of_emails == true && user.email_on_review == true bcc_mail_address = instructor.email end if user.email_on_review? defn[:bcc] = bcc_mail_address defn[:body][:obj_name] = assignment.name defn[:body][:first_name] = User.find(user.id).fullname defn[:to] = User.find(user.id).email Mailer.sync_message(defn).deliver_now
- Add a new attribute: bcc_mail_address
Changed files: app/helpers/mailer_helper.rb:
def self.send_mail_to_reviewer(user, subject, partial_name, note)
def self.send_mail_to_reviewer(user, bcc_mail_address, subject, partial_name, note)
Issue4: the user could choose checkbox options
- Fix the problem that the users cannot choose to uncheck the email options.
Changed files: app/views/users/_prefs.html.erb:
- previous version:
<td><label for="user_email_on_review">When someone else <strong>reviews</strong> my work</label></td> <td><%= check_box 'user', 'email_on_review', <font color="red">{}, true, false %</td> </tr> <tr> <td><label for="user_email_on_submission">When someone else <strong>submits</strong> work I am assigned to review</label></td> <td><%= check_box 'user', 'email_on_submission', {}, true, false %></td> </tr> <tr> <td><label for="user_email_on_review_of_review">When someone else reviews one of my reviews (<strong>metareviews</strong> my work)</label></td> <td><%= check_box 'user', 'email_on_review_of_review', {}, true, false %></td> </tr>
- correct version:
<tr> <td><label for="user_email_on_review">When someone else <strong>reviews</strong> my work</label></td> <td><%= check_box 'user', 'email_on_review' %></td> </tr> <tr> <td><label for="user_email_on_submission">When someone else <strong>submits</strong> work I am assigned to review</label></td> <td><%= check_box 'user', 'email_on_submission' %></td> </tr> <tr> <td><label for="user_email_on_review_of_review">When someone else reviews one of my reviews (<strong>metareviews</strong> my work)</label></td> <td><%= check_box 'user', 'email_on_review_of_review' %></td> </tr>
- fix issue disable email_on_review is not working on profile
Changed files: app/models/review_response_map.rb:
- previous version:
- correct version:
Test
Process Video Test
- instructor6 create a new assignment
- student10, student11 submit a hyperlink as the first submission
- nstructor6 modify the due date of first submission(For the test, the student only can do the review after the due date of the first submission)
- student 11 does the review for student 10 ---->the student 10 and the instructor6(Blind carbon copy) should receive the email to notify that there's a new review
- student 10 resubmit another hyperlink as the second submission --->the student 11 and the instructor6(Blind carbon copy) should receive the email to notify that he needs to update the review
Database:
- we modified the email address of instructor6, student10 and 11 to do the test in the video
Rspec test
- test function: if the user unchecked the box of email_on_review(When someone else reviews my work) option, he should not receive the email.
- We create a new student2 with email_on_review options is false (default is true)
Changed files: app/spec/models/review_response_map_spec.rb:
let(:student2) { build(:student, id: 3, name: "name2", fullname: 'no one', email: 'expertiza@mailinator.com', email_on_review: false) }
it '#email should not send email when email on review attribute is disabled' do reviewer_id = 1 allow(Participant).to receive(:find).with(1).and_return(participant) allow(Assignment).to receive(:find).with(1).and_return(assignment) allow(AssignmentTeam).to receive(:find).with(3).and_return(team2) allow(AssignmentTeam).to receive(:users).and_return(student2) allow(User).to receive(:find).with(3).and_return(student2) review_response_map2.reviewee_id = 3 defn = {body: {type: "Peer Review", obj_name: "Test Assgt", first_name: "no one", partial_name: "new_submission"}, to: "expertiza@mailinator.com"} expect { review_response_map2.email(defn, participant, Assignment.find(Participant.find(reviewer_id).parent_id)) } .to change { ActionMailer::Base.deliveries.count }.by 0 end
Team Information
- Siwei Wen (swen4@ncsu.edu)
- Shuzheng Wang (swang41@ncsu.edu)
- Zhifeng Zhu (zzhu25@ncsu.edu)
- Mentor: Ed Gehringer (efg@ncsu.edu)