No Description

addNotas.html 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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'>A&ntilde;ade su sentencia</h1>
  10. <div class ='row'>
  11. <div class = 'col table-responsive'>
  12. <form action = "/Maestro/{{MaestroId}}/{{ofertaId}}/addNotas" method = 'POST'>
  13. <input name ="Maestro" value ='{{MaestroId}}' type ='hidden'>
  14. <input type ='hidden' value ='{{ofertaId}}' name = 'oferta'>
  15. <table class="table table-hover">
  16. <thead>
  17. <tr class = 'eval'>
  18. <th>Nombre</th>
  19. {% set evaluacion = namespace(value=0) %}
  20. {% for eval in evaluaciones %}
  21. <th>{{eval.tipo}}</th>
  22. <input type ='hidden' name = 'cantidadEval[{{evaluacion.value}}]' value = '{{eval.id}}'>
  23. {% set evaluacion.value = evaluacion.value +1 %}
  24. {% endfor %}
  25. </thead>
  26. <tbody>
  27. {% set column = namespace(value=0) %}
  28. {% set row = 0 %}
  29. {% set counterRow = namespace(value =0) %}
  30. {% set tabindex = namespace(value =0) %}
  31. {% for estudiante in estudiantes %}
  32. <tr class = 'student' data-value='{{estudiante.id}}'>
  33. <td class = "w-25">
  34. <input type='hidden' name ='id_usuario[{{ column.value }}]' value ='{{estudiante.id}}'>
  35. {{estudiante.apellidos}} {{estudiante.nombres}}
  36. </td>
  37. {% set row = 0 %}
  38. {% for row in range (evaluacion.value) %}
  39. <td><input type="text" class="form-control" id='{{evalIds[row]}}' name="evaluacion[{{column.value}}][{{row}}]" onchange ='submitIndividual("evaluacion[{{column.value}}][{{row}}]","{{estudiante.id}}", "{{evalIds[row]}}")' tabindex="{{tabindex.value}}" ></td>
  40. {% set tabindex.value = tabindex.value + 1 %}
  41. {% set counterRow.value = row +1 %}
  42. {% endfor %}
  43. </tr>
  44. {% set column.value = column.value + 1 %}
  45. {% endfor %}
  46. </tbody>
  47. </table>
  48. <input type='hidden' name ='columnPost' value = '{{column.value}}'>
  49. <input type ='hidden' name = 'row' value ='{{counterRow.value}}'>
  50. <button type ='submit' class ='btn btn-success'>Someter</button>
  51. </form>
  52. </div>
  53. </div>
  54. <script>
  55. var notasCompletas = jQuery.parseJSON('{{ notasCompletas | tojson | safe}}');
  56. var maestro = document.getElementsByName('Maestro')
  57. var oferta = document.getElementsByName('oferta')
  58. maestro = $(maestro).val();
  59. oferta = $(oferta).val();
  60. function submitIndividual(evalNombre, stuId, evalId){
  61. var valor = document.getElementsByName(evalNombre);
  62. valor = $(valor).val();
  63. var xhr = new XMLHttpRequest();
  64. xhr.open("POST", '/Maestro/'+maestro+'/'+oferta+'/addNotas', true);
  65. xhr.setRequestHeader('Content-Type', 'application/json');
  66. xhr.send(JSON.stringify(
  67. {
  68. 'StudentId': stuId,
  69. 'Nota': valor,
  70. 'evalId':evalId }
  71. ));
  72. //$.post('Maestro/'+maestro+'/'+oferta+'/addNotas', pos);
  73. }
  74. $(document).ready(function(){
  75. $('tr.student').each(function(){
  76. var index =0;
  77. var counter =0;
  78. var studentId = $(this).data('value');
  79. var tr = $(this);
  80. tr.children('td').each(function (){
  81. var td = $(this);
  82. td.children('input.form-control').each(function(){
  83. if ($(this).attr('id')==notasCompletas[studentId].evaluacion[counter]){
  84. $(this).val(notasCompletas[studentId].valorSaco[counter])
  85. counter +=1;
  86. }
  87. index+=1
  88. })
  89. })
  90. })
  91. })
  92. </script>
  93. {% endblock %}