php
Anthony RICHARD 1 year ago
parent 70f34d0d75
commit db92efc3a1

@ -68,25 +68,22 @@ class TeacherController extends UserController
}
public function addVocabList():void {
global $twig;
global $user;
$mdl = new MdlTeacher();
$name = Validation::filter_str_simple($_POST['listName'] ?? null);
$words = array();
for ($i = 0; $i <= 19; $i++) {
echo $i;
if (!isset($_POST['frenchWord' . $i]) == null || !isset($_POST['englishWord' . $i]) == null) break;
$frenchWord = Validation::filter_str_simple($_POST['frenchWord' . $i] ?? null);
$englishWord = Validation::filter_str_simple($_POST['englishWord' . $i] ?? null);
for ($i = 0; $i <= 20; $i++) {
if (empty($_POST['frenchWord' . $i]) || empty($_POST['englishWord' . $i])) break;
$frenchWord = Validation::filter_str_simple($_POST['frenchWord' . $i] ?? null);
$englishWord = Validation::filter_str_simple($_POST['englishWord' . $i] ?? null);
$words[] = array($frenchWord, $englishWord);
$words[] = array($frenchWord, $englishWord);
}
if (count($words) % 2 == 1) throw new Exception("il manque un mot");
if (count($words) % 2 == 0) throw new Exception("il manque un mot");
else {
$addvoc= $mdl->addVocabList($user->getId(), $name, "", $words);
$mdl->addVocabList($user->getId(), $name, "", $words);
$this->affAllVocab();
}
}

@ -23,7 +23,7 @@ class TranslationGateway extends AbsGateway
public function add(array $parameters): int // require 4 elements
{
try {
$this->addWord($parameters[0]);var_dump($parameters[0]);var_dump($parameters[1]);
$this->addWord($parameters[0]);
$this->addWord($parameters[1]);
$query = "INSERT INTO Translate VALUES(null, :word1, :word2, :idVoc)";
$args = array(':word1' => array($parameters[0], PDO::PARAM_STR),

Loading…
Cancel
Save