@@ -33,13 +33,14 @@
     <div class="panel-group" id="phases_accordion" role="tablist">
       <!-- If template has phases-->
       <% if template_hash[:template][:phases].present? %>
+        <% i = 0 %>
         <% template_hash[:template][:phases].each do |phase_no, phase_hash| %>
           <% phase = phase_hash[:data] %>
             <div class="panel panel-default">
               <div class="heading-button" role="button" data-toggle="collapse"
                    data-parent="phases_accordion" 
                    href="#collapsePhase<%= phase.id %>"
-                   aria-expanded="false" 
+                   aria-expanded="<%= i == 0 ? 'true' : 'false' %>" 
                    aria-controls="#collapsePhase<%= phase.id %>">
                    
                 <div class="panel-heading" role="tab" id="<%= "headingPhase#{phase.id}" %>">
<div class="row">
  <div class="col-md-12">
    <% if template == current && template.customization_of.nil? %>
      <div class="template_edit" style="display: none;">
        <%= render partial: "org_admin/templates/edit_template", locals: { template: template, template_hash: template_hash } %>
      </div>
    <% end %>
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <div class="template_show">
      <%= render partial: "org_admin/templates/show_template", locals: { template: template, current: current, template_hash: template_hash }%>
    </div>
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <% if template_hash[:template][:phases].present? && template_hash[:template][:phases].length > 1 %>
      <div id="sections-accordion-controls">
        <div class="accordion-controls" data-parent="phases_accordion">
          <a href="#" data-toggle-direction="show"><%= _('expand all') %></a>
          <span>|</span>
          <a href="#" data-toggle-direction="hide"><%= _('collapse all') %></a>
        </div>
      </div>
    <% end %>
  </div>
</div>
<!-- Accordion for phases -->
<div class="row">
  <div class="col-md-12">
    <div class="panel-group" id="phases_accordion" role="tablist">
      <!-- If template has phases-->
      <% if template_hash[:template][:phases].present? %>
        <% template_hash[:template][:phases].each do |phase_no, phase_hash| %>
          <% phase = phase_hash[:data] %>
            <div class="panel panel-default">
              <div class="heading-button" role="button" data-toggle="collapse"
                   data-parent="phases_accordion" 
                   href="#collapsePhase<%= phase.id %>"
                   aria-expanded="false" 
                   aria-controls="#collapsePhase<%= phase.id %>">
                   
                <div class="panel-heading" role="tab" id="<%= "headingPhase#{phase.id}" %>">
                  <div class="panel-title pull-left">
                    <%= phase.title %>
                  </div>
                  <div class="pull-right">
                    <i class="fa fa-plus pull-right" aria-hidden="true"></i>
                  </div>
                  <div class="clearfix"></div>
                </div>
              </div>
              <div id="<%= "collapsePhase#{phase.id}" %>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="<%= "headingPhase#{phase.id}" %>">
                <div class="panel-body">
                  <%= render partial: 'org_admin/templates/show_phases_sections', locals: { phase: phase, phase_hash: phase_hash, template: template, current: current } %>
                </div>
              </div>
            </div>
        <% end %>
      <% end %>
    </div>
  </div>
</div>
We could check for first instead of adding an extra variable and its counter ``` template_hash[:template][:phases].each do |o| aria-expanded="<%= template_hash[:template][:phases].first == o ? 'true' : 'false' %>" end