Anthony RICHARD 1 year ago
commit 1a391d93d5

@ -20,27 +20,32 @@ class TeacherController extends UserController
public function affAllVocab(): void public function affAllVocab(): void
{ {
global $twig; global $twig;
global $user;
$id = $user->getId();
$mdl = new MdlTeacher(); $mdl = new MdlTeacher();
$vocabularies = $mdl->getAll(); $vocabularies = $mdl->getAll();
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies]); echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'userId' => $id]);
} }
public function getByName(): void public function getByName(): void
{ {
global $twig; global $twig;
global $user;
$mdl = new MdlTeacher(); $mdl = new MdlTeacher();
$id = $user->getId();
$name = Validation::filter_str_simple($_GET['listName'] ?? null); $name = Validation::filter_str_simple($_GET['listName'] ?? null);
$vocab = $mdl->getVocabByName($name); $vocab = $mdl->getVocabByName($name);
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocab, 'selectedName' => $name]); echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocab, 'selectedName' => $name, 'userId' => $id ]);
} }
public function DelById():void{ public function DelById():void{
global $twig; global $twig;
global $user;
$mdl = new MdlTeacher(); $mdl = new MdlTeacher();
$id = Validation::filter_int($_GET['vocabID'] ?? null); $id = $user->getId();
$vocab = $mdl->removeVocById($id); $vocab = $mdl->removeVocById($id);
echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $vocab]); echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $vocab, 'userId' => $id ]);
} }
public function showVocabListForm(): void { public function showVocabListForm(): void {

@ -8,12 +8,12 @@
<div class="section"> <div class="section">
<section class="VocabularyList"> <section class="VocabularyList">
<h2>Vocab list</h2> <h2>Vocab list</h2>
{% include 'vocabularyContainer.twig' with {'actions' : 'affAllVocab', 'vocabularies' : vocabularies } %} {% include 'vocabularyContainer.twig' with {'actions' : 'affAllVocab', 'vocabularies' : vocabularies , 'userId' : userId} %}
</section> </section>
<section class="Vocabulaire"> <section class="Vocabulaire">
<h2>Vocab of the user</h2> <h2>Vocab of the user</h2>
{% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'getByName', 'selectedName' : 'selectedName' } %} {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'getByName', 'selectedName' : 'selectedName', 'userId' : userId } %}
</section> </section>
<section class="addGroupForm"> <section class="addGroupForm">
@ -23,7 +23,7 @@
<section class="unassignedUsers"> <section class="unassignedUsers">
<h1>Unassigned vocab</h1> <h1>Unassigned vocab</h1>
{% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'delById'} %} {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'delById', 'userId' : userId } %}
</section> </section>
</div> </div>
</body> </body>

@ -17,14 +17,14 @@
{% if actions is defined %} {% if actions is defined %}
<td> <td>
{% if actions == 'affAllVocab' %} {% if actions == 'affAllVocab' %}
<a href="affAllVocab"> <a href="{{base}}/teacher/{{ userId }}/affAllVocab">
</a> </a>
{% elseif actions == 'getByName' %} {% elseif actions == 'getByName' %}
<a href="getByName?listName={{ selectedName }}"> <a href="{{base}}/teacher/{{userId}}/getByName?VocabID={{selectedName}}">
</a> </a>
{% elseif actions == 'delById' %} {% elseif actions == 'delById' %}
<a id="delButton" href="delById?vocabID={{ row.id }}"> <a id="delButton" href="{{base}}/teacher/{{userId}}/delById?vocabID={{ row.id }}">
<input class="btn-black" type="button" value="delete from vocabulary" /> <input class="btn-black" type="button" value="delete from vocabulary" />
</a> </a>
{% endif %} {% endif %}

Loading…
Cancel
Save