Patrick BRUGIERE 2 years ago
parent 6353b83a16
commit 1f9ef8b535

@ -5,15 +5,17 @@ use config\Validation;
use model\MdlTeacher; use model\MdlTeacher;
use gateway\VocabularyListGateway; use gateway\VocabularyListGateway;
use Exception; use Exception;
use model\MdlUser;
class TeacherController extends UserController class TeacherController extends UserController
{ {
public function affAllStudent(): void public function affAllStudent(): void
{ {
global $twig; global $twig;
global $user;
$mdl = new MdlTeacher(); $mdl = new MdlTeacher();
$student = $mdl->getAllStudent(); $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(); $id = $user->getId();
$mdl = new MdlTeacher(); $mdl = new MdlTeacher();
$vocabularies = $mdl->getAll(); $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 public function getByName(): void
@ -35,7 +37,7 @@ class TeacherController extends UserController
$id = $user->getId(); $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, '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(); $mdl = new MdlTeacher();
$id = $user->getId(); $id = $user->getId();
$vocab = $mdl->removeVocById($id); $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 { public function showVocabListForm(): void {
global $twig; global $twig;
$userID = Validation::filter_int($_GET['userID'] ?? null); global $user;
echo $twig->render('addVocabList.html', ['user' => $userID]); echo $twig->render('addVocabList.html', ['userID' => $user->getId(), 'userRole' => $user->getRoles() ]);
} }
public function addVocabList():void { public function addVocabList():void {
global $twig; global $twig;
global $user; global $user;
$id = $user->getId();
$mdl = new MdlTeacher(); $mdl = new MdlTeacher();
$name = Validation::filter_str_simple($_GET['listName'] ?? null); $name = Validation::filter_str_simple($_POST['listName'] ?? null);
$words = array(); $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); $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" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel="stylesheet" /> rel="stylesheet" />
<!-- Core theme CSS (includes Bootstrap)--> <!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" /> <link href="{{base}}/css/styles.css" rel="stylesheet" />
</head> </head>
{% include 'navbar.twig' %} {% include 'navBar.twig' %}
<div class="content"> <div class="content">
<section> <section>
<h1>Add words</h1> <h1>Add words</h1>
{% if user is defined %} {% if userID is defined %}
<form action="{{base}}/teacher/addVocabList" method="GET"> <form action="{{base}}/teacher/{{userID}}/addVocabList" method="POST">
<table> <table>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<input type="hidden" name="userID" value="{{user}}">
<input type="text" name="listName" placeholder="list name" required> <input type="text" name="listName" placeholder="list name" required>
</td> </td>
</tr> </tr>
{% for i in 0..1 %} {% for i in 0..20 %}
<tr> <tr>
<td><input type="text" name="frenchWord{{i}}" placeholder="french word"></td> <td><input type="text" name="frenchWord{{i}}" placeholder="french word"></td>
<td><input type="text" name="englishWord{{i}}" placeholder="english word"></td> <td><input type="text" name="englishWord{{i}}" placeholder="english word"></td>

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

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

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

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

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

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

@ -14,40 +14,19 @@
<td>{{ row.image }}</td> <td>{{ row.image }}</td>
<td>{{ row.author }}</td> <td>{{ row.author }}</td>
{% if actions is defined %} {% if actions is defined%}
<td> <td>
{% if actions == 'affAllVocab' %} {% if 'getByName' in actions %}
<a href="{{base}}/teacher/{{ userId }}/affAllVocab">
</a>
{% elseif actions == 'getByName' %}
<a href="{{base}}/teacher/{{userId}}/getByName?listName={{selectedName}}"> <a href="{{base}}/teacher/{{userId}}/getByName?listName={{selectedName}}">
</a> </a>
{% elseif actions == 'delById' %} {% endif %}
{% if 'delById' in actions %}
<a id="delButton" href="{{base}}/teacher/{{userId}}/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 %}
{% endif %} {% endif %}
{% endfor %} {% 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> </td>

Loading…
Cancel
Save