Patrick BRUGIERE 1 year ago
parent 6353b83a16
commit 1f9ef8b535

@ -5,15 +5,17 @@ use config\Validation;
use model\MdlTeacher;
use gateway\VocabularyListGateway;
use Exception;
use model\MdlUser;
class TeacherController extends UserController
{
public function affAllStudent(): void
{
global $twig;
global $user;
$mdl = new MdlTeacher();
$student = $mdl->getAllStudent();
echo $twig->render('usersView.html', ['users' => $student]);
echo $twig->render('usersView.html', ['users' => $student, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]);
}
@ -24,7 +26,7 @@ class TeacherController extends UserController
$id = $user->getId();
$mdl = new MdlTeacher();
$vocabularies = $mdl->getAll();
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'userId' => $id]);
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]);
}
public function getByName(): void
@ -35,7 +37,7 @@ class TeacherController extends UserController
$id = $user->getId();
$name = Validation::filter_str_simple($_GET['listName'] ?? null);
$vocab = $mdl->getVocabByName($name);
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocab, 'selectedName' => $name, 'userId' => $id ]);
echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocab, 'selectedName' => $name, 'userID' => $user->getId(), 'userRole' => $user->getRoles() ]);
}
@ -45,28 +47,37 @@ class TeacherController extends UserController
$mdl = new MdlTeacher();
$id = $user->getId();
$vocab = $mdl->removeVocById($id);
echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $vocab, 'userId' => $id ]);
echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $vocab, 'userID' => $user->getId(), 'userRole' => $user->getRoles() ]);
}
public function showVocabListForm(): void {
global $twig;
$userID = Validation::filter_int($_GET['userID'] ?? null);
echo $twig->render('addVocabList.html', ['user' => $userID]);
global $user;
echo $twig->render('addVocabList.html', ['userID' => $user->getId(), 'userRole' => $user->getRoles() ]);
}
public function addVocabList():void {
global $twig;
global $user;
$id = $user->getId();
$mdl = new MdlTeacher();
$name = Validation::filter_str_simple($_GET['listName'] ?? null);
$name = Validation::filter_str_simple($_POST['listName'] ?? null);
$words = array();
$frenchWord = Validation::filter_str_simple($_GET['frenchWord'] ?? null);
$englishWord = Validation::filter_str_simple($_GET['englishWord'] ?? null);
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);
$words[] = array($frenchWord, $englishWord);
var_dump($words);
$addvoc= $mdl->addVocabList($id, $name, "", $words);
echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $addvoc ,'userId' => $id]);
}
if (count($words) % 2 == 1) throw new Exception("il manque un mot");
else {
$addvoc= $mdl->addVocabList($user->getId(), $name, "", $words);
$this->affAllVocab();
}
}
}

@ -15,22 +15,21 @@
href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel="stylesheet" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
<link href="{{base}}/css/styles.css" rel="stylesheet" />
</head>
{% include 'navbar.twig' %}
{% include 'navBar.twig' %}
<div class="content">
<section>
<h1>Add words</h1>
{% if user is defined %}
<form action="{{base}}/teacher/addVocabList" method="GET">
{% if userID is defined %}
<form action="{{base}}/teacher/{{userID}}/addVocabList" method="POST">
<table>
<tr>
<td colspan="2">
<input type="hidden" name="userID" value="{{user}}">
<input type="text" name="listName" placeholder="list name" required>
</td>
</tr>
{% for i in 0..1 %}
{% for i in 0..20 %}
<tr>
<td><input type="text" name="frenchWord{{i}}" placeholder="french word"></td>
<td><input type="text" name="englishWord{{i}}" placeholder="english word"></td>

@ -21,7 +21,7 @@
<body id="page-top">
<!-- Navigation-->
{% include 'navbar.twig' %}
{% include 'navBar.twig' %}
<!-- Masthead-->
<header class="masthead">
<div class="container px-4 px-lg-5 d-flex h-100 align-items-center justify-content-center">

@ -24,7 +24,7 @@
}
</style>
<body>
{% include 'navbar.twig' %}
{% include 'navBar.twig' %}
<div class="content">
<section class="groupList">
<h2>Group list</h2>

@ -25,26 +25,26 @@
}
</style>
<body>
<div class="section">
{% include 'navBar.twig' %}
<div class="content">
<section class="VocabularyList">
<h2>Vocab list</h2>
{% include 'vocabularyContainer.twig' with {'actions' : 'affAllVocab', 'vocabularies' : vocabularies , 'userId' : userId } %}
<h2>My lists</h2>
{% include 'vocabularyContainer.twig' with {'actions' : ['affContent', 'delById'], 'vocabularies' : vocabularies } %}
</section>
<section class="Vocabulaire">
<h2>Vocab of the user</h2>
{% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'getByName', 'selectedName' : 'selectedName', 'userId' : userId } %}
<section>
<h2>Content</h2>
{% if content is defined %}
{% endif %}
//for ou ça affiche chaque traduction french - english [remove]
</section>
<section class="addGroupForm">
<h2>Add Vocabb</h2>
{% include 'vocabularyContainer.twig' with { 'vocabularies' : vocabularies ,'actions' : 'addVocabList' , 'userId' : userId } %}
<section>
<h2>Groups</h2>
//la liste des groupes [ajouter] ou [retirer]
</section>
<section class="unassignedUsers">
<h1>Unassigned vocab</h1>
{% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'delById', 'userId' : userId } %}
</section>
<a href="{{base}}/teacher/{{userID}}/showVocabListForm">
<input class="btn-black" type="button" value="add a list" />
</a>
</div>
</body>
</html>

@ -24,7 +24,7 @@
}
</style>
<body>
{% include 'navbar.twig' %}
{% include 'navBar.twig' %}
<div class="content">
<section>
<h1>My account</h1>

@ -43,7 +43,7 @@
</head>
<body>
{% include 'navbar.twig' %}
{% include 'navBar.twig' %}
<div class="content">
<div class="container">
<div class="message">

@ -8,7 +8,7 @@
</head>
<body>
{% include 'navbar.twig' %}
{% include 'navBar.twig' %}
{% if users is defined %}
<div class="content">
<section>

@ -14,40 +14,19 @@
<td>{{ row.image }}</td>
<td>{{ row.author }}</td>
{% if actions is defined %}
{% if actions is defined%}
<td>
{% if actions == 'affAllVocab' %}
<a href="{{base}}/teacher/{{ userId }}/affAllVocab">
</a>
{% elseif actions == 'getByName' %}
{% if 'getByName' in actions %}
<a href="{{base}}/teacher/{{userId}}/getByName?listName={{selectedName}}">
</a>
{% elseif actions == 'delById' %}
{% endif %}
{% if 'delById' in actions %}
<a id="delButton" href="{{base}}/teacher/{{userId}}/delById?vocabID={{ row.id }}">
<input class="btn-black" type="button" value="delete from vocabulary" />
</a>
{% endif %}
{% endif %}
{% endfor %}
<br>
{% if actions == 'addVocabList' %}
<form action="{{ base }}/teacher/{{ userId }}/addVocabList" method="GET">
<label for="listName">Name:</label>
<input type="text" id="listName" name="listName"><br><br>
<label for="frenchWord">French Word:</label>
<input type="text" id="frenchWord" name="frenchWord"><br><br>
<label for="englishWord">English Word:</label>
<input type="text" id="englishWord" name="englishWord"><br><br>
<input type="submit" value="Add Vocabulary">
</form>
{% endif %}
</td>

Loading…
Cancel
Save