templates/evaluation/new.html.twig line 1

Open in your IDE?
  1. {% extends 'layout/backEndLayout.html.twig' %}
  2. {% block content %}
  3.             {% form_theme form 'bootstrap_4_layout.html.twig' %}
  4.               <div class="col-12 jumbotron" >
  5.                
  6.                      <div class="row mt-4  mx-auto box-shadow">
  7.                         <div class="card-header">
  8.                                         <h3 class="my-0 text-center text-justify text-uppercase">  Nouvelle fiche d evaluation</h3>
  9.                         </div>
  10.                         <div class="mt-4 col-md-12 col-sm-12 table-responsive">
  11.                             <div class="row">
  12.                                 <div class="col-2   table-responsive"></div>
  13.                                 <div class="col-8  table-responsive">
  14.                                     {{ form_start(form, {action: path('admin_evaluations_create'),'attr': {'id': 'formEvaluation', 'class':'evaluation'} }) }}
  15.                                     <p>
  16.                                         {{ form_widget(form.sequence ,{'attr':{'class':'ChoiceSequence'} } ) }}
  17.                                     </p>
  18.                                     <p>
  19.                                         {{ form_widget(form.classRoom,{'attr':{'class':'ChoiceClassRoom', 'name' :'ChoiceClassRoom', 'id':'ChoiceClassRoom'} }) }}
  20.                                     </p>
  21.                                     <p>
  22.                                         {{ form_widget(form.competence,{'attr':{'class':'form form-control'} }) }}
  23.                                     </p>
  24.                                 </div>
  25.                                 <div class="col-2  table-responsive"></div>
  26.                             </div>
  27.                         </div>
  28.                         <div id="ficheBodyStudents" class=" col-md-12  row">
  29.                             {% include "evaluation/liststudents.html.twig" %}
  30.                         </div>
  31.                     </div>
  32.                     <div class="row mt-2 mx-auto">
  33.                             <div class=" col-3">
  34.                             </div>
  35.                             <div class=" col-3 mx-auto btn-group d-inline-flex p-2 bd-highlight">
  36.                                 <button class="btn btn-danger" type="submit">
  37.                                     <b>
  38.                                         <i class="fa fa-balance-scale"></i>submit</b>
  39.                                 </button>
  40.                             </div>
  41.                             <div class="  col-3 mx-auto btn-group d-inline-flex p-2 bd-highligh">
  42.                                 <a class="btn btn-info" href="{{ path('admin_evaluations') }}">
  43.                                     <i class="fa fa-list"></i>
  44.                                     {{ 'Back to the list'|trans({}, 'admin') }}
  45.                                 </a>
  46.                                 
  47.                             </div>
  48.                             <div class=" col-3">
  49.                             </div>
  50.                     </div>
  51.                 
  52.             {{ form_end(form) }}
  53.         </div>
  54.                 
  55. {% endblock %}
  56. {% block footer %}
  57.     {{ parent() }}
  58. {% endblock %}
  59. {% block javascripts %}
  60.     {{parent()}}
  61.     <script type="text/javascript">
  62.         var classRoom = document.getElementById("evaluation_classRoom"),
  63.             competence = document.getElementById("evaluation_competence"),
  64.             idclassroom,
  65.             idcourse,
  66.             idsequence,
  67.             formEval = document.getElementById("formEvaluation");
  68.             classRoom.setAttribute('name', 'ChoiceClassRoom');
  69.             
  70.             
  71.             idsequence = $("select.ChoiceSequence option:selected").val();
  72.             
  73.             $(".ChoiceClassRoom").change(function () {
  74.                 idclassroom = $("select.ChoiceClassRoom option:selected").val();
  75.                 
  76.                 $.ajax({
  77.                     type: "POST",
  78.                     url: "{{ path('admin_classroom_students') }}",
  79.                     data: {
  80.                     idclassroom: idclassroom,
  81.                     idsequence: idsequence
  82.                     },
  83.                     datatype: "json",
  84.                     success: function (data) {
  85.                         $("#ficheBodyStudents").html(data).show();
  86.                     }
  87.                 });
  88.             });
  89.     var marksJson = [],
  90.     postData;
  91.         $(function () {
  92.             $(document).on('submit', 'form', function (e) { // il est impératif de commencer avec cette méthode qui va empêcher le navigateur d'envoyer le formulaire lui-même
  93.             e.preventDefault();
  94.             
  95.             $("input[max=20]").each(function (index) {
  96.                 marksJson.push({"matricule": $(this).attr('id'), "note": $(this).val(), "appreciation": $(this).parent().next().children().val(), "weight": $(this).parent().next().next().children().val()});
  97.             });
  98.             idcourse = $("select.ChoiceCourse option:selected").val();
  99.             postData = {
  100.                 "marks": JSON.stringify(marksJson),
  101.                 "idroom": idclassroom,
  102.                 "idcourse": idcourse,
  103.                 "idsequence": idsequence,
  104.                 "competence": competence.value
  105.             };
  106.             
  107.         $.ajax({
  108.             type: "POST",
  109.             url: "{{ path('admin_evaluations_create') }}",
  110.             data: postData,
  111.             datatype: "json",
  112.             success: function (data) {
  113.                 alert("Enregistre avec succes.");
  114.             },
  115.             error: function (e) {
  116.                 console.log(e.message);
  117.                 alert("Echec.");
  118.             }
  119.             });
  120.         });
  121.         });
  122.     </script>
  123. {% endblock javascripts %}