How to put the average in the last table in Rails

1

I have the following question:

asked by anonymous 08.06.2018 / 07:11

2 answers

0

The result of the mean is not appearing at the end because you need the amount of <th></th> to be the same amount of <td></td> .

In your example you have 12% with% tags and only 3% with%.

You should always leave the same amount and in your case you will need as you place the notes (proof -> 1,2,3,4,5,6,7,8, end)

      <table class="table table-sm table-striped table-bordered shadow-sm">
                <thead class="thead-dark">
                <tr>
                    <th>Disciplina</th>
                    <th>Faltas Atribuidas</th>
                    <th>Prova 1</th>
                    <th>Prova 2</th>
                    <th>Prova 3</th>
                    <th>Prova 4</th>
                    <th>Prova 5</th>
                    <th>Prova 6</th>
                    <th>Prova 7</th>
                    <th>Prova 8</th>
                    <th>Prova Final</th>
                    <th>Média</th>
                </tr>
            </thead>
            <tbody>
                <% block.disciplines.distinct.each do |discipline| %>

                <tr>
                    <td><%= discipline.name %></td>
                    <td>
                        <%= number_of_absences(current_user, discipline) %>
                    </td>
                    <% discipline.evaluations.each do |evaluation| %>
                        <td><%= Evaluate.get_evaluate(current_user.id, evaluation.id).present? ? Evaluate.get_evaluate(current_user.id, evaluation.id).note : '0,0' %></td>
                    <% end %>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td><%= get_media(current_user, discipline) %></td>
                </tr>
                <% end %>
            </tbody>
        </table>
    
09.06.2018 / 14:18
0

Use the "times" to make a loop of the times you have to repeat it, being the difference between 8 and the size of the notes.

<% discipline.evaluations.each do |evaluation| %>
<td><%= Evaluate.get_evaluate(current_user.id, evaluation.id).present? ? Evaluate.get_evaluate(current_user.id, evaluation.id).note : '0,0' %></td>
<% end %>
<% (8 - discipline.evaluations.length).times do %>
  <td></td>
<% end %>

I just do not know if it looks "pretty".

    
01.07.2018 / 02:25