CSC/ECE 517 Fall 2015 E1586 AnonymousChatBetweenAuthorAndReviewer: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(47 intermediate revisions by 2 users not shown)
Line 23: Line 23:


=== Discussion of Resolution ===
=== Discussion of Resolution ===
 
Following modifications were made to implement the chat feature:- <br>
We will make the following modifications to implement the chat feature:- <br>


*Create a new model which will help to extract, store and validate data in the database table which contains information about the interaction between the author/s and reviewer.
*Create a new model which will help to extract, store and validate data in the database table which contains information about the interaction between the author/s and reviewer.
Line 30: Line 29:
*Edit the view which is used by the response controller to incorporate the text area input field on the review form where the reviewer can ask his/her initial query.
*Edit the view which is used by the response controller to incorporate the text area input field on the review form where the reviewer can ask his/her initial query.


*Create a new controller which will contain methods to send emails to the author and reviewers as well as retrieve and display the chat history between the two.
*Create a new controller with methods for authentication for a respective chat log only visible to the author and reviewer of a particular assignment, method to submit a response or a follow up query and show the existing interaction log.
 
*Create a new helper with the e-mail methods for sending to the author and reviewer.


*Create a new view which will facilitate the author to respond to the queries asked by the reviewer. The reviewer can also use this view to ask any follow up questions.
*Create a new view which will facilitate the author to respond to the queries asked by the reviewer. The reviewer can also use this view to ask any follow up questions.
=== Mock-Ups ===
The sample question box would look like:
[[File: ARSNMockup1.JPG]]
An interface with the question would be displayed on opening a link from the email.
The authors can reply the query which reviewers ask.
[[File: ARSNMockup2.JPG]]


=== Design Patterns ===
=== Design Patterns ===
The implementation team expects that the following design patterns be used in the solution:
The following design patterns were used for the solution:
   
   
* '''Observer Pattern'''<ref>Observer Design Pattern https://en.wikipedia.org/wiki/Observer_pattern</ref>: The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. For example, we are notifying the team members whenever the reviewer submits the query.
* '''Observer Pattern'''<ref>Observer Design Pattern https://en.wikipedia.org/wiki/Observer_pattern</ref>: The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. For example, we are notifying the team members whenever the reviewer submits the query.
Line 53: Line 44:
=== Database Design ===
=== Database Design ===


[[File:DatabaseTable.jpg]]
[[File:Review_chats.png]]


The above figure shows the schema of a new table which will be created in Expertiza to store relevant information about the chat. It contains the following attributes:
The above figure shows the schema of a new table which will be created in Expertiza to store relevant information about the chat. It contains the following attributes:
Line 80: Line 71:
2. For use case 2, test whether the reviewer receive email with the response.<br/>
2. For use case 2, test whether the reviewer receive email with the response.<br/>
3. Test whether all the previous interactions are displayed as chat history.<br/>
3. Test whether all the previous interactions are displayed as chat history.<br/>
4. The 'Ask Question' button should not be enabled until some text has been entered in the text area.


== Implementation ==
== Implementation ==


'''Files created/modified'''
===Code Implementation===
 
 
*Create a new model '''review_chat.rb''' for ReviewChat.
 
'''Validation'''- Check if the query box is not empty and restrict the query length to 255 characters.
 
  validates_length_of :content , :maximum => 255,message: "Length must be less that 255 characters"
  validates_presence_of :content, message: "Content cannot be blank"
 
*Create a new controller '''review_chats_controller.rb''' with the following methods:
 
'''action_allowed?'''- Allow chat visibility to the reviewers and the authors of a particular interaction
 
  def action_allowed?
    review_chat = ReviewChat.find(params[:id])
    allowed_users=Array.new
    response_map = ReviewChat.get_response_map(review_chat)
    team_id = response_map.reviewee_id
    teams_users = TeamsUser.where(team_id: team_id)
    teams_users.each do |teams_user|
      allowed_users << User.find(teams_user.user_id).id
    end
    allowed_users << Participant.find(response_map.reviewer_id).user_id
    current_role_name.eql? 'Student' and allowed_users.include?(session[:user].id)
  end
 
