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.             $(".ChoiceSequence").change(function () {
  72.                 idsequence = $("select.ChoiceSequence option:selected").val();
  73.             });
  74.             
  75.             $(".ChoiceClassRoom").change(function () {
  76.                 idclassroom = $("select.ChoiceClassRoom option:selected").val();
  77.                 $.ajax({
  78.                     type: "POST",
  79.                     url: "{{ path('admin_classroom_students') }}",
  80.                     data: {
  81.                     idclassroom: idclassroom,
  82.                     idsequence: idsequence
  83.                     },
  84.                     datatype: "json",
  85.                     success: function (data) {
  86.                         $("#ficheBodyStudents").html(data).show();
  87.                     }
  88.                 });
  89.             });
  90.     var marksJson = [],
  91.     postData;
  92.         $(function () {
  93.             $(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
  94.             e.preventDefault();
  95.             
  96.             $("input[max=20]").each(function (index) {
  97.                 marksJson.push({"matricule": $(this).attr('id'), "note": $(this).val(), "appreciation": $(this).parent().next().children().val(), "weight": $(this).parent().next().next().children().val()});
  98.             });
  99.             idcourse = $("select.ChoiceCourse option:selected").val();
  100.             postData = {
  101.                 "marks": JSON.stringify(marksJson),
  102.                 "idroom": idclassroom,
  103.                 "idcourse": idcourse,
  104.                 "idsequence": idsequence,
  105.                 "competence": competence.value
  106.             };
  107.             
  108.         $.ajax({
  109.             type: "POST",
  110.             url: "{{ path('admin_evaluations_create') }}",
  111.             data: postData,
  112.             datatype: "json",
  113.             success: function (data) {
  114.                 alert("Enregistre avec succes.");
  115.             },
  116.             error: function (e) {
  117.                 console.log(e.message);
  118.                 alert("Echec.");
  119.             }
  120.             });
  121.         });
  122.         });
  123.     </script>
  124. {% endblock javascripts %}