ece517-p3/expertiza

View on GitHub
app/views/grades/_reviews.html.erb

Summary

Maintainability
Test Coverage
<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>
<% if rscore and rscore[:assessments].length > 0 %>
    <BR/>
    <%flag_varying_rubrics=false%>

    <%if @questions.has_key?("review1".to_sym)%>
        <b> Round 1:</b>
        <%flag_varying_rubrics=true%>
        <%= render :partial => 'grades/review_table', :locals => { :ctrl => 'review', :caction => 'view_review', :symbol => "review1".to_sym, :prefix => prefix, :assignment => participant.assignment, :reviews => rscore[:assessments], :collabel => "Review", :rowlabel => "Reviewer", :round=>1 }%>
    <%end%>

    <%if @questions.has_key?("review2".to_sym)%>
        <b> Round 2:</b>
        <%flag_varying_rubrics=true%>
        <%= render :partial => 'grades/review_table', :locals => { :ctrl => 'review', :caction => 'view_review', :symbol => "review2".to_sym, :prefix => prefix, :assignment => participant.assignment, :reviews => rscore[:assessments], :collabel => "Review", :rowlabel => "Reviewer" , :round=>2 }%>
    <%end%>

    <%if @questions.has_key?("review3".to_sym)%>
        <b> Round 3:</b>
        <%flag_varying_rubrics=true%>
        <%= render :partial => 'grades/review_table', :locals => { :ctrl => 'review', :caction => 'view_review', :symbol => "review3".to_sym, :prefix => prefix, :assignment => participant.assignment, :reviews => rscore[:assessments], :collabel => "Review", :rowlabel => "Reviewer" , :round=>3 }%>
    <%end%>
    
    <%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%>
    <BR/>
    <HR/>
    <% count = 0 %>
    <!--Zhewei: If this assignment supports varying rubrics by round, Expertiza will display all-round reviews. -->
    <!--And if one reviewer did not do first-round review and did second round directly, Expertiza will display only second round.-->
    <!--If another reviewer only finished first-round review and did not do second round, Expertiza will display only first round.-->
    <!--If this assignment does not support varying rubrics by round, Expertiza will display last round review.--> 
    <% rounds = Array.new %>
    <% rscore[:assessments].uniq{|response| response.round }.each do |response| %>
        <% rounds << response.round %>
    <% end %>

    <% rounds.each do |round| %>
        <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 %>
        <% 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 %>
        <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 %>
                <% count = count + 1 %>
                <% prefix = nil if controller.action_name == "view_my_scores" %>
                <!--change code in order to compat to multi-round review-->
                <% if @assignment.varying_rubrics_by_round? and !review.round.nil? %>
                    <% review_symbol = 'review' + review.round.to_s %>
                <% else %>
                    <% review_symbol = 'review' %>
                <% end %>
                <% @questions[review_symbol.to_sym].each do |question| %>
                    <% if question.instance_of? UploadFile %>
                        <!-- Display FileUpload question type -->
                        <% current_folder = DisplayOption.new %>
                        <% current_folder.name = "" %>
                        <% files = @participant.files(@participant.review_file_path(review.response_map.id).to_s + current_folder.name) %>
                        <%= display_directory_tree(@participant, files, true).html_safe %>
                    <% end %>
                <% end %>
                
                <%= review.display_as_html(prefix, index + 1, nil, true, @current_user) %><br/>
                
                <% 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>
    <% end %>
<% else %>
    <i>No reviews have been completed for this user's submissions.</i>
<% end %>