CSC/ECE 517 Fall 2021 - E2135 Email notification to reviewers and instructors
This page provides a description of the Expertiza based OSS project.
About Expertiza
Expertiza is an open-source project developed using the Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. The application allows students to submit and peer-review learning objects (articles, code, websites, etc)[1]. Expertiza supports submission across various document types, including the URLs and wiki pages.
Problem Statement
Modified Files
- app/models/due_date.rb
- test/models/due_date.rb
- db/migrate/20210319212323_create_delayed_jobs.rb
Pre-config
We use delayed jobs library to deal with the delayed email. We need run following command in order to install delayed_job binary executable.
rails generate delayed_job
Then we need to run
RAILS_ENV=development bin/delayed_job start
This will start a backend server to deal with the delayed jobs. If we want to stop, just run following.
RAILS_ENV=development bin/delayed_job stop
Implementation approach
1) Reminder email sent when assignment or review is approaching deadline: In the due_date.rb file, whenever a new due date is created or an existing due date is updated, the start_reminder method will be fired which will eventually be added to the delayed_job queue. This job will be executed at a preconfigured time before the deadline, where it will fire the method reminder which will be added to the delayed job queue by the handle_asynchronously method of gem delayed_job_active_record. Inside the reminder method, we will fetch three attributes - assignment_id, deadline_type, due_at. These three attributes will be used to decide the deadline type ( submission or review or teammate review ), fetch the participant email for that assignment, fetch the deadline threshold and at the end send the email reminder at a specified threshold time before the deadline which will contain all the details such as assignment names link to assignment and assignment type ( submission or review or teammate review).
2) Implement code:
def create_mailer_object Mailer.new end def create_mailworker_object MailWorker.new(self.parent_id, self.deadline_type, self.due_at) end
# main function to start email reminder def start_reminder puts when_to_run_reminder if self.changed? @extra_param = self.parent_id.to_s + "," + self.deadline_type_id.to_s # first deleted existed delayed jobs with same parent_id(which is assignment id actually) Delayed::Job.where(extra_param: @extra_param).each do |job| job.delete end # add a delayed job to the delayed job queue, the job will run at what when_to_run_reminder return run_at_time = when_to_run_reminder if run_at_time >= 0.seconds.from_now self.delay(run_at: run_at_time, :extra_param => @extra_param).reminder end end end #### def reminder deadline_text = self.deadline_type if %w[submission review].include? self.deadline_type deadline_text = "Team Review" if self.deadline_type == 'metareview' mail_worker = create_mailworker_object email_reminder(mail_worker.find_participant_emails, deadline_text) unless mail_worker.find_participant_emails.empty? end #### def email_reminder(emails, deadline_type) assignment = Assignment.find(self.parent_id) subject = "Message regarding #{deadline_type} for assignment #{assignment.name}" body = "This is a reminder to complete #{deadline_type} for assignment #{assignment.name}. \ Deadline is #{self.due_at}.If you have already done the #{deadline_type}, Please ignore this mail." emails.each do |mail| Rails.logger.info mail end Mailer.delayed_message(bcc: emails, subject: subject, body: body).deliver_now end
# after duedate - threshold hours, then we can send the reminder email def when_to_run_reminder hours_before_deadline = self.threshold.hours result = (self.due_at.in_time_zone - hours_before_deadline).to_dateti
Automated Testing using RSPEC
We have used Rspec for testing the delayed_job functionalities. Using the test-driven development (TDD) approach, we have added a Rspec test which checks whether the mail is enqueued upon the firing of the reminder method.
We have used Rspec for testing the delayed_job functionalities. Using the test-driven development (TDD) approach, we have added a Rspec test which checks whether the call for reminder method is enqueued upon the firing of the start_reminder method, with the proper scheduled execution time.
NOTE: All the reminder mails except the ones for the reviewer are sent to expertiza.development@gmail.com ,as this is already set in the development environment.
Steps to verify Functionality
- Test Email
Email: expertiza_test123@outlook.com Password: password98@
- Test Expertiza account
name/login: Email_Test_ID1 password: password98@
1. Change the existing assignment's due date First login in as instructor6, and go to Manage → Assignments
Then click change edit in the right side menu under **Actions**. Go to Due dates and change the **reminder** and **Due & Time**, and click save.
Then you should receive email at expertiza_test123@outlook.com in the appropriate time. For this example,16 hours before 2021/10/25 04:08 (US Eastern time zone), the system shall send a reminder email to expertiza_test123@outlook.com.
2. Create a new assignment with valid due date Create a new Assignment
Assign a valid due date and reminder hours. Valid means that the due data minus reminder hour should be a time that is later than the current time. For example, if you set due date to 10:00pm on 10/25/2021 and set reminder hours to 8 hours, then you won't get the email if current date time has passed 2:00pm on 10/25/2021.
Then add the previous user login to it as a participant
Because the participants was added later, so we need to change the due date once more in order to trigger the email notification jobs.
Additional Links
- Git forked repository link: https://github.com/CuiJinku/expertiza/tree/beta
- VCL deployment: http://152.7.176.117:8080/
- Pull request link: https://github.com/expertiza/expertiza/pull/2099