Guest User

Untitled

a guest
Jul 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 7.40 KB | None | 0 0
  1. <% estudiantes = (@seccion || @materia.clase).estudiante_clases.includes(:periodo_lectivo).order_apellido %>
  2.  
  3. <% titulo('Hoja de calificaciones') %>
  4.  
  5. <script type="text/javascript">
  6.   $(function() {
  7.     $t_cont = $("#t_cont");
  8.     $t_izq = $("#t_izq");
  9.     $t_der = $("#t_der");
  10.     $t_calificaciones = $("#calificaciones");
  11.     $t_cabecera = $("#t_cabecera");
  12.     $t_cabecera1 = $("#t_cabecera1")
  13.     ancho_izquierda = $t_izq.width();
  14.  
  15.     /* ocultar Loading y mostrar tabla */
  16.     $("#t_loading").hide();
  17.     $t_cont.show();
  18.  
  19.     /* slide horizontal */
  20.     hslider = $("#hslider").slider({
  21.         slide: function(event,ui){
  22.           $t_calificaciones.css('marginLeft',(ui.value*-1));
  23.           $t_cabecera.css('marginLeft',(ui.value*-1));
  24.         }
  25.     });
  26.     reset_slider(hslider);
  27.  
  28.     /* resize wide*/
  29.     $("#clayout").click(function(){ reset_slider(hslider); });
  30.    
  31.     function reset_slider(rslider){
  32.         $t_calificaciones.css('marginLeft',ancho_izquierda);
  33.         $t_cabecera.css('marginLeft',ancho_izquierda);
  34.         rslider.slider("option","value",ancho_izquierda*-1);
  35.         rslider.slider("option","min",ancho_izquierda*-1);
  36.         rslider.slider("option","max", $t_der.width()-($t_cont.width()+ancho_izquierda) );
  37.      }
  38.  
  39.      /* fix header */
  40.      pos_inicial = $t_cabecera.offset().top - 25;
  41.      $(window).scroll(function(){
  42.        if (window.pageYOffset > pos_inicial) {
  43.          $t_cabecera.css('top',window.pageYOffset-pos_inicial);
  44.          $t_cabecera1.css('top',window.pageYOffset-pos_inicial);
  45.        }
  46.        else {
  47.          $t_cabecera.css('top',0);
  48.          $t_cabecera1.css('top',0);
  49.        }
  50.      });
  51.  
  52.   });
  53. </script>
  54.  
  55. <div class="detalle bloque">
  56.   <p>
  57.     <b>Materia:</b>
  58.     <%= @materia.nombre %>
  59.   </p>
  60.   <p>
  61.     <b>Clase:</b>
  62.     <%= (@seccion || @materia.clase).nombre_completo %>
  63.   </p>
  64. </div>
  65.  
  66. <div id="t_loading"> Generando tabla </div>
  67.  
  68. <div class="t_cont" id="t_cont">
  69.   <div class="t_izq" id="t_izq">
  70.     <table id="t_cabecera1" class="t_cabecera">
  71.       <thead>
  72.         <tr>
  73.           <th class="tnum">#</th>
  74.           <th class="tmat">Materia</th>
  75.         </tr>
  76.         <tr>
  77.           <th>&nbsp;</th>
  78.           <th>&nbsp;</th>
  79.         </tr>
  80.       </thead>
  81.     </table>
  82.  
  83.  
  84.     <table>
  85.       <thead>
  86.         <tr class="t_virtual">
  87.           <th>&nbsp;</th>
  88.           <th>&nbsp;</th>
  89.         </tr>
  90.       </thead>
  91.  
  92.       <% i = 0; %>
  93.       <tbody>
  94.           <% estudiantes.each do |e| %>
  95.             <tr>
  96.               <td class="tnum"><%= i += 1 if e.retirado.nil? %></td>
  97.               <td class="tmat"><%= e.estudiante.apellido_corto %></td>
  98.             </tr>
  99.           <% end %>
  100.       </tbody>
  101.     </table>
  102.   </div>
  103.  
  104.   <div class="t_der" id="t_der">
  105.     <table id="t_cabecera" class="t_cabecera">
  106.       <thead>
  107.         <tr>
  108.           <% numcols = 0 %>
  109.           <% @hoja[:head].each_with_index do |h, p| %>
  110.             <% next if h.nil? %>
  111.             <th class="periodo" colspan="<%= h[:cols] %>">
  112.               <%= "#{Clase.nombre_grado(p + 1)} #{@materia.periodo_lectivo.last_tipo_nota.try(:nombre) || 'Período'}" %>
  113.             </th>
  114.             <% numcols += h[:cols] %>
  115.           <% end %>
  116.           <th rowspan="2" class="tooltip tot" data-tooltip="Promedio estudiante">PR</th>
  117.         </tr>
  118.         <tr class="titulo_acumulado">
  119.           <% @hoja[:head].each_with_index do |h, p| %>
  120.             <% next if h.nil? %>
  121.             <% h[:eval].times do |i| %>
  122.               <th class="tooltip eval" data-tooltip="<%= Clase.nombre_grado(i + 1) %> Acumulado"><%= i + 1 %>A</th>
  123.             <% end %>
  124.             <% if h[:acum] > 0 %>
  125.               <th class="tooltip acum <%= 'last' if h[:eval] + 1 == h[:cols] %>"
  126.                   data-tooltip="Total Acumulado">TA</th>
  127.             <% end %>
  128.             <% if h[:exam] > 0 %>
  129.               <th class="tooltip exam <%= 'last' if h[:eval] + h[:acum] + 1 == h[:cols] %>"
  130.                   data-tooltip="Examen">EX</th>
  131.             <% end %>
  132.             <% c = @materia.periodo_lectivo.last_tipo_nota; h[:cons].times do |i| %>
  133.               <th class="tooltip cons <%= 'last' if h[:eval] + h[:acum] + h[:exam] + i + 1 == h[:cols] %>"
  134.                   data-tooltip="<%= "#{Clase.nombre_grado(c.try(:numero_consolidado, p + 1))} " \
  135.                   "#{c.try(:nombre) || 'Período'}" %>">
  136.                 <%= "#{c.try(:numero_consolidado, p + 1)}#{c.try(:nombre_corto) || 'P'}" %>
  137.               </th>
  138.               <% c = c.try(:consolidado) %>
  139.             <% end %>
  140.           <% end %>
  141.         </tr>
  142.       </thead>
  143.     </table>
  144.  
  145.     <table class="calificaciones" id="calificaciones">
  146.       <thead>
  147.         <tr class="t_virtual">
  148.           <% @hoja[:head].each_with_index do |h, p| %>
  149.             <% next if h.nil? %>
  150.             <% h[:eval].times do |i| %>
  151.               <th class="eval">&nbsp;</th>
  152.             <% end %>
  153.             <% if h[:acum] > 0 %>
  154.               <th class="acum">&nbsp;</th>
  155.             <% end %>
  156.             <% if h[:exam] > 0 %>
  157.               <th class="exam">&nbsp;</th>
  158.             <% end %>
  159.             <% c = @materia.periodo_lectivo.last_tipo_nota; h[:cons].times do |i| %>
  160.               <th class="cons">
  161.                 &nbsp;
  162.               </th>
  163.               <% c = c.try(:consolidado) %>
  164.             <% end %>
  165.           <% end %>
  166.         </tr>
  167.       </thead>
  168.  
  169.       <% i = 0; n = 0; suma = 0.0 %>
  170.       <% tbody = capture do %>
  171.  
  172.         <tbody>
  173.           <% estudiantes.each do |e| %>
  174.             <% notas = @hoja[e.id] || [] %>
  175.             <tr>
  176.               <% @hoja[:head].each_with_index do |h, p| %>
  177.                 <% notas[p] = { eval: [], cons: [] } if notas[p].nil? %>
  178.                 <% h[:eval].times do |i| %>
  179.                   <%= calificacion_cell('eval', notas[p][:eval][i], @nota_min) %>
  180.                 <% end %>
  181.                 <% if h[:acum] > 0 %>
  182.                   <%= calificacion_cell('acum' + (h[:eval] + 1 == h[:cols] ? ' last' : ''),
  183.                       notas[p][:acum], @nota_min) %>
  184.                 <% end %>
  185.                 <% if h[:exam] > 0 %>
  186.                   <%= calificacion_cell('exam' + (h[:eval] + h[:acum] + 1 == h[:cols] ? ' last' : ''),
  187.                       notas[p][:exam], @nota_min) %>
  188.                 <% end %>
  189.                 <% h[:cons].times do |i| %>
  190.                   <%= calificacion_cell('cons' + (h[:eval] + h[:acum] + h[:exam] + i + 1 == h[:cols] ? ' last' : ''),
  191.                       notas[p][:cons][i], @nota_min) %>
  192.                 <% end %>
  193.                 <%  %>
  194.               <% end %>
  195.               <td class="tot"><%= calificacion(promedio = e.promedio_materia(@materia.id), @nota_min) %></td>
  196.               <% if e.retirado.nil? && !promedio.nil? %>
  197.                 <% suma += promedio; n += 1 %>
  198.               <% end %>
  199.             </tr>
  200.           <% end %>
  201.         </tbody>
  202.       <% end %>
  203.  
  204.       <tfoot>
  205.         <tr>
  206.           <td></td>
  207.           <td>Promedio total</td>
  208.           <% if numcols > 0 %>
  209.             <td colspan="<%= numcols %>"></td>
  210.           <% end %>
  211.           <td><%= calificacion(n > 0 ? suma / n : nil, @nota_min) %></td>
  212.         </tr>
  213.       </tfoot>
  214.       <%= tbody %>
  215.     </table>
  216.   </div>
  217. </div>
  218.  
  219. <div class="fix_footer">
  220.   <div id="hslider"></div>
  221. </div>
  222.  
  223. <% content_for :botonera do %>
  224.   <%= link_to 'Volver', polymorphic_path([@clase || @seccion, @materia], anchor: 'estudiantes'), class: 'button' %>
  225. <% end %>
Add Comment
Please, Sign In to add comment