User:Cbaruah

From Expertiza_Wiki
Jump to navigation Jump to search

CSC/ECE 517 Fall 2016 E1655/OSS Improve e-mail notification

Peer Review Information

For users intending to view the deployed Expertiza associated with this assignment, the credentials are as follows:

  • Instructor Login: Username: instructor6 , password: password
  • Student Login: Username: student5432 , password: password
  • Student Login: Username: testing11, password: password
  • Student Login: Username: testing12, password: password

Expertiza Background

Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other student's submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.

Mailers in Expertiza have their association with many other components like Users, Courses, Reviews, Participants and Invitations. The Mailer Helper in specific invokes methods which perform mailer related functions like sending email to newly created user, sending email to reviewer etc.

Motivation

This project in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails, RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.

Currently, the mailer notifies the students on their account creation and to the reviewer when a submission of work is done. The scope of this project is to improve the present email notifications and also plug gaps in some implementations.

Current Implementation

1. 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. So, this issue is fixed by implementing the functionality of sending e-mail when account creation is done in this case. Now, e-mail is getting triggered to the concerned user whenever their account is created regardless of how their account is created. The listed files were manipulated for updating this functionality.

  1. controllers/import_file_controller.rb
  2. helpers/import_file_helper

2. Evidently, if a file is revised after review, the system e-mails the reviewer saying to revise the review. The method to implement this was in place but wasn't working. This issue is fixed. Note that the e-mail is only triggered for a file submission and there is no mailer functionality in place for URL submission. Also, after the last round of review is completed, e-mail is no longer is getting triggered as desired. The listed files were updated or created to get the functionality working.

  1. controllers/submitted_content_controller
  2. helpers/mailer_helper
  3. app/views/mailer/partials/_file_submission_plain.html.erb
  4. app/views/mailer/partials/_file_submission_html.html.erb

3. The message body of the e-mail now includes the round of the review stage for which the review is provided along with a link to the site. Files changed are same as mentioned in second point.

4.1 E-mail is triggered to an invitee whenever a participant sends out an invitation to another participant to join a team. The listed files were updated or created to get the functionality working.

  1. controllers/invitation_controller
  2. helpers/participants_helper
  3. app/views/mailer/partials/_team_join_invite_html.html.erb
  4. app/views/mailer/partials/_team_join_invite_plain.html.erb

4.2 Whenever the invitee accepts the invitation, the student who issued the invitation gets a mail stating that the invitee has accepted his/her invitation. The controller and helper class are same as mentioned in the 4th point. New views are created for this functionality

  1. app/views/mailer/partials/_team_accept_invite_html.html.erb
  2. app/views/mailer/partials/_team_accept_invite_plain.html.erb

5. Mail is also getting triggered when a student responds to a teammate advertisement. The controller and helper class changed are same as mentioned in the 4th point. New views are created for this functionality.

  1. app/views/mailer/partials/_response_to_advertisement.html.erb
  2. app/views/mailer/partials/_response_to_advertisement.html.erb

Files modified in current project

Classes

  • controllers/import_file_controller
  • controllers/submitted_content_controller
  • controllers/invitation_controller
  • helpers/import_file_helper
  • helpers/participants_helper
  • helpers/mailer_helper

About import_file_controller

This controller derives from the Application Controller. It states the functionality of importing any kind of file like csv, xls, doc into the application. It defines the import function which takes the 'session' and 'params' as output and provides success message on successful import. It also provides the functionality of specifying the delimiter in the file which is being imported. The ImportFile method defined in the controller reads the file row by row based on the model concerned. The modified code snippet is

About submitted_content_controller

This controller also derives from the Application Controller. It states the CRUD operations on submitting the file or hyperlink for assignment. It provides functionality to download, create folder and delete folder after submission. It provides the functionality for submitting links and submitting hyperlinks separately.

   prepared_mail = MailerHelper.send_mail_to_reviewer(User.find(participant.user_id), "A new submission is available", "file_submission", "file  submission", Assignment.find(participant.parent_id).name)
   prepared_mail.deliver

About invitation_controller

This controller also derives from the Application Controller. It states the CRUD as well as other basic operations when an invitation is sent by an user to any participant to join their team. It provides the functionality to send and accept invitations as well as to reject invitations and leave team.

# To send mail request to invitees to join team
prepared_mail = MailerHelper.send_mail_for_invitation(user, "Invitation to join team", "team_join_invite", "invitation to join", student.name)
prepared_mail.deliver

About import_file_helper

This is a helper file for the import_file_controller class which stores the attributes from the controller class as well as creates new users when user are created by importing a CSV file.

def self.create_new_user(attributes, session)
   user = User.new(attributes)
   user.parent_id = (session[:user]).id
   user.timezonepref = User.find(user.parent_id).timezonepref
   user.save!
   prepared_mail = MailerHelper.send_mail_to_user(user, "Your Expertiza account and password have been created.", "user_welcome", user.password)
   prepared_mail.deliver
   user
end

About participants_helper

This is a helper file for the participants_controller class. It provides some of the basic functionalities that is required to create participants that are added to expertiza.

  def self.create_new_user(attrs, session)
   user = User.new
   user.update_attributes attrs
   user.parent_id = (session[:user]).id
   user.save
   password = @user.reset_password
   prepared_mail = MailerHelper.send_mail_to_user(@user, "Your Expertiza account and password have been created.", "user_welcome", password)
   prepared_mail.deliver
   flash[:success] = "A new password has been sent to new user's e-mail address."
   user
 end

About mailer_helper

This helper file is for the mailer class. Its creates the structure of the mail body that is needed by the mailer class to send mails. It also holds all the attributes that are required to send a mail.

def self.send_mail_to_reviewer(user, subject, partial_name, type, obj_name)
   Mailer.sync_message ({
     to: user.email,
     subject: subject,
     body: {
       type: type,
       obj_name: obj_name,
       user: user,
       first_name: ApplicationHelper.get_user_first_name(user),
       partial_name: partial_name
     }
   })
 end
 def self.send_mail_for_invitation(user, subject, partial_name, type, obj_name)
   Mailer.sync_message ({
     to: user.email,
     subject: subject,
     body: {
       type: type,
       obj_name: obj_name,
       user: user,
       first_name: ApplicationHelper.get_user_first_name(user),
       partial_name: partial_name
     }
   })
 end

def self.send_mail_for_advertisement_response(user, subject, partial_name, type, obj_name)

   Mailer.sync_message ({
     to: user.email,
     subject: subject,
     body: {
       type: type,
       obj_name: obj_name,
       user: user,
       first_name: ApplicationHelper.get_user_first_name(user),
       partial_name: partial_name
     }
   })
 end

Files created in current project

  • app/views/mailer/partials/_file_submission_plain.html.erb
  • app/views/mailer/partials/_file_submission_html.html.erb
  • app/views/mailer/partials/_team_join_invite_html.html.erb
  • app/views/mailer/partials/_team_join_invite_plain.html.erb
  • app/views/mailer/partials/_file_submission_html.html.erb
  • app/views/mailer/partials/_file_submission_plain.html.erb
  • app/views/mailer/partials/_team_accept_invite_html.html.erb
  • app/views/mailer/partials/_team_accept_invite_plain.html.erb

Testing Details

UI testing of participant addition via CSV file and mail delivery check

  • Login as instructor. Create a new course and assignment.
  • Add new participant to an assignment using a import file option.
  • A mail is triggered for participant who do not have an expertiza account.

UI testing of file submission

  • Login as student. Go to assignment and open your work page.
  • Upload a new file submission. If the submission is made in review stage, a mail is triggered to a reviewer saying a new submission is available for a particular review round.

UI testing for sending/accepting invitation to join team

  • Login as student. Go to assignment and open your team page.
  • Search for a student with whom you want to team up and click on send invite. A mail is triggered to that student saying a new invite has been sent.
  • When the student accepts it, another mail is triggered back to the invitee saying the invite has been accepted.
  • When a team member responds to an advertisement, the student who hosted it gets a mail about that response.

Scope for Future Improvement

  • A mail is being triggered only when a file is submitted for revision. But on the submission of a link, no such mail is sent. So this is one of the areas which can be improved in the future.

References

https://github.com/cbaruah/expertiza.git

https://expertiza.ncsu.edu

http://research.csc.ncsu.edu/efg/expertiza

YouTube channel

How to install and run image file in docker