User:Rpothir

From Expertiza_Wiki
Jump to navigation Jump to search

This wiki page describes the work on the OSS project titled E1716-Improve email notifications for the course CSC/ECE 517, Spring 2017.

Expertiza

Expertiza is an online collaboration tool for the students and instructors. It is an open source project developed on Ruby on Rails platform. It has several features that help the users to contribute jointly by creating the list of users by importing CSV file, assigning work, share the work, giving reviews, forming teams and finally notifying every action using email notifications.


Motivation

Though expertiza is a great platform, there are quite a few enhancements in sending emails to users on the reviews, deadlines and accounts creations. So this contribution helps in learning to contribute to open source projects.

Description of the current project

The existing functionality implements the email notifications' feature in response to certain events. However, there are cases where email notifications are sent which are redundant as well as cases where email notifications need to be sent but are not sent. The current project aims at improving this email-notification functionality. For example, Expertiza uses a peer review system wherein, after the first round of submission, submitted work is peer reviewed. Using the recommendations made and the improvements suggested in the peer reviews, an assignment participant can then proceed to improve his work. Thus, a participant is notified via email whenever a review for his/her submitted work is provided. Similarly, a reviewer is notified via email when a new submission is made for the work that he/she reviewed. Now, if the participant makes an improvement in his/her submission after the last round of reviews has been done, sending an email to the reviewer regarding this is redundant. However, in the current state of application, a reviewer is notified in this case too. Thus, there are similar cases, where the email notification needs to be enabled/disabled and that is the objective of our project.


The issues/tasks that needed modifications were identified:

1. Notify an instructor by e-mail when a student suggests a topic.

2. The email message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.

3.Send out an email to the invitee when a participant sends out an invitation to another participant to join a team.

4. The student who issued the invitation should also be e-mailed when the invitee joins the team.

5. Create an option (in the instructor’s profile) to get a copy of ‘e-mails being sent to students (this is so the instructor can verify correct functioning of the system).

6.When students' accounts are created by importing a CSV file on the Users page, they receive e-mails with their user-ID and password. But if an account is created by adding them as participants to an assignment when they don't already have an account, e-mail is not sent. Students should receive e-mails upon account creation, regardless of how their account is created.

Peer Review Information

Steps to test the features manually

1. You can Login into the Expertiza application either as an instructor or as a student the user login credentials are as follows:

username : 'instructor' password: 'password'

username: 'student6360' password: 'password'

2. Once you have logged in as an student, go to the Assignments tab. Choose an assignment that has the 'Suggest a topic' option. Suggest a topic and check if an email is being sent to the account whose details are as follows::

For users intending to view the Expertiza test mails associated with this assignment, a Gmail account is set up and the user login credentials are below: (for Expertiza, emails are sent from this gmail account)

user_name: 'expertiza.development@gmail.com'

password: 'qwer@1234'

3. SInce our logic of implementing the task no 2) depends on the review deadline being already passed or not, currently you cannot test this in the app because all the review deadlines for all the assignments (currently in the database) have already passed. Please refer the section below to understand the logic

4. To test the third task (no 3)), navigate to any assignment where you are able to add a team mate by navigating to 'your team' and adding a valid user (e.g student5000) to your team. An email will be sent to the gmail account mentioned above. Now, sign in as the user who was invited and accept the invitation to join team. A corresponding email will be delivered in the setup gmail account. This tests the working of the fourth task.

5. Login as an instructor and check the checkbox to receive a copy of all emails. Carry out one of the tasks mentioned above (suggesting a topic, inviting members) that will cause an email to be sent. In the setup email account, you will see copies of all these emails generated. (one for each email sent to each user even though it is the same email)


Test Plan and Development

Testing

We have used the RSpec testing tool for Behavior Driven Development(BDD). We have done unit testing and integration testing using RSpec framework. The test plans and the implementation details of each of the features are as follows:


1)Topic Suggestion


Test plan:

The mail should be sent to the instructor as soon as a new topic is suggested by the student. Since the process going here is a method call and mailer invocation, corresponding tests to check whether the emails are sent to instructor have been written in the RSpec.


Development:

Earlier Scenario:

Some of the assignments have an option to suggest a topic to the instructor. But when a student suggests a topic, this event is not notified to the instructor leaving it to go unnoticed and the student must mail the instructor regarding the suggestion.

Updates/Changes:

The suggestions controller is modified so that whenever a student suggests a topic, an email is sent to the professor. The changes made are shown below.

Updated the controllers/suggestion_controller.rb so that whenever a new suggestion is getting saved it must invoke the mailer function. This is also being done when the suggestion is getting accepted too.

The mailer function as shown below contains the to address which is the instructor's email address, the subject along with the topic name and body with the proposer's details. This function invokes the suggestion_topic function in the mailer which send the mail.


As mentioned above the function defined in the mailer send the mail in the following format to the instructor.

The mail format and view would be


2)Revising the reviews


Development:

Earlier Scenario:

