You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
4.2 KiB
116 lines
4.2 KiB
<?php
|
|
|
|
|
|
require_once('../BDD/SqliteDb.php');
|
|
$db = new SqliteDb('o');
|
|
|
|
$numQuestionSuiv = $_GET['numQuestion']+1;
|
|
|
|
|
|
|
|
|
|
$sqliteQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion=? AND numTp = ?');
|
|
$sqliteQuery->bindParam(1, $_GET['numQuestion']);
|
|
$sqliteQuery->bindParam(2, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
$typeRow = $result->fetchArray();
|
|
|
|
$sqliteQuery = $db->prepare('DELETE FROM Type WHERE numquestion= ? AND numTp=? ');
|
|
$sqliteQuery->bindParam(1, $_GET['numQuestion']);
|
|
$sqliteQuery->bindParam(2, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
|
|
|
|
if($typeRow['type'] == 'query'){
|
|
$sqliteQuery = $db->prepare('SELECT count(*) FROM (SELECT numQuestion FROM Correct WHERE numTp=? UNION SELECT numQuestion FROM FunctionCorrect WHERE numTp=?)');
|
|
$sqliteQuery->bindParam(1, $_GET['numTp']);
|
|
$sqliteQuery->bindParam(2, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
$nbQuestionsRow = $result->fetchArray();
|
|
|
|
$sqliteQuery = $db->prepare('DELETE FROM Correct WHERE numquestion= ? AND numTp=? ');
|
|
$sqliteQuery->bindParam(1, $_GET['numQuestion']);
|
|
$sqliteQuery->bindParam(2, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
|
|
|
|
for( $iSuiv = $numQuestionSuiv, $j=$_GET['numQuestion'] ; $iSuiv <= $nbQuestionsRow['count(*)'] ; $iSuiv++ , $j++ ){
|
|
|
|
$typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?');
|
|
$typeQuery->bindParam(1, $iSuiv);
|
|
$typeQuery->bindParam(2, $_GET['numTp']);
|
|
$resultType = $typeQuery->execute();
|
|
$typeRow = $resultType->fetchArray();
|
|
|
|
if($typeRow['type'] == 'query'){
|
|
$table = 'Correct';
|
|
$type = 'query';
|
|
}
|
|
else{
|
|
$table = 'FunctionCorrect';
|
|
$type = 'functionCorrect';
|
|
}
|
|
|
|
$sqliteQuery = $db->prepare('UPDATE '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=? ');
|
|
$sqliteQuery->bindParam(1, $j);
|
|
$sqliteQuery->bindParam(2, $iSuiv);
|
|
$sqliteQuery->bindParam(3, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
|
|
$sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=? ');
|
|
$sqliteQuery->bindParam(1, $j);
|
|
$sqliteQuery->bindParam(2, $iSuiv);
|
|
$sqliteQuery->bindParam(3, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
}
|
|
}
|
|
else {
|
|
|
|
$sqliteQuery = $db->prepare('SELECT count(*) FROM (SELECT numQuestion FROM Correct WHERE numTp=? UNION SELECT numQuestion FROM FunctionCorrect WHERE numTp=?)');
|
|
$sqliteQuery->bindParam(1, $_GET['numTp']);
|
|
$sqliteQuery->bindParam(2, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
$nbQuestionsRow = $result->fetchArray();
|
|
|
|
$sqliteQueryF = $db->prepare('DELETE FROM FunctionCorrect WHERE numquestion= ? AND numTp=?');
|
|
$sqliteQueryF->bindParam(1, $_GET['numQuestion']);
|
|
$sqliteQueryF->bindParam(2, $_GET['numTp']);
|
|
$result = $sqliteQueryF->execute();
|
|
|
|
|
|
|
|
for( $iSuiv = $numQuestionSuiv, $j=$_GET['numQuestion'] ; $iSuiv <= $nbQuestionsRow['count(*)'] ; $iSuiv++ , $j++ ){
|
|
|
|
$typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?');
|
|
$typeQuery->bindParam(1, $numQuestionSuiv);
|
|
$typeQuery->bindParam(2, $_GET['numTp']);
|
|
$resultType = $typeQuery->execute();
|
|
$typeRow = $resultType->fetchArray();
|
|
|
|
|
|
if($typeRow['type'] == 'query'){
|
|
$table = 'Correct';
|
|
$type = 'query';
|
|
}
|
|
else{
|
|
$table = 'FunctionCorrect';
|
|
$type = 'functionCorrect';
|
|
}
|
|
|
|
$sqliteQuery = $db->prepare('UPDATE '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=? ');
|
|
$sqliteQuery->bindParam(1, $j);
|
|
$sqliteQuery->bindParam(2, $iSuiv);
|
|
$sqliteQuery->bindParam(3, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
|
|
$sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=? ');
|
|
$sqliteQuery->bindParam(1, $j);
|
|
$sqliteQuery->bindParam(2, $iSuiv);
|
|
$sqliteQuery->bindParam(3, $_GET['numTp']);
|
|
$result = $sqliteQuery->execute();
|
|
}
|
|
}
|
|
|
|
|
|
|