'''show'''- Show the chat interaction log
 
  def show
    @review_chat = ReviewChat.find(params[:id])
    @map_id=@review_chat.response_map_id
    @chat_log=ReviewChat.get_chat_log(@map_id)
  end
 
'''submitted_response'''- Create a chat record and send an email to the reviewer when an author replied to a query asked by the reviewer
 
  def submitted_response
    @review_chat = ReviewChat.find(params[:id])
    response_map = ReviewResponseMap.find(@review_chat.response_map_id)
    @chat_reviewer=Participant.find(response_map.reviewer_id).user_id
    if(@chat_reviewer==session[:user].id) then
    ReviewChat.create(:response_map_id => @review_chat.response_map_id, :type_flag => 'Q' , :content => params[:response_area])
    ReviewChatsHelper::chat_email_query(params[:id])
    flash[:notice]="Query has been submitted"
    else
      ReviewChat.create(:response_map_id => @review_chat.response_map_id, :type_flag => 'A' , :content => params[:response_area])
      ReviewChatsHelper::chat_email_response(@review_chat.id,@chat_reviewer)
      flash[:notice]="Response has been submitted"
    end
    redirect_to action: 'show', id: params[:id]
  end
 
*Create a helper file '''review_chats_helper.rb''' with the following methods:
 
'''chat_email_response'''- Send an email to the author of an assignment when a reviewer posts a query
 
  def self.chat_email_response(id,reviewer_id,partial="new_chatemail")
    defn = Hash.new
    defn[:body] = Hash.new
    defn[:body][:partial_name] = partial
    reviewer_email=User.find(reviewer_id).email
    defn[:subject] = "Response posted for submission"
    defn[:body][:type] = " response has been posted for your query .
    Please open the below URL to view.
    http://expertiza.ncsu.edu/review_chats/show/#{id}"
    defn[:to] = reviewer_email
    Mailer.sync_message(defn).deliver
  end


*Create a new model '''ReviewChat''' .
'''chat_email_query'''- Send an email to the author of an assignment when a reviewer posts a query


*Create a new controller '''ReviewChats'''.
  def self.chat_email_query(id,partial="new_chatemail")
    defn = Hash.new
    defn[:body] = Hash.new
    defn[:body][:partial_name] = partial
    @review_chat=ReviewChat.find(id)
    response_map = ReviewChat.get_response_map(@review_chat)
    @team_id = response_map.reviewee_id
    teams_users = TeamsUser.where(team_id: @team_id)
    to_mail_list = Array.new
    teams_users.each do |teams_user|
    to_mail_list << User.find(teams_user.user_id).email
    end
    defn[:subject] = "Query posted for submission"
    defn[:body][:type] = " query has been posted for your submission .
    Please open the below URL to view and respond.
    http://expertiza.ncsu.edu/review_chats/show/#{id}"
    defn[:to] = to_mail_list
    Mailer.sync_message(defn).deliver
  end
  end


*Create new views as discussed in the design.
*Modify existing controller '''response_controller.rb''' and add a new method.


*Modify view expertiza/app/views/response/response.html.erb to incorporate text box and corresponding submit button.
'''initiate_chat'''- Create a chat record and send an email to the authors when a reviewer posts a query.
  def initiate_chat
      @map = ResponseMap.find(params[:id])
      ReviewChat.create( :response_map_id=>@map.id, :type_flag => 'Q' , :content => params[:review_question])
      flash[:notice]="Question has been submitted to Author"
      @interaction_id=ReviewChat.where(:response_map_id => @map.id)
      ReviewChatsHelper::chat_email_query(@interaction_id.first.id)
      redirect_to action: 'new', id: params[:id]
  end
*Create a new view '''show.html.erb''' to show the existing chat record and a box to respond and ask a follow up query.


'''Flowchart'''
===Flowchart===


[[File: ARSNFlowchart1.png]]
[[File: ARSNFlowchart1.png]]


'''Flow'''
==Testing==
===User Interface Testing===