Peer reviewing assignments is an important aspect of Expertiza. A review is done for the submitted content on the basis of some guidelines. For each round of the assignment, there is a deadline for submitting the review. It may happen that a participant chooses to revise his/her submitted content after receiving a review. When a participant thus revises his submitted content, an email notification is sent to all the reviewers requesting them to update their reviews. Now, sending such a notification makes sense only if the review deadline for that particular round has not already passed and if the last round of review has not already been done. However, in the existing system, an email is sent in both the cases mentioned above. One of our tasks was to fix this to ensure that email is sent only when needed.

Updates/Changes

We made the changes shown above in the submitted_content_controller. In order to get the review deadlines for each assignment, we fetched values from the "Due_dates" table in the database. By comparing the review deadline with the current date and time (the time when a resubmission is made) we put a conditional statement that ensures that an email notification is only sent at appropriate times


3)Inviting a participant to join the team

Test Plan

The main features to test in this particular task is to make sure that the defined methods are getting called at right times with the right parameters. Also, it is required to test whether the mailer is invoked at right time thereby avoiding unnecessary emails. Here, both the controller and mailers are being tested. The RSpec tests for both the invitation and acceptance are mentioned below.

Development

Earlier Scenario:

Whenever a user invites another participant to join the team, he/she can just add them in expertiza and must wait until the participant logs into expertiza to see the invitation.

Changes/Updates:

We have included the mailer call whenever a user is inviting a participant so that an email is sent out stating that an invitation is pending.

Whenever a new invitation is created and set into waiting status, the email is call is made in controllers/invitation_controller.rb


The email call calls a function named 'accept_invitation' in the invitation controller where the appropriate fields required for the email are gathered and the mailer is called.


In the mailer, the 'accept_invitation' function is invoked where the to address is addressed to the participant who is being invited.


The format of the mail being set is customized in views/mailer/accept_invitation.html.erb as shown below.


4)Notification regarding the Accepted Invitation

Earlier scenario:

As mentioned earlier, whenever a participant accepts the team invitation the user who sent the invitation gets to know about the news only after logging into Expertiza which may take longer to form the team.

Changes/Updates:

So here, we have included a mailer so that whenever a participant accepts the team request, an email is sent to the user who invited him/her. This makes sure that the user who invited has been notified immediately after the team request has been accepted thereby avoiding delays in team formation.


Whenever a new invitation is accepted the status is confirmed and the email call is made in controllers/invitation_controller.rb


The email call calls a function named 'accepted_invitation' in the invitation controller where the appropriate fields required for the email are gathered and the mailer is called.


In the mailer, the 'accepted_invitation' function is invoked where the to address is addressed to the user who invited the participant to join the team in the first place.


The format of the mail being set is customized in views/mailer/accepted_invitation.html.erb as shown below.


5)Copy of emails to Instructor

Proposal:

To creation an option to get a copy of ‘e-mails being sent to students so the instructor can verify correct functioning of the system.

Changes:

In regard with the proposal, we created an option in the instructor profile which allows the instructor to get all the emails that are being sent to the students. On consultation with the instructor, the instructor email was added as cc in the mails being sent. For this, a new migration is done on database to add a new column of Boolean data type.

In the profile of the instructor a check box is added to facilitate instructors to receive the copy of mails sent to students.

Inside the mailer, the option is checked and if satisfied, all the generic mails are also forwarded to the instructor.

6)Sending emails when user accounts are created by adding users as participants to assignments

Test Plan

Here, we just had to test whether or not an email is being sent to the created users. The only aspect worth testing in this case was by actually (manually) testing whether the feature is working or not.

Development

Earlier Scenario

A common method of importing user details to create new user accounts is by importing a CSV file containing the records of all users. Thus, at the beginning of each course term, the instructor adds users to the course by fetching their details from a CSV file that is imported. On creation of new accounts, each user is notified via email. However, this is not the only way a new account can be created for a user. An instructor can create an account for a user (if it does not already exist) by adding him/her as a participant to an assignment. This is also done by importing a CSV file containing user details. However, when a user account is created this way, an email notification is not sent to the user. Our job was to fix this functionality so that an email notification is sent to a user on account creation irrespective of the method of account creation.

updates/changes

An obvious choice would have been to add a mailer call in the partipants_controller in the "add" method. However, in the participants_controller's 'create' method, there was a mailer call when existing users (users whose accounts have already been created) are added to an assignment, by searching users by either their name/ email id.

Another choice was to add a mailer in the users_controller when a new user has been created. However, adding a mailer here, did not give the required functionality. Hence, we added a mailer call in the imported_files_controller as shown below::


In the imported CSV file, the third column contained email ids of the users. By iterating through each row of the file and accessing the value in the third column (column no.s beginning from 0), we fetched email address of each user. Once we fetched the email address, we added a mailer call to send an email to the concerned user.

Design Principles

As far as possible, we have tried to abide by the SOLID principles in the parts of the code that we worked with. In addition, we have tried to follow the Ruby Style guidelines such as:

1. Use two spaces per indentation level.

2. Avoided using a ; to separate statements and expressions while having only one expression per line.

3. Avoided having single line methods

4.Have used empty lines between method definitions and also to break up methods into logical paragraphs internally.

We have also tried to preserve the core principle of the MVC architecture by ensuring that most of the functionality has been implemented in the controllers and coupling is minimized. ==