@RequestMapping(value = "/getListeNoteEleveByAjax", method = RequestMethod.GET)
  @ResponseBody
  public String getListeNoteEleve(Model uiModel, HttpServletRequest httpServletRequest) {

    long inscription = Long.parseLong(httpServletRequest.getParameter("inscription"));

    long evaluation = Long.parseLong(httpServletRequest.getParameter("evaluation"));

    List<Notes> listeN =
        Notes.getListeNoteEleve(
                Inscription.findInscription(inscription), Evaluation.findEvaluation(evaluation))
            .getResultList();

    return Notes.toJsonArray(listeN);
  }
  @RequestMapping(value = "/getListeNoteClasseByAjax", method = RequestMethod.GET)
  @ResponseBody
  public String getListeNoteClasse(Model uiModel, HttpServletRequest httpServletRequest) {

    long matiere = Long.parseLong(httpServletRequest.getParameter("matiere"));

    long evaluation = Long.parseLong(httpServletRequest.getParameter("evaluation"));

    List<Notes> listeN =
        Notes.getListeNoteClasse(
                Matiere.findMatiere(matiere), Evaluation.findEvaluation(evaluation))
            .getResultList();

    return Notes.toJsonArray(listeN);
  }
  @RequestMapping(value = "/deleteNoteEleveByAjax", method = RequestMethod.GET)
  @ResponseBody
  public String deleteNoteEleveByAjax(
      @RequestParam(value = "idNote") long idNote,
      @RequestParam(value = "evaluation") long evaluation,
      @RequestParam(value = "inscription") long inscription,
      Model uiModel,
      HttpServletRequest httpServletRequest) {

    Notes.findNotes(idNote).remove();

    List<Notes> listeN =
        Notes.getListeNoteEleve(
                Inscription.findInscription(inscription), Evaluation.findEvaluation(evaluation))
            .getResultList();

    return Notes.toJsonArray(listeN);
  }
  @RequestMapping(value = "/saveNoteClasseByAjax", method = RequestMethod.GET)
  @ResponseBody
  public String saveNoteClasseByAjax(
      @RequestParam(value = "matiere") long matiere,
      @RequestParam(value = "evaluation") long evaluation,
      @RequestParam(value = "inscription") long inscription,
      @RequestParam(value = "noteEtudiant") long value,
      Model uiModel,
      HttpServletRequest httpServletRequest) {

    Notes note;

    Matiere mat = Matiere.findMatiere(matiere);

    Evaluation ev = Evaluation.findEvaluation(evaluation);

    Inscription inscript = Inscription.findInscription(inscription);

    Eleve eleve = inscript.getEleve();

    note = Notes.findNote(mat, ev, inscript);

    if (value > 20) {

      return null;
    }

    if (note == null) {

      note = new Notes();

      note.setCoefficient(mat.getCoefficient());

      note.setMatiere(mat);

      note.setDateSaisie(new Date());

      note.setEleve(eleve);

      note.setInscripionEleve(inscript);

      note.setEvaluation(ev);

      note.setPourcentage(ev.getPourcentage());

      note.setValeur(value);

      note.setEtablissement(ev.getEtablissement());

      note.setAgentSaisie(SecurityUtil.getUserName());

      note.persist();

    } else {

      note.setCoefficient(mat.getCoefficient());

      note.setMatiere(mat);

      note.setEleve(eleve);

      note.setInscripionEleve(inscript);

      note.setEvaluation(ev);

      note.setPourcentage(ev.getPourcentage());

      note.setValeur(value);

      note.setEtablissement(ev.getEtablissement());

      note.setDateUpdate(new Date());

      note.setAgentUpdate(SecurityUtil.getUserName());

      note.merge();
    }

    List<Notes> listeN =
        Notes.getListeNoteClasse(
                Matiere.findMatiere(matiere), Evaluation.findEvaluation(evaluation))
            .getResultList();

    System.out.println("Taille - : " + listeN.size());

    return Notes.toJsonArray(listeN);
  }