* Login to Expertiza with a student account. You can use login id as 'student5700' and password as 'password'.
* Start reviewing an existing assignment. You would see a small query box at the bottom of the page.
*The reviewer enters his question in the text area provided and clicks on the "Submit" button.
*The reviewer enters his question in the text area provided and clicks on the "Submit" button.
[[File: FinalProject1.jpg]]
[[File: FinalProject1.jpg]]
Line 105: Line 194:
[[File: FinalProject4.jpg]]
[[File: FinalProject4.jpg]]
*On answering the question, the reviewer receives an email indicating that his question has been answered. It also contains a link which redirects the reviewer to the appropriate view where the answer will be displayed.
*On answering the question, the reviewer receives an email indicating that his question has been answered. It also contains a link which redirects the reviewer to the appropriate view where the answer will be displayed.
*The authorized users will also be able to see a link to open existing chat interaction log.
[[File: FinalProject3.jpg]]
*This view also contains the chat history between the author/s and the reviewer for the entire duration of the interaction.
*This view also contains the chat history between the author/s and the reviewer for the entire duration of the interaction.
[[File: FinalProject2.jpg]]
[[File: FinalProject2.jpg]]
===Model Testing===
* Create a model test file '''review_chat_test.rb''' with the below tests.
'''Presence of response_map_id'''
  test "response_map_id should be present" do
    @review_chat.response_map_id = " "
    assert_not @review_chat.response_map_id?
  end
'''Presence of content'''
  test "content should be present (nonblank)" do
    @review_chat.content = " " * 6
    assert_not @review_chat.valid?
  end
'''Length of content'''
  test "content should have a maximum length of 255" do
    @review_chat.content = "a" * 250
    assert @review_chat.valid?
  end
* To run the tests,
  bin/rake test test/models/review_chat_test.rb
===Web Testing===
* Create a browser automation test using [http://imacros.net/overview imacros] in Firefox/Chrome browser.
* Run the simulation to test the Expertiza chat operation in the browser.


== Suggestions for Future Improvements ==
== Suggestions for Future Improvements ==
Line 116: Line 239:


* Expertiza Github repository<ref>Expertiza Github repository https://github.com/expertiza/expertiza</ref>
* Expertiza Github repository<ref>Expertiza Github repository https://github.com/expertiza/expertiza</ref>
* Demo video<ref>Demo video https://www.youtube.com/watch?v=8E-hYiJVoZI</ref>
* Github Pull request<ref>Github Pull request https://github.com/expertiza/expertiza/pull/628</ref>


==References==
==References==
<references/>
<references/>

Latest revision as of 03:47, 17 December 2015

E1586 AnonymousChatBetweenAuthorAndReviewer

This page provides a brief description of the Expertiza project. The project is aimed at developing an email based anonymous session between author and a reviewer so that reviewers can ask questions to the authors for any doubts related to the assignments during peer reviewing.

Project

Introduction to Expertiza

Expertiza is a peer review based system which provides an incremental class based learning together with the instructors and the peers. This project has been developed together by faculty and students using Ruby on Rails framework. Expertiza handles assignment submissions, team formations, assignment reviews and grades, etc.

Purpose

During reviews, many times reviewers will be having questions about the submitted material and if it's a blocker there is no way that the reviewer can progress further with the review. As a result, reviewers will end up submitting the empty or incomplete review.

Scope

This project is limited to an email based conversation for asking questions and answers. The reviewers would ask questions related to assignment submission doubts to which authors can respond. All this would be taken care as email responses using a link provided in the email. This project does not cater to any live interactive session with spontaneous back-to-back questions and responses.

Following tasks would be incorporated in the project:

  • Provide a ‘TextArea’ input field on review forms, where any reviewer can type in their questions.
  • Create a new button ‘Ask for Quick Help’ on the review forms.
  • An email would be send to the author with the link where he can respond to the questions asked by the reviewers for their submitted work.
  • Reviewers would be notified by an email when authors respond to the the questions.

Design

Discussion of Resolution

Following modifications were made to implement the chat feature:-

  • Create a new model which will help to extract, store and validate data in the database table which contains information about the interaction between the author/s and reviewer.
  • Edit the view which is used by the response controller to incorporate the text area input field on the review form where the reviewer can ask his/her initial query.
  • Create a new controller with methods for authentication for a respective chat log only visible to the author and reviewer of a particular assignment, method to submit a response or a follow up query and show the existing interaction log.
  • Create a new helper with the e-mail methods for sending to the author and reviewer.
  • Create a new view which will facilitate the author to respond to the queries asked by the reviewer. The reviewer can also use this view to ask any follow up questions.

Design Patterns

The following design patterns were used for the solution:

  • Observer Pattern<ref>Observer Design Pattern https://en.wikipedia.org/wiki/Observer_pattern</ref>: The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. For example, we are notifying the team members whenever the reviewer submits the query.
  • Iterator Pattern: In our instance, we need to display the entire chat history of a particular interaction, hence we can use the iterator design pattern to iterate through the previous chat messages.

Database Design

The above figure shows the schema of a new table which will be created in Expertiza to store relevant information about the chat. It contains the following attributes:

  • id: This attribute is auto-generated by rails when we create a table and is auto incremented with each record. It is also the primary key of our table.
  • assignment_id: Stores the ID of the assignment for which the interaction between author and reviewer is taking place.
  • reviewer_id: Stores the ID of the reviewer who asks the questions.
  • team_id: Stores the ID of the team to which the topic belongs.
  • type_flag: Flag which is used to indicate if the particular tuple contains a question or answer. It can take two values, 'Q' for question and 'A' for answer.
  • content: Stores the question asked by the reviewer or the response given by the author/s depending on the value of the type flag.

Records for a particular interaction can be identified by using a combination of assignment_id, reviewer_id and team_id.

Use Cases

Name: Send a question to the author/s about their work.
Actor: Reviewer.
Description: The reviewer enters his question in the text area which is provided and clicks on the "Ask question" button which is provided as shown in the mock up. On clicking this button an email is sent to the author/s along which a link to answer the question.

Name: Answer the question which has been asked by the reviewer.
Actor: Author/s
Description: The author/s click on the link received in their email and are redirected to a page where they can answer the question. Once they submit the answer, an email is sent to the reviewer notifying him/her that their question has been answered.

Proposed Tests

1. For use case 1, test whether all the team members receive email with the question.
2. For use case 2, test whether the reviewer receive email with the response.
3. Test whether all the previous interactions are displayed as chat history.

Implementation

Code Implementation

  • Create a new model review_chat.rb for ReviewChat.

Validation- Check if the query box is not empty and restrict the query length to 255 characters.

 validates_length_of :content , :maximum => 255,message: "Length must be less that 255 characters"
 validates_presence_of :content, message: "Content cannot be blank"
  • Create a new controller review_chats_controller.rb with the following methods:

action_allowed?- Allow chat visibility to the reviewers and the authors of a particular interaction

 def action_allowed?
   review_chat = ReviewChat.find(params[:id])
   allowed_users=Array.new
   response_map = ReviewChat.get_response_map(review_chat)
   team_id = response_map.reviewee_id
   teams_users = TeamsUser.where(team_id: team_id)
   teams_users.each do |teams_user|
     allowed_users << User.find(teams_user.user_id).id
   end
   allowed_users << Participant.find(response_map.reviewer_id).user_id
   current_role_name.eql? 'Student' and allowed_users.include?(session[:user].id)
 end

show- Show the chat interaction log

 def show
   @review_chat = ReviewChat.find(params[:id])
   @map_id=@review_chat.response_map_id
   @chat_log=ReviewChat.get_chat_log(@map_id)
 end

submitted_response- Create a chat record and send an email to the reviewer when an author replied to a query asked by the reviewer

 def submitted_response
   @review_chat = ReviewChat.find(params[:id])
   response_map = ReviewResponseMap.find(@review_chat.response_map_id)
   @chat_reviewer=Participant.find(response_map.reviewer_id).user_id
   if(@chat_reviewer==session[:user].id) then
   	ReviewChat.create(:response_map_id => @review_chat.response_map_id, :type_flag => 'Q' , :content => params[:response_area])
   	ReviewChatsHelper::chat_email_query(params[:id])
   	flash[:notice]="Query has been submitted"	
   else	
     	ReviewChat.create(:response_map_id => @review_chat.response_map_id, :type_flag => 'A' , :content => params[:response_area])
     	ReviewChatsHelper::chat_email_response(@review_chat.id,@chat_reviewer)
     flash[:notice]="Response has been submitted"
   end	
   redirect_to action: 'show', id: params[:id]
 end
  • Create a helper file review_chats_helper.rb with the following methods:

chat_email_response- Send an email to the author of an assignment when a reviewer posts a query

 def self.chat_email_response(id,reviewer_id,partial="new_chatemail")
   defn = Hash.new
   defn[:body] = Hash.new
   defn[:body][:partial_name] = partial
   reviewer_email=User.find(reviewer_id).email
   defn[:subject] = "Response posted for submission"
   defn[:body][:type] = " response has been posted for your query .
   Please open the below URL to view.
   http://expertiza.ncsu.edu/review_chats/show/#{id}"
   defn[:to] = reviewer_email
   Mailer.sync_message(defn).deliver
 end

chat_email_query- Send an email to the author of an assignment when a reviewer posts a query

 def self.chat_email_query(id,partial="new_chatemail")
   defn = Hash.new
   defn[:body] = Hash.new
   defn[:body][:partial_name] = partial
   @review_chat=ReviewChat.find(id)
   response_map = ReviewChat.get_response_map(@review_chat)
   @team_id = response_map.reviewee_id
   teams_users = TeamsUser.where(team_id: @team_id)
   to_mail_list = Array.new
   teams_users.each do |teams_user|
   to_mail_list << User.find(teams_user.user_id).email 
   end
   defn[:subject] = "Query posted for submission"
   defn[:body][:type] = " query has been posted for your submission .
   Please open the below URL to view and respond.
   http://expertiza.ncsu.edu/review_chats/show/#{id}"
   defn[:to] = to_mail_list
   Mailer.sync_message(defn).deliver
 end
 end
  • Modify existing controller response_controller.rb and add a new method.

initiate_chat- Create a chat record and send an email to the authors when a reviewer posts a query.

 def initiate_chat
     @map = ResponseMap.find(params[:id])
     ReviewChat.create( :response_map_id=>@map.id, :type_flag => 'Q' , :content => params[:review_question])
     flash[:notice]="Question has been submitted to Author"
     @interaction_id=ReviewChat.where(:response_map_id => @map.id)
     ReviewChatsHelper::chat_email_query(@interaction_id.first.id)
     redirect_to action: 'new', id: params[:id]
 end
  • Create a new view show.html.erb to show the existing chat record and a box to respond and ask a follow up query.

Flowchart

Testing

User Interface Testing

  • Login to Expertiza with a student account. You can use login id as 'student5700' and password as 'password'.
  • Start reviewing an existing assignment. You would see a small query box at the bottom of the page.
  • The reviewer enters his question in the text area provided and clicks on the "Submit" button.

  • On clicking this button the appropriate method is called in ReviewChats controller which sends an email to all the authors of the topic indicating that a question has been asked about their work. The email contains a link which when clicked on will redirect the author to the appropriate view where he/she can answer the question.

  • On answering the question, the reviewer receives an email indicating that his question has been answered. It also contains a link which redirects the reviewer to the appropriate view where the answer will be displayed.
  • The authorized users will also be able to see a link to open existing chat interaction log.

  • This view also contains the chat history between the author/s and the reviewer for the entire duration of the interaction.

Model Testing

  • Create a model test file review_chat_test.rb with the below tests.

Presence of response_map_id

 test "response_map_id should be present" do
   @review_chat.response_map_id = " "
   assert_not @review_chat.response_map_id?
 end

Presence of content

 test "content should be present (nonblank)" do
   @review_chat.content = " " * 6
   assert_not @review_chat.valid?
 end

Length of content

 test "content should have a maximum length of 255" do
   @review_chat.content = "a" * 250
   assert @review_chat.valid?
 end
  • To run the tests,
 bin/rake test test/models/review_chat_test.rb

Web Testing

  • Create a browser automation test using imacros in Firefox/Chrome browser.
  • Run the simulation to test the Expertiza chat operation in the browser.

Suggestions for Future Improvements

  • This can be extended to a live interactive author-reviewer anonymous chat session inside the Expertiza reviews window.
  • A purging script can be developed which will clear all the interaction records every semester.

Resources

References

<references/>