Nav apraksta

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. {% extends 'ElVerdaderoHeader.html' %}
  2. {% block head %}
  3. {{MaestroId}}
  4. {% endblock %}
  5. {% block css %}
  6. <link rel='stylesheet' href ='../../../../static/css/estilo.css'>
  7. {% endblock %}
  8. {% block body %}
  9. <h1 class = 'text-center text-white bg-dark'>Asistencia</h1>
  10. <div class ='row'>
  11. <div class="col">
  12. <form action="/dashboard/{{MaestroId}}/{{ofertaId}}/addAsistencia" method="POST"></form>
  13. <label for="Fecha">Fecha (Deje en blanco si la asistencia es de hoy):</label>
  14. <input type="date" id="Fecha" name="Fecha" value = '{{fecha}}' onchange ='changeFecha(event, {{MaestroId}} , {{ofertaId}});'>
  15. <table class='table table-bordered table-hover'>
  16. <thead>
  17. <tr>
  18. <th class ='w-50'>Estudiantes</th>
  19. <th>Presente</th>
  20. <th>Tarde</th>
  21. <th>Ausente</th>
  22. <th>Excusado</th>
  23. </tr>
  24. </thead>
  25. <tbody>
  26. {% set count = namespace(value=0) %}
  27. {% for estud in estudiantes %}
  28. <tr data-value = {{estud.matricula}}>
  29. <td>{{estud.apellidos}} {{estud.nombres}}</td>
  30. <td> <div class = "form-check form-check-inline"><input class="form-check-input" type="radio" name="Asistencia[{{count.value}}]" onchange = 'changeAsistencia("Asistencia[{{count.value}}]", "{{estud.matricula}}", 0, {{MaestroId}}, {{ofertaId}})' id="0"></div> </td>
  31. <td> <div class = "form-check form-check-inline"><input class="form-check-input" type="radio" name="Asistencia[{{count.value}}]" onchange = 'changeAsistencia("Asistencia[{{count.value}}]", "{{estud.matricula}}", 1, {{MaestroId}}, {{ofertaId}})' id="1"></div> </td>
  32. <td> <div class = "form-check form-check-inline"><input class="form-check-input" type="radio" name="Asistencia[{{count.value}}]" onchange = 'changeAsistencia("Asistencia[{{count.value}}]", "{{estud.matricula}}", 2, {{MaestroId}}, {{ofertaId}})' id="2"></div> </td>
  33. <td> <div class = "form-check form-check-inline"><input class="form-check-input" type="radio" name="Asistencia[{{count.value}}]" onchange = 'changeAsistencia("Asistencia[{{count.value}}]", "{{estud.matricula}}", 3, {{MaestroId}}, {{ofertaId}})' id="3"></div> </td>
  34. </tr>
  35. {% set count.value = count.value + 1 %}
  36. {% endfor %}
  37. </tbody>
  38. </table>
  39. <button type='submit' class='btn btn-success'>Someter</button>
  40. </div>
  41. </form>
  42. </div>
  43. <script>
  44. function changeFecha(e, maestro, oferta){
  45. location.replace('/Maestro/'+maestro+'/'+oferta+'/addAsistencia/'+e.target.value);
  46. }
  47. var asistenciaCompleta = jQuery.parseJSON('{{dictList | tojson | safe }}');
  48. $(document).ready(function(){
  49. $('tr').each(function(){
  50. var student = $(this).data('value');
  51. student = parseInt(student);
  52. var tr = $(this);
  53. tr.children('td').each(function(){
  54. var td = $(this);
  55. td.children('div').each(function(){
  56. var div = $(this)
  57. div.children('input').each(function(){
  58. if(typeof(asistenciaCompleta[student])!='undefined' && $(this).attr('id') == asistenciaCompleta[student].Asistencia){
  59. $(this).prop('checked', true);
  60. }
  61. })
  62. }
  63. )
  64. })
  65. })
  66. })
  67. function changeAsistencia(nameInput, matricula, valor, maestro, oferta){
  68. var fecha = document.getElementById('Fecha');
  69. fecha = $(fecha).val()
  70. matricula = parseInt(matricula);
  71. var xhr = new XMLHttpRequest();
  72. xhr.open("POST",'/Maestro/'+maestro+'/'+oferta+'/addAsistencia/'+fecha, true);
  73. xhr.setRequestHeader('Content-Type', 'application/json');
  74. xhr.send(JSON.stringify(
  75. {
  76. 'Matricula': matricula,
  77. 'Asistencia':valor,
  78. 'Fecha': fecha
  79. }
  80. ));
  81. }
  82. </script>
  83. {% endblock %}