CSC/ECE 517 Fall 2018/E1834 Improve email notifications: Difference between revisions
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
==Modified Files== | ==Modified Files== | ||
* assignment_participant.rb | * app/models/assignment_participant.rb | ||
* app/models/assignment.rb | |||
* app/models/course_participant.rb | |||
* app/controllers/submitted_content_controller.rb | |||
* app/mailers/delayed_mailer.rb | |||
* lib/tasks/background_email_reminder.rake | |||
* spec/models/assignment_particpant_spec.rb | |||
Revision as of 23:23, 2 November 2018
This page provides a description of the Expertiza based OSS project.
About Expertiza
Expertiza is an open source project developed using 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, web sites, etc)[1].Expertiza supports submission across various document types, including the URLs and wiki pages.
Problem Statement
Modified Files
- app/models/assignment_participant.rb
- app/models/assignment.rb
- app/models/course_participant.rb
- app/controllers/submitted_content_controller.rb
- app/mailers/delayed_mailer.rb
- lib/tasks/background_email_reminder.rake
- spec/models/assignment_particpant_spec.rb
Implementation approach
1) Email sent when user is added as a participant to assignment :
When students' accounts are created by importing a CSV file on the Users page,they receive e-mails but not when user was added as a participant to the assignment. We added a method in the assignment_participant.rb file (model) to send mails when a participant is added to an assignment on the assignment page by importing a CSV file. We have also added a method in the course_participant.rb file(model), to send the mail when a Course participant is added by importing a CSV file. Both functionalities are implemented using the method from the MailerHelper class i.e send_mail_to_user().
https://github.com/expertiza/expertiza/commit/c17bb25827e43940cc9f253c04ee7343878298df
2) Sending email to reviewer when new submission is availble:
Added functionality to send email to the reviewer when new submission is available by making changes in the submitted_content_controller and assignment_participant model.The method handled boundary constraints like checking whether the round was valid and disabling email notification after the last round of review.
Code to check if it was the valid round
In the assignment_participant.rb, Firstly, fetched the topic_id from the SignedUpTeam class and got the next due date using the DueDate model Finally compared the round of the Due date with the number of review rounds of the assignments, to verify if its the final round.
Extra functionality of specifying the current review round and providing the direct link to reviewer in the mail itself also implemented in the submitted_content controller using the ReviewResponseMap and Response class.
In the submitted_content_controller.rb, We mapped the reviewer_id and reviewee_id, fetched from participants, using the ReviewResponseMap class. For all such mappings retrieved, we are fetching the last response id, which is then passed as the URL suffix to redirect the reviewer to the appropriate page.
3) Including a specific link for the deadline reminders email functionality :
Added a review_reminder_email method and mail_reviewers method in the delayed_mailer.rb file which implemented the functionality for sending deadline reminder mails which includes a link on where to go and perform the specific task. Prepared a hash named email_list using the email and participant_id, for each participant who is a reviewer. Using this hash, we are calling the review_reminder_email function. In this function, based on the due date for the deadline_type(i.e reviewer), we fetch the participant id of the same and add it as the suffix in the URL to be visited by the reviewer. Also, the logic of the copy of mail to the instructor is also taken care. Notice that the link in the instructor's email will contain the '?id=' field of the last participant fetched.
In the background_email_reminder.rake file,
Earlier only the emails for the participants were fetched, but now we are fetching the hash containing the email and response_id. The response_id field was fetched as per the below order in the code-
participants.review_mappings -> allresponsemaps -> eachresponsemap -> response.
For the reviewer assign_type, we have defined a separate method send_reminder_emails(), wherein we pass the response_id of the email_list hash, and add it as a suffix in the URL which will be accessed by the reviewer.
Testing
We have used Rspec for testing the email functionalities.Using the test driven development(TDD) approach, we have added an Rspec test which checks whether the mail is delivered to the expected receiver upon creation of the account for the student.
We have created a new assignment_particpant_ spec file for the above purpose.The spec uses double and stub features of rspec gem to fake user login.
Since the smtp setting are set to test mode all mails go to expertiza.development@gmail.com and not the actual user.Hence when an email is sent the
ActionMailer::Base.deliveries list gets updated.The last element in the deliveries list will be the email that was sent when the import method was invoked.
Then using expect object we verify whether the email was correctly sent by checking the subject, from and to field.
NOTE: All the mails except the ones for the reviewer which are sent to mailinator are sent to expertiza.development@gmail.com ,as this is already set in the development environment.
Additional Links
- Git pull link: https://github.com/expertiza/expertiza/pull/1253
- VCL deployment: http://152.46.18.165:8080/