CSC/ECE 517 Fall 2019 - E1966. Tabbed reviews partial file refactor for displaying the alternate view of reviews: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 20: Line 20:


* In student end, add render partial to tabbed reviews.
* In student end, add render partial to tabbed reviews.
'''app/views/grades/_participant.html.erb '''
'''app/views/grades/_participant.html.erb '''
<pre>
<pre>
Line 27: Line 28:
</TR>
</TR>
</pre>
</pre>
* Add feed back link in student end view.
'''app/views/grades/_tabbed_reviews.html.erb '''
<pre>
    <% rounds.each do |round| %>
        <h3>Round <%= round %></h3>
        <a href="#" name= <%= participant.id.to_s + '_' + round.to_s + "Link" %> onClick="toggleElement('<%= participant.id.to_s +
                '_' + round.to_s %>','round <%= round.to_s%> reviews');return false;">show round <%= round.to_s%> reviews</a>
        <table class="table table-striped" id=<%= participant.id.to_s + '_' + round.to_s %> <%= style="display: none;" if controller.action_name != "view_my_scores"%>>
            <% rscore[:assessments].select{|response| response.round == round}.reverse.uniq{|response| response.map_id}.sort_by{|response| response.map_id}.each_with_index do |review, index| %>
                <tr><td>
                <% review_feedback = nil %>
                        <%= display_directory_tree(@participant, files, true).html_safe %>
                    <% end %>
                <% end %>
                <%= review.display_as_html(prefix, index + 1, nil, true) %>
                <!-- Generate the feedback html -->
                <% map = FeedbackResponseMap.where(reviewed_object_id: review.id, reviewer_id: participant.id).first
                    review_feedbacks = map.try :response %>
                <% if review_feedbacks && !review_feedbacks.empty? %>
                    <%= link_to "View", :controller => 'response', :action => 'view', :id => review_feedbacks.first.id %> or
                    <%= link_to "Edit", :controller => 'response', :action => 'edit', :id => review_feedbacks.first.id, :return => "feedback" %> feedback for Review <%= count %>
                <% else %>                 
                    <%= link_to "Give feedback", :controller => 'response', :action => 'new_feedback', :id => review.id %> for Review <%= count %>
                <% end %>
                </td></tr>
            <% end %>
        </table><hr>
</pre>
* Add javascript to tabbed review so it can be hidden or shown by clicking the show/hide reviews.
'''app/views/grades/_tabbed_reviews.html.erb '''
<pre>
<script type="text/javascript">
  toggle_tag_prompt = function() {
    $('.tag_prompt_container').toggle();
  };
  $( document ).ready(function() {
    $('#tag_prompt_toggler').click(function () {
      if ($('#tag_prompt_toggler').text() == "hide tags")
        $('#tag_prompt_toggler').text("show tags")
      else
        $('#tag_prompt_toggler').text("hide tags")
    });
  });
</script>
</pre>
* Add statistic view to student end by using the team_review_statistics.html.erb file.
'''app/views/grades/_participant.html.erb '''
<pre>
<TR id="<%= prefix %>_reviews" style="display:none; background-color: white;">
    <TD COLSPAN="10">
    <%= render :partial=>'grades/team_review_statistics', :locals => {:prefix => 'user', :participant => participant, :pscore => pscore} %>
    <%= render :partial=>'grades/tabbed_reviews', :locals => {:prefix => 'user', :participant => participant, :rscore => pscore[:review]} %>
    </TD>
</TR>
</pre>
'''app/views/grades/_tabbed_reviews.html.erb'''
<pre>
<% if @assignment.is_answer_tagging_allowed %>
            <span class="spn_qsttog" id="tag_prompt_toggler" title="Click to display/hide tags" onclick="toggle_tag_prompt()">hide tags</span>
        <% end %>
</pre>
'''app/views/grades/_team_review_statistics.html.erb'''
<pre>
<% if controller.action_name != "view_my_scores"%>
    <tr>
        <td colspan="10">
<% end %>
<% if rscore and rscore[:assessments].length > 0 %>
    <%flag_varying_rubrics=false%>
@@ -25,6 +29,9 @@
    <%if flag_varying_rubrics==false%>
        <%= render :partial => 'grades/review_table', :locals => { :ctrl => 'review', :caction => 'view_review', :symbol => "review".to_sym, :prefix => prefix, :assignment => participant.assignment, :reviews => rscore[:assessments], :collabel => "Review", :rowlabel => "Reviewer" }%>
    <%end%>
    </td>
</tr>
<% end %> 
<% if controller.action_name != "view_my_scores"%>   
        </td>
    </tr>
<% end %>
</pre>
===Instructor End===


*  
* Create new method view2 for response_controller


''' app/controllers/response_controller.rb '''
<pre>
def view2
    @response = Response.find(params[:id])
    @map = @response.map
    set_content2
    render "response/view"
  end
......
......
    @participant = @map.reviewer
......
def set_content2(new_response = false)
    @contributor = @map.contributor
    members = TeamsUser.where(team_id: params[:team])
    @user = members.first
    @participant = AssignmentParticipant.where(user_id: @user.user_id, parent_id: params[:assignment]).first
@@ -264,7 +273,9 @@ def set_content(new_response = false)
    @questions = retrieve_questions questionnaires, @assignment.id
    # @pscore has the newest versions of response for each response map, and only one for each response map (unless it is vary rubric by round)
    @pscore = @participant.scores(@questions)
    @reviewer = @map.reviewer
    @round = params[:round]
  end 
</pre>


'''path to add '''
'''app/views/grades/_tabbed_reviews.html.erb '''
<pre>
<pre>
to do
                <% prefix = nil %>
......
<% if controller.action_name == "view_my_scores"%>
                    <!-- Generate the feedback html -->
                    <% map = FeedbackResponseMap.where(reviewed_object_id: review.id, reviewer_id: participant.id).first
                        review_feedbacks = map.try :response %>
                    <% if review_feedbacks && !review_feedbacks.empty? %>
                        <%= link_to "View", :controller => 'response', :action => 'view', :id => review_feedbacks.first.id %> or
                        <%= link_to "Edit", :controller => 'response', :action => 'edit', :id => review_feedbacks.first.id, :return => "feedback" %> feedback for Review <%= count %>
                    <% else %>
                        <%= link_to "Give feedback", :controller => 'response', :action => 'new_feedback', :id => review.id %> for Review <%= count %>
                    <% end %>
                </td></tr>
                <% end %>
            <% end %>
        </table><hr>
    <% end %>
</pre>
</pre>


''' app/views/grades/_view_heatgrid.html.erb '''
<pre>
                      <th class="sorter-false"> <a target="_blank" href="../response/view2?id=<%= review.id.to_s %>&&team=<%= @team.id %>&&round=<%= vm.round.to_s %>&&assignment=<%= @assignment.id %>" 
data-toggle="tooltip" data-placement="right" title="Click to see details"><%= user_name.to_s %></a>  </th>


</pre>


''' app/views/response/view.html.erb '''
<pre>
<% if controller.action_name != "view2" %>
    <% file_url = nil %>
    <%= @response.display_as_html(nil, nil, file_url) %>
    <br/>
<% else %>
    <TR style="display:none; background-color: white;">
        <TD COLSPAN="10">
        <%= render :partial=>'grades/tabbed_reviews', :locals => {:prefix => 'user', :participant => @participant, :rscore => @pscore[:review], :reviewer => @reviewer, :round => @round} %>
        </TD>
    </TR>
<% end %>
</pre>


'''path to add '''
* show right round for instructor-end
'''app/views/grades/_tabbed_reviews.html.erb'''
<pre>
<pre>
to do
        <% next if round.to_s != @round.to_s %>
</pre>
</pre>


'''path to add '''
* Create construct_instructor2_html in order to not show review number
''' app/models/response.rb '''
<pre>
if prefix == "instructor"
      self_id = self.id.to_s
      code = construct_instructor2_html identifier, self_id, count
    elsif prefix # has prefix means view_score page in instructor end
      self_id = prefix + '_' + self.id.to_s
      code = construct_instructor_html identifier, self_id, count
......
def construct_instructor2_html identifier, self_id, count
    identifier += '<table width="100%">'\
'<tr>'\
'<td align="left" width="70%"><b>Review ' + '</b>&nbsp;&nbsp;&nbsp;'\
'<a href="#" name= "review_' + self_id + 'Link" onClick="toggleElement(' + "'review_" + self_id + "','review'" + ');return false;">hide review</a>'\
'</td>'\
'<td align="left"><b>Last Reviewed:</b>'\
"<span>#{(self.updated_at.nil? ? 'Not available' : self.updated_at.strftime('%A %B %d %Y, %I:%M%p'))}</span></td>"\
'</tr></table>'
  end
</pre>


'''app/views/grades/_tabbed_reviews.html.erb'''
<pre>
<pre>
to do
<% if controller.action_name != "view2"%>
            <h3>Round <%= round %></h3>
            <% if controller.action_name != "view_my_scores" %>
                <a href="#" name= <%= participant.id.to_s + '_' + round.to_s + "Link" %> onClick="toggleElement('<%= participant.id.to_s + '_' + round.to_s %>','round <%= round.to_s%> reviews');return false;">show round <%= round.to_s%> reviews</a>
            <% end %>
        <% end %>
        <% if @assignment.is_answer_tagging_allowed %>
            <span class="spn_qsttog" id="tag_prompt_toggler" title="Click to display/hide tags" onclick="toggle_tag_prompt()">hide tags</span>
@@ -37,6 +39,7 @@
                <% review_feedback = nil %>
                <% count = count + 1 %>
                <% prefix = nil %>
                <% prefix = "instructor" if controller.action_name == "view2" %>
</pre>
</pre>


* Show just one review in instructor-end
'''app/views/grades/_tabbed_reviews.html.erb'''
<pre>
<% rounds.each do |round| %>
        <% if controller.action_name == "view2"%>
        <% next if round.to_s != @round.to_s %>
        <% end %>
        <% if controller.action_name != "view2"%>
            <h3>Round <%= round %></h3>
            <% if controller.action_name != "view_my_scores" %>
@@ -33,8 +35,13 @@
        <% if @assignment.is_answer_tagging_allowed %>
            <span class="spn_qsttog" id="tag_prompt_toggler" title="Click to display/hide tags" onclick="toggle_tag_prompt()">hide tags</span>
        <% end %>
        <% if controller.action_name != "view2"%>
        <table class="table table-striped" id=<%= participant.id.to_s + '_' + round.to_s %> <%= style="display: none;" if controller.action_name != "view_my_scores"%>>
        <% end %>
            <% rscore[:assessments].select{|response| response.round == round}.reverse.uniq{|response| response.map_id}.sort_by{|response| response.map_id}.each_with_index do |review, index| %>
                <% if controller.action_name == "view2"%>
                <% next if review.reviewer != @reviewer || count > 0 %>
                <% end %>
                <tr><td>
                <% review_feedback = nil %>
                <% count = count + 1 %>
@@ -72,7 +79,9 @@
                </td></tr>
                <% end %>
            <% end %>
        <% if controller.action_name != "view2"%>   
        </table><hr>
        <% end %>
    <% end %>
<% else %>
</pre>


=='''Test files'''==
=='''Test files'''==

Revision as of 19:23, 28 October 2019

About Expertiza

Expertiza is a open source project currently for CSC517 instructor and students forming groups, submit work, review, and view grades. The project is based on Ruby on Rails framework and the code is on Github: https://github.com/expertiza/expertiza. Expertiza serves wiki page, collecting information of all internal information and updates of all versions.

Problem Statement

Issue details

1) On student-end, Expertiza use grades/_reviews.html.erb partial to display reviewers, scores and review details; on instructor-end, it uses response controller and model to generate reviews page (the tables and charts are generated by grades/_team_statistics.html.erb (display reviewers and scores) in Statistics tab). We need to use the same kinds of partials in instructor-end and student-end, either _reviews partial or tabbed_reviews partial.

2) Give Feedback link at view_my_score at student-end should not appear at folded view.

What to do

1) We need to use the same kinds of partials in instructor-end and student-end.

2) Give Feedback link at view_my_score should appear at the bottom of expanded view.

Solution

Student End

  • In student end, add render partial to tabbed reviews.

app/views/grades/_participant.html.erb

<TR id="<%= prefix %>_reviews" style="display:none; background-color: white;">
    <TD COLSPAN="10"><%= render :partial=>'grades/reviews', :locals => {:prefix => 'user', :participant => participant, :rscore => pscore[:review]} %></TD>
    <TD COLSPAN="10"><%= render :partial=>'grades/tabbed_reviews', :locals => {:prefix => 'user', :participant => participant, :rscore => pscore[:review]} %></TD>
</TR>
  • Add feed back link in student end view.

app/views/grades/_tabbed_reviews.html.erb

    <% rounds.each do |round| %>
        <h3>Round <%= round %></h3>
        <a href="#" name= <%= participant.id.to_s + '_' + round.to_s + "Link" %> onClick="toggleElement('<%= participant.id.to_s +
                 '_' + round.to_s %>','round <%= round.to_s%> reviews');return false;">show round <%= round.to_s%> reviews</a>
        <table class="table table-striped" id=<%= participant.id.to_s + '_' + round.to_s %> <%= style="display: none;" if controller.action_name != "view_my_scores"%>>
            <% rscore[:assessments].select{|response| response.round == round}.reverse.uniq{|response| response.map_id}.sort_by{|response| response.map_id}.each_with_index do |review, index| %>
                <tr><td>
                <% review_feedback = nil %>
                        <%= display_directory_tree(@participant, files, true).html_safe %>
                    <% end %>
                <% end %>
                <%= review.display_as_html(prefix, index + 1, nil, true) %>
                <!-- Generate the feedback html -->
                <% map = FeedbackResponseMap.where(reviewed_object_id: review.id, reviewer_id: participant.id).first
                    review_feedbacks = map.try :response %>
                <% if review_feedbacks && !review_feedbacks.empty? %>
                    <%= link_to "View", :controller => 'response', :action => 'view', :id => review_feedbacks.first.id %> or
                    <%= link_to "Edit", :controller => 'response', :action => 'edit', :id => review_feedbacks.first.id, :return => "feedback" %> feedback for Review <%= count %>
                <% else %>                   
                    <%= link_to "Give feedback", :controller => 'response', :action => 'new_feedback', :id => review.id %> for Review <%= count %>
                <% end %>
                </td></tr>
            <% end %>
        </table><hr>
  • Add javascript to tabbed review so it can be hidden or shown by clicking the show/hide reviews.

app/views/grades/_tabbed_reviews.html.erb

<script type="text/javascript">
  toggle_tag_prompt = function() {
    $('.tag_prompt_container').toggle();
  };
  $( document ).ready(function() {
    $('#tag_prompt_toggler').click(function () {
      if ($('#tag_prompt_toggler').text() == "hide tags")
        $('#tag_prompt_toggler').text("show tags")
      else
        $('#tag_prompt_toggler').text("hide tags")
    });
  });
</script>
  • Add statistic view to student end by using the team_review_statistics.html.erb file.

app/views/grades/_participant.html.erb

<TR id="<%= prefix %>_reviews" style="display:none; background-color: white;">
    <TD COLSPAN="10">
    <%= render :partial=>'grades/team_review_statistics', :locals => {:prefix => 'user', :participant => participant, :pscore => pscore} %>
    <%= render :partial=>'grades/tabbed_reviews', :locals => {:prefix => 'user', :participant => participant, :rscore => pscore[:review]} %>
    </TD>
</TR>

app/views/grades/_tabbed_reviews.html.erb

<% if @assignment.is_answer_tagging_allowed %>
            <span class="spn_qsttog" id="tag_prompt_toggler" title="Click to display/hide tags" onclick="toggle_tag_prompt()">hide tags</span>
        <% end %>

app/views/grades/_team_review_statistics.html.erb

<% if controller.action_name != "view_my_scores"%>
    <tr>
        <td colspan="10">
<% end %> 

<% if rscore and rscore[:assessments].length > 0 %>
    <%flag_varying_rubrics=false%>

@@ -25,6 +29,9 @@
    <%if flag_varying_rubrics==false%>
        <%= render :partial => 'grades/review_table', :locals => { :ctrl => 'review', :caction => 'view_review', :symbol => "review".to_sym, :prefix => prefix, :assignment => participant.assignment, :reviews => rscore[:assessments], :collabel => "Review", :rowlabel => "Reviewer" }%>
    <%end%>
    </td>
</tr>
<% end %>  

<% if controller.action_name != "view_my_scores"%>    
        </td>
    </tr>
<% end %> 

Instructor End

  • Create new method view2 for response_controller

app/controllers/response_controller.rb

def view2
    @response = Response.find(params[:id])
    @map = @response.map
    set_content2
    render "response/view"
  end 
......
......
    @participant = @map.reviewer
......
def set_content2(new_response = false)
    @contributor = @map.contributor
    members = TeamsUser.where(team_id: params[:team])
    @user = members.first
    @participant = AssignmentParticipant.where(user_id: @user.user_id, parent_id: params[:assignment]).first
@@ -264,7 +273,9 @@ def set_content(new_response = false)
    @questions = retrieve_questions questionnaires, @assignment.id
    # @pscore has the newest versions of response for each response map, and only one for each response map (unless it is vary rubric by round)
    @pscore = @participant.scores(@questions)
    @reviewer = @map.reviewer
    @round = params[:round]
  end  

app/views/grades/_tabbed_reviews.html.erb

                <% prefix = nil %>
......
<% if controller.action_name == "view_my_scores"%>
                    <!-- Generate the feedback html -->
                    <% map = FeedbackResponseMap.where(reviewed_object_id: review.id, reviewer_id: participant.id).first
                        review_feedbacks = map.try :response %>
                    <% if review_feedbacks && !review_feedbacks.empty? %>
                        <%= link_to "View", :controller => 'response', :action => 'view', :id => review_feedbacks.first.id %> or
                        <%= link_to "Edit", :controller => 'response', :action => 'edit', :id => review_feedbacks.first.id, :return => "feedback" %> feedback for Review <%= count %>
                    <% else %>
                        <%= link_to "Give feedback", :controller => 'response', :action => 'new_feedback', :id => review.id %> for Review <%= count %>
                    <% end %>
                </td></tr>
                <% end %>
            <% end %>
        </table><hr>
    <% end %>

app/views/grades/_view_heatgrid.html.erb

                      <th class="sorter-false"> <a target="_blank" href="../response/view2?id=<%= review.id.to_s %>&&team=<%= @team.id %>&&round=<%= vm.round.to_s %>&&assignment=<%= @assignment.id %>"  
data-toggle="tooltip" data-placement="right" title="Click to see details"><%= user_name.to_s %></a>  </th>

app/views/response/view.html.erb

<% if controller.action_name != "view2" %>
    <% file_url = nil %>
    <%= @response.display_as_html(nil, nil, file_url) %>
    <br/>
<% else %>
    <TR style="display:none; background-color: white;">
        <TD COLSPAN="10">
        <%= render :partial=>'grades/tabbed_reviews', :locals => {:prefix => 'user', :participant => @participant, :rscore => @pscore[:review], :reviewer => @reviewer, :round => @round} %>
        </TD>
    </TR>
<% end %>
  • show right round for instructor-end

app/views/grades/_tabbed_reviews.html.erb

        <% next if round.to_s != @round.to_s %>
  • Create construct_instructor2_html in order to not show review number

app/models/response.rb

if prefix == "instructor"
      self_id = self.id.to_s
      code = construct_instructor2_html identifier, self_id, count
    elsif prefix # has prefix means view_score page in instructor end
      self_id = prefix + '_' + self.id.to_s
      code = construct_instructor_html identifier, self_id, count
......
def construct_instructor2_html identifier, self_id, count
    identifier += '<table width="100%">'\
						 '<tr>'\
						 '<td align="left" width="70%"><b>Review ' + '</b>   '\
						 '<a href="#" name= "review_' + self_id + 'Link" onClick="toggleElement(' + "'review_" + self_id + "','review'" + ');return false;">hide review</a>'\
						 '</td>'\
						 '<td align="left"><b>Last Reviewed:</b>'\
						 "<span>#{(self.updated_at.nil? ? 'Not available' : self.updated_at.strftime('%A %B %d %Y, %I:%M%p'))}</span></td>"\
						 '</tr></table>'
  end

app/views/grades/_tabbed_reviews.html.erb

<% if controller.action_name != "view2"%>
            <h3>Round <%= round %></h3>
            <% if controller.action_name != "view_my_scores" %>
                <a href="#" name= <%= participant.id.to_s + '_' + round.to_s + "Link" %> onClick="toggleElement('<%= participant.id.to_s + '_' + round.to_s %>','round <%= round.to_s%> reviews');return false;">show round <%= round.to_s%> reviews</a>
            <% end %>
        <% end %>
        <% if @assignment.is_answer_tagging_allowed %>
            <span class="spn_qsttog" id="tag_prompt_toggler" title="Click to display/hide tags" onclick="toggle_tag_prompt()">hide tags</span>
@@ -37,6 +39,7 @@
                <% review_feedback = nil %>
                <% count = count + 1 %>
                <% prefix = nil %>
                <% prefix = "instructor" if controller.action_name == "view2" %>
  • Show just one review in instructor-end

app/views/grades/_tabbed_reviews.html.erb

<% rounds.each do |round| %>
        <% if controller.action_name == "view2"%>
        <% next if round.to_s != @round.to_s %>
        <% end %>
        <% if controller.action_name != "view2"%>
            <h3>Round <%= round %></h3>
            <% if controller.action_name != "view_my_scores" %>
@@ -33,8 +35,13 @@
        <% if @assignment.is_answer_tagging_allowed %>
            <span class="spn_qsttog" id="tag_prompt_toggler" title="Click to display/hide tags" onclick="toggle_tag_prompt()">hide tags</span>
        <% end %>
        <% if controller.action_name != "view2"%>
        <table class="table table-striped" id=<%= participant.id.to_s + '_' + round.to_s %> <%= style="display: none;" if controller.action_name != "view_my_scores"%>>
        <% end %>
            <% rscore[:assessments].select{|response| response.round == round}.reverse.uniq{|response| response.map_id}.sort_by{|response| response.map_id}.each_with_index do |review, index| %>
                <% if controller.action_name == "view2"%>
                <% next if review.reviewer != @reviewer || count > 0 %>
                <% end %>
                <tr><td>
                <% review_feedback = nil %>
                <% count = count + 1 %>
@@ -72,7 +79,9 @@
                </td></tr>
                <% end %>
            <% end %>
        <% if controller.action_name != "view2"%>    
        </table><hr>
        <% end %>
    <% end %>
<% else %>

Test files

  • what test done
  • how to do that

path to add

test 

Team Information

  1. Forked Issue on Github
  2. Weiran Fu (@ncsu.edu)
  3. Qingyan Wang (qwang20@ncsu.edu)
  4. Hongli Wang (hwang85@ncsu.edu)
  5. Mentor: Mohit Jain (mjain6@ncsu.edu)

References

  1. Expertiza on GitHub
  2. The live Expertiza website
  3. Expertiza project documentation wiki
  4. GitHub Project Repository Fork
  5. Demo link
  6. Rspec Documentation