ajout d'un fonction pour que le teacher vois que ses listes

php
Patrick BRUGIERE 1 year ago
parent 07819a17ca
commit 26e98ed144

@ -18,6 +18,14 @@ class TeacherController extends UserController
$groups = $mdl->getAllGroups(); $groups = $mdl->getAllGroups();
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'groups' => $groups, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'groups' => $groups, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]);
} }
public function findByUser():void {
global $twig;
global $user;
$mdl = new MdlTeacher();
$vocabularies = $mdl->findByUser($user->getId());
$groups = $mdl->getAllGroups();
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'groups' => $groups, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]);
}
public function DelById():void{ public function DelById():void{
global $user; global $user;

@ -131,4 +131,19 @@ class VocabularyListGateway extends AbsGateway
throw new Exception($e->getMessage()); throw new Exception($e->getMessage());
} }
} }
public function findByUser(int $id): array {
try {
$query = "SELECT v.* FROM VocabularyList v, User_ u WHERE v.userID =u.id AND u.id=:id";
$args = array(':id' => array($id, PDO::PARAM_INT));
$this->con->executeQuery($query, $args);
$results = $this->con->getResults();
$tab = array();
foreach ($results as $row) $tab[] = new VocabularyList($row['id'], $row['name'], $row['image'], $row['userID']);
return $tab;
}
catch (PDOException $e) {
throw new Exception($e->getMessage());
}
}
} }

@ -24,6 +24,12 @@ class MdlTeacher extends MdlUser
$gtw = new UserGateway(); $gtw = new UserGateway();
return $gtw->findAll(); return $gtw->findAll();
} }
public function findByUser($id):array
{
$gtw = new VocabularyListGateway();
return $gtw->findByUser($id);
}
public function getVocabByName(string $name):array{ public function getVocabByName(string $name):array{
$gtw = new VocabularyListGateway(); $gtw = new VocabularyListGateway();

@ -29,7 +29,7 @@
<div class="content"> <div class="content">
<section class="VocabularyList"> <section class="VocabularyList">
<h2>My lists</h2> <h2>My lists</h2>
{% include 'vocabularyContainer.twig' with {'actions' : ['affContent', 'delById', 'getContent' ], 'vocabularies' : vocabularies, 'vocabID' : vocabID, 'content' : content } %} {% include 'vocabularyContainer.twig' with {'actions' : ['findByUser', 'delById', 'getContent' ], 'vocabularies' : vocabularies, 'vocabID' : vocabID, 'content' : content } %}
</section> </section>
<section> <section>
<h2>Content</h2> <h2>Content</h2>

Loading…
Cancel
Save