<?php
session_start();
require_once('../../BDD/SqliteDb.php');

$db = new SqliteDb('save');



$numTp = $_GET['numTp'];
$numQuestion = $_GET['numQuestion']; 
$reponse = $_GET['textbox']; 


//$user = "mehdi";
$user = $_SERVER['REMOTE_USER'];

    
    //Sauvegarde des REPONSES//    
    $query = $db->prepare('DELETE FROM TpSauvegarde WHERE numTp= ? AND numQuestion = ? AND idEtudiant=?');        
    $query->bindParam(1,$numTp);
    $query->bindParam(2,$numQuestion);
    $query->bindParam(3, $user);
    $result = $query->execute();
    
    $query = $db->prepare('INSERT OR REPLACE INTO TpSauvegarde  VALUES (?,?,?,?)');        
    $query->bindParam(1, $user);
    $query->bindParam(2,$numTp);
    $query->bindParam(3,$numQuestion);
    $query->bindParam(4,$reponse);
    $result = $query->execute();
    
    //$db->ecrireFichierNotes($numTp,'save');

         echo 'testsave';
                      


