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

From Expertiza_Wiki
Jump to navigation Jump to search
 
(27 intermediate revisions by the same user 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 37: Line 36:


=== 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 72: 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 ==
Line 78: Line 76:
===Code Implementation===
===Code Implementation===


*Model '''review_chat.rb''' to validate if the query box is empty and restrict the query length to 255 characters.
 
*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_length_of :content , :maximum => 255,message: "Length must be less that 255 characters"
   validates_presence_of :content, message: "Content cannot be blank"
   validates_presence_of :content, message: "Content cannot be blank"


*Methods in the controller '''review_chats_controller.rb'''
*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
'''action_allowed?'''- Allow chat visibility to the reviewers and the authors of a particular interaction
Line 90: Line 91:
     review_chat = ReviewChat.find(params[:id])
     review_chat = ReviewChat.find(params[:id])
     allowed_users=Array.new
     allowed_users=Array.new
     team_id=review_chat.team_id
    response_map = ReviewChat.get_response_map(review_chat)
     team_id = response_map.reviewee_id
     teams_users = TeamsUser.where(team_id: team_id)
     teams_users = TeamsUser.where(team_id: team_id)
     teams_users.each do |teams_user|
     teams_users.each do |teams_user|
       allowed_users << User.find(teams_user.user_id).id
       allowed_users << User.find(teams_user.user_id).id
     end
     end
     allowed_users << Participant.find(review_chat.reviewer_id).user_id
     allowed_users << Participant.find(response_map.reviewer_id).user_id
     current_role_name.eql? 'Student' and allowed_users.include?(session[:user].id)
     current_role_name.eql? 'Student' and allowed_users.include?(session[:user].id)
   end
   end
Line 103: Line 105:
   def show
   def show
     @review_chat = ReviewChat.find(params[:id])
     @review_chat = ReviewChat.find(params[:id])
     @assignment_id=@review_chat.assignment_id
     @map_id=@review_chat.response_map_id
    @reviewer_id=@review_chat.reviewer_id
     @chat_log=ReviewChat.get_chat_log(@map_id)
    @team_id=@review_chat.team_id
     @chat_log=ReviewChat.where(:reviewer_id => @reviewer_id).where(:team_id => @team_id)
   end
   end


Line 113: Line 113:
   def submitted_response
   def submitted_response
     @review_chat = ReviewChat.find(params[:id])
     @review_chat = ReviewChat.find(params[:id])
     @chat_reviewer=Participant.find(@review_chat.reviewer_id).user_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
     if(@chat_reviewer==session[:user].id) then
     ReviewChat.create(:assignment_id => @review_chat.assignment_id,:reviewer_id => @review_chat.reviewer_id, :team_id=>@review_chat.team_id, :type_flag => 'Q' , :content => params[:response_area])
     ReviewChat.create(:response_map_id => @review_chat.response_map_id, :type_flag => 'Q' , :content => params[:response_area])
     ReviewChatsHelper::chat_email_query(params[:id])
     ReviewChatsHelper::chat_email_query(params[:id])
     flash[:notice]="Query has been submitted"
     flash[:notice]="Query has been submitted"
     else
     else
       ReviewChat.create(:assignment_id => @review_chat.assignment_id,:reviewer_id => @review_chat.reviewer_id, :team_id=>@review_chat.team_id, :type_flag => 'A' , :content => params[:response_area])
       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)
       ReviewChatsHelper::chat_email_response(@review_chat.id,@chat_reviewer)
       flash[:notice]="Response has been submitted"
       flash[:notice]="Response has been submitted"
Line 126: Line 127:
   end
   end


*Methods in the helper file '''review_chats_helper.rb'''
*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
'''chat_email_response'''- Send an email to the author of an assignment when a reviewer posts a query
Line 141: Line 142:
     defn[:to] = reviewer_email
     defn[:to] = reviewer_email
     Mailer.sync_message(defn).deliver
     Mailer.sync_message(defn).deliver
   end  
   end


'''chat_email_query'''- Send an email to the author of an assignment when a reviewer posts a query
'''chat_email_query'''- Send an email to the author of an assignment when a reviewer posts a query
Line 149: Line 150:
     defn[:body] = Hash.new
     defn[:body] = Hash.new
     defn[:body][:partial_name] = partial
     defn[:body][:partial_name] = partial
    assignment=nil
     @review_chat=ReviewChat.find(id)
     @team_id=ReviewChat.find(id).team_id
    response_map = ReviewChat.get_response_map(@review_chat)
    @team_id = response_map.reviewee_id
     teams_users = TeamsUser.where(team_id: @team_id)
     teams_users = TeamsUser.where(team_id: @team_id)
     to_mail_list = Array.new
     to_mail_list = Array.new
Line 162: Line 164:
     defn[:to] = to_mail_list
     defn[:to] = to_mail_list
     Mailer.sync_message(defn).deliver
     Mailer.sync_message(defn).deliver
  end
   end
   end


*New method in existing controller '''response_controller.rb'''
*Modify existing controller '''response_controller.rb''' and add a new method.


'''submitted_question'''- Create a chat record and send an email to the authors when a reviewer posts a query.
'''initiate_chat'''- Create a chat record and send an email to the authors when a reviewer posts a query.
   def submitted_question
   def initiate_chat
       @map = ResponseMap.find(params[:id])
       @map = ResponseMap.find(params[:id])
       ReviewChat.create(:assignment_id => @map.assignment.id,:reviewer_id => @map.reviewer_id, :team_id=>@map.reviewee_id, :type_flag => 'Q' , :content => params[:review_question])
       ReviewChat.create( :response_map_id=>@map.id, :type_flag => 'Q' , :content => params[:review_question])
       flash[:notice]="Question has been submitted to Author"
       flash[:notice]="Question has been submitted to Author"
       @interaction_id=ReviewChat.where(:reviewer_id => @map.reviewer_id).where(:team_id => @map.reviewee_id)
       @interaction_id=ReviewChat.where(:response_map_id => @map.id)
       ReviewChatsHelper::chat_email_query(@interaction_id.first.id)
       ReviewChatsHelper::chat_email_query(@interaction_id.first.id)
       redirect_to action: 'new', id: params[:id]
       redirect_to action: 'new', id: params[:id]
   end
   end
*Create new view '''Show.html.erb''' to show the existing chat record and a box to respond and ask a follow up query.
*Create a new view '''show.html.erb''' to show the existing chat record and a box to respond and ask a follow up query.
 
<h1> Chat Log </h1>
 
<table border=1 cellpadding="30">
    <tr>
      <th style = "width:160px;padding-left:5px;padding-right:5px"> Q/A </th>
      <th style = "width:500px;padding-left:5px;padding-right:5px"> Content</th>
      <th style = "padding-left:5px;padding-right:5px"> Timestamp</th>
    </tr>
 
    <% @chat_log.each do |chat_log| %>
      <tr>
        <% if chat_log.type_flag == 'Q' %>
        <td style = "width:160px;padding-left:5px;padding-right:5px" > Query </td>
        <%else%>
        <td style = "width:160px;padding-left:5px;padding-right:5px" > Response </td>
        <%end%>
        <td style = "width:500px;padding-left:5px;padding-right:5px" > <%= chat_log.content %> </td>
        <td style = "padding-left:5px;padding-right:5px"> <%= chat_log.created_at.strftime("%Y-%m-%d %I:%M:%S %p") %> </td>
        <%end%>
</tr>
</table>
 
<p style="position:fixed; bottom:0px; right:100px ">
      <%= form_tag :action => "submitted_response" , :id => params[:id] do %>
      <label for="response">Post your query/response</label><BR/>
      <textarea cols="30" rows="4" id="response_area" name="response_area" style="overflow:hidden;">
        </textarea> <br/>
<%= submit_tag "Submit", :name => "submit_response" %><% end %>
 
 
 
    </p>
 
*Modify view expertiza/app/views/response/response.html.erb to incorporate text box and corresponding submit button.


===Flowchart===
===Flowchart===
Line 216: Line 184:
[[File: ARSNFlowchart1.png]]
[[File: ARSNFlowchart1.png]]


===Screenshots===
==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 227: Line 198:
*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 236: 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/>