CSC/ECE 517 Fall 2018/E1834 Improve email notifications: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 77: Line 77:
   end
   end


Corresponding methods in the assignment_participant model were added.


  # assignment_participant model
  def is_round_valid_for_mail?
    topic_id = SignedUpTeam.topic_id(self.parent_id, self.user_id)
    return assignment.review_deadline(topic_id, assignment.num_review_rounds)
  end
 
  def number_of_current_round
    topic_id = SignedUpTeam.topic_id(self.parent_id, self.user_id)
    assignment.number_of_current_round(topic_id)
  end
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 ResponseMap class.
  #submitted_content_controller.
   # Send email to reviewers to review new submission, if review_round is valid and not last.
   # Send email to reviewers to review new submission, if review_round is valid and not last.
  if participant.is_round_valid_for_mail?
      if participant.is_round_valid_for_mail?
    current_round = participant.number_of_current_round
        #reviewers = []
    reviewers = []
        participant.reviewers.each do |reviewer|
    participant.reviewers.each do |reviewer|
          review_mappings = ResponseMap.where(reviewer_id: reviewer.id)
      reviewers << User.find(reviewer.user_id).email
          review_mappings.each do |map|
    end
            reviewed_object_id = ''
    Mailer.delayed_message(bcc: reviewers, subject: "You have a new submission to review for Review #{current_round}",  
            if map.reviewee_id == @participant.id || map.reviewee_id == @participant.team.id
    body: "Please visit #{team.hyperlinks['submission']} and proceed to peer reviews.").deliver_now
              reviewed_object_id = map.reviewed_object_id
  end
              Mailer.delayed_message(bcc: User.find(reviewer.user_id).email, subject: "You have a new submission to review", body: "Please visit https://expertiza.ncsu.edu/response/edit?id=#{reviewed_object_id} and proceed to peer reviews.").deliver_now
            end
          end
        end
      end

Revision as of 06:01, 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

  • 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. So this involves adding a call to the e-mailer … or, perhaps, moving an email call from the Users controller to the point where an account is actually created.
  • Second, evidently if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review is in progress.The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed. It would also be nice to fix the message so it tells which review (Review 1, Review 2, etc.) has been revised, and gives the reviewer a link directly to it.
  • Deadline reminders should include a link on where to go to perform the needed function.

    Approach Taken To Implement Changes

    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.

    1) Mail sent when participant added 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 model to send mails when a participant is added to an assignment on the assignment page through a CSV file.This functionality is implemented with using the MailerHelper class.

      # provide import functionality for Assignment Participants
      # if user does not exist, it will be created and added to this assignment
     def self.import(row_hash, _row_header = nil, session, id)
       raise ArgumentError, "No user id has been specified." if row_hash.empty?
       user = User.find_by(name: row_hash[:name])
       if user.nil?
         raise ArgumentError, "The record containing #{row_hash[:name]} does not have enough items." if row_hash.length < 4
         attributes = ImportFileHelper.define_attributes(row_hash)
         user = ImportFileHelper.create_new_user(attributes, session)
       end
       raise ImportError, "The assignment with id \"#{id.to_s}\" was not found." if Assignment.find(id).nil?
       unless AssignmentParticipant.exists?(user_id: user.id, parent_id: id)
         new_part = AssignmentParticipant.create(user_id: user.id, parent_id: id)
         new_part.set_handle
       end
       prepared_mail = MailerHelper.send_mail_to_user(user, "Your Expertiza account and password have been created.", "user_welcome", "password")
       prepared_mail.deliver
     end
    


    We have in a similar fashion added a method in the course_participant model.

     # provide import functionality for Course Participants
     # if user does not exist, it will be created and added to this assignment
     def self.import(row_hash, _row_header = nil, session, id)
       raise ArgumentError, "No user id has been specified." if row_hash.empty?
       user = User.find_by(name: row_hash[:name])
       if user.nil?
         raise ArgumentError, "The record containing #{row_hash[:name]} does not have enough items." if row_hash.length < 4
         attributes = ImportFileHelper.define_attributes(row_hash)
         user = ImportFileHelper.create_new_user(attributes, session)
       end
       course = Course.find_by(id)
       raise ImportError, "The course with the id \"" + id.to_s + "\" was not found." if course.nil?
       unless CourseParticipant.exists?(user_id: user.id, parent_id: id)
         CourseParticipant.create(user_id: user.id, parent_id: id)
       end
       password = "password"#user.password
       prepared_mail = MailerHelper.send_mail_to_user(user, "Your Expertiza account and password have been created.", "user_welcome", password)
       prepared_mail.deliver
     end
    


    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 and assignment_participant models. The method handled boundary constraints like checking whether the round was valid and disabling email notification after the last round of review.

     #assignment.rb model
     # E1834 Fall 18
     def review_deadline(topic_id = nil, num_review_rounds)
       return false if topic_id.nil? and self.staggered_deadline?
       next_due_date = DueDate.get_next_due_date(self.id, topic_id)
       return !(next_due_date.round == num_review_rounds && next_due_date.deadline_type_id == 2)
     end
    

    Corresponding methods in the assignment_participant model were added.

     # assignment_participant model
     def is_round_valid_for_mail?
       topic_id = SignedUpTeam.topic_id(self.parent_id, self.user_id)
       return assignment.review_deadline(topic_id, assignment.num_review_rounds)
     end
      
     def number_of_current_round
       topic_id = SignedUpTeam.topic_id(self.parent_id, self.user_id)
       assignment.number_of_current_round(topic_id)
     end
    

    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 ResponseMap class.

      #submitted_content_controller.
      # Send email to reviewers to review new submission, if review_round is valid and not last.
         if participant.is_round_valid_for_mail?
           #reviewers = []
           participant.reviewers.each do |reviewer|
             review_mappings = ResponseMap.where(reviewer_id: reviewer.id)
             review_mappings.each do |map|
               reviewed_object_id = 
               if map.reviewee_id == @participant.id || map.reviewee_id == @participant.team.id
                 reviewed_object_id = map.reviewed_object_id
                 Mailer.delayed_message(bcc: User.find(reviewer.user_id).email, subject: "You have a new submission to review", body: "Please visit https://expertiza.ncsu.edu/response/edit?id=#{reviewed_object_id} and proceed to peer reviews.").deliver_now
               end
             end
           end
         end