Merge remote-tracking branch 'origin/php' into php

php
Patrick BRUGIERE 1 year ago
commit 133880f019

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Before

Width:  |  Height:  |  Size: 4.3 MiB

After

Width:  |  Height:  |  Size: 4.3 MiB

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 210 KiB

Before

Width:  |  Height:  |  Size: 294 KiB

After

Width:  |  Height:  |  Size: 294 KiB

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 181 KiB

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Before

Width:  |  Height:  |  Size: 882 KiB

After

Width:  |  Height:  |  Size: 882 KiB

Before

Width:  |  Height:  |  Size: 6.6 MiB

After

Width:  |  Height:  |  Size: 6.6 MiB

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

@ -18,4 +18,4 @@ global $password;
$password = 'achanger';
global $altorouterPath;
$altorouterPath = "/SAE_2A_Anglais/Project/php";
$altorouterPath = "/~lugoigoux1/SAE_2A_Anglais/Project/php";

@ -10,37 +10,41 @@ class AdminController
{
public function showAllUsers(): void {
global $twig;
global $user;
$model = new MdlAdmin();
$users = $model->getAllUsers();
echo $twig->render('usersView.html', ['users' => $users]);
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
}
public function showAllAdmins(): void {
global $twig;
global $user;
$model = new MdlAdmin();
$users = $model->getAllAdmins();
echo $twig->render('usersView.html', ['users' => $users]);
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
}
public function showAllTeachers(): void {
global $twig;
global $user;
$model = new MdlAdmin();
$users = $model->getAllTeachers();
echo $twig->render('usersView.html', ['users' => $users]);
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
}
public function showAllStudents(): void {
global $twig;
global $user;
$model = new MdlAdmin();
$users = $model->getAllStudents();
echo $twig->render('usersView.html', ['users' => $users]);
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
}
public function removeUser(): void {
try {
$id = Validation::filter_int($_GET['userID'] ?? null);
global $user;
$model = new MdlAdmin();
$model->removeUser($id);
$model->removeUser($user->getId());
$this->showAllUsers();
}
catch (Exception $e) {
@ -50,21 +54,24 @@ class AdminController
public function showAllGroups(): void {
global $twig;
global $user;
$model = new MdlAdmin();
$groups = $model->getAllGroups();
$unassignedUsers = $model->getUnassignedUsers();
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'unassignedUsers' => $unassignedUsers]);
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'unassignedUsers' => $unassignedUsers, 'userID' => $user->getId()]);
}
public function showGroupDetails(): void {
try {
global $twig;
global $user;
$selectedGroup = Validation::filter_int($_GET['selectedGroup'] ?? null);
$model = new MdlAdmin();
$groups = $model->getAllGroups();
$users = $model->getUsersOfGroup($selectedGroup);
$unassignedUsers = $model->getUnassignedUsers();
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'selectedGroup' => $selectedGroup, 'users' => $users, 'unassignedUsers' => $unassignedUsers]);
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'selectedGroup' => $selectedGroup, 'users' => $users, 'unassignedUsers' => $unassignedUsers, 'userID' => $user->getId()]);
}
catch (Exception $e) {
throw new Exception("invalid group ID");
@ -113,10 +120,10 @@ class AdminController
public function addUserToGroup(): void {
try {
$user = Validation::filter_int($_GET['userID'] ?? null);
global $user;
$group = Validation::filter_int($_GET['groupID'] ?? null);
$model = new MdlAdmin();
$model->addUserToGroup($user, $group);
$model->addUserToGroup($user->getId(), $group);
$_GET['selectedGroup'] = $group;
$this->showGroupDetails();
}

@ -50,7 +50,6 @@ class FrontController
break;
default :
if ($id != null && !$this->checkIdExist($id)) throw new Exception("identifiant invalide");
if ($target == null) throw new Exception("pas de target");
if (isset($_SESSION['login']) && isset($_SESSION['roles'])) {
@ -62,6 +61,7 @@ class FrontController
$mdl = new $mdl;
if (is_callable(array($mdl, 'is'))) {
global $user;
$user = call_user_func_array(array($mdl, 'is'), array($_SESSION['login'], $_SESSION['roles']));
if (!$user || $user->getId() != $id) throw new Exception("erreur 403 permission denied");

@ -10996,7 +10996,7 @@ body {
padding: 0.9rem 0;
}
#mainNav .navbar-nav .nav-item:hover {
color: fade(#fff, 80%);
color: #faf4e0;
outline: none;
background-color: transparent;
}
@ -11021,7 +11021,7 @@ body {
color: #fff;
}
#mainNav .nav-link:hover {
color: #a840a3;
color: #faf4e0;
}
#mainNav .nav-link:active {
color: #fff;
@ -11053,7 +11053,7 @@ body {
#secondNav {
min-height: 3.5rem;
background-color: #940262;
background-color: #7464a1;
}
#secondNav .navbar-toggler {
font-size: 80%;
@ -11095,7 +11095,7 @@ body {
color: #fff;
}
#secondNav .nav-link:hover {
color: #a840a3;
color: #463c61;
}
#secondNav .nav-link:active {
color: #fff;

@ -1,4 +1,4 @@
<form action="addGroup" method="GET">
<form action="{{ base }}/admin/{{ userID }}/addGroup" method="GET">
<input name="num" type="text" placeholder="number" required>
<input name="year" type="text" placeholder="year" required>
<input name="sector" type="text" placeholder="sector" required>

@ -21,11 +21,10 @@
<section>
<h1>Add words</h1>
{% if user is defined %}
<form action="index.php" method="GET">
<form action="{{base}}/teacher/addVocabList" method="GET">
<table>
<tr>
<td colspan="2">
<input type="hidden" name="action" value="addVocabList">
<input type="hidden" name="userID" value="{{user}}">
<input type="text" name="listName" placeholder="list name" required>
</td>

@ -1,4 +1,5 @@
<table>
{{ userID }}
{% if groups is defined %}
{% for row in groups %}
{% if selectedGroup is defined and selectedGroup == row.id %}
@ -21,7 +22,7 @@
{% if 'showGroupDetails' in actions %}
<td>
<a href="showGroupDetails?selectedGroup={{ row.id }}">
<a href="{{base}}/admin/{{userID}}/showGroupDetails?selectedGroup={{ row.id }}">
<input class="btn-black" type="button" value="Show"/>
</a>
</td>
@ -29,7 +30,7 @@
{% if 'removeGroup' in actions %}
<td>
<a href="removeGroup?selectedGroup={{ row.id }}">
<a href="{{base}}/admin/{{userID}}/removeGroup?selectedGroup={{ row.id }}">
<input class="btn-black" type="button" value="Remove"/>
</a>
</td>

@ -28,7 +28,6 @@
<h2>Group list</h2>
{% include 'groupContainer.twig' with {'actions' : ['showGroupDetails', 'removeGroup']} %}
</section>
<section class="users">
<h2>Users of the group</h2>
{% include 'userContainer.twig' with {'users' : users, 'action' : 'removeUserFromGroup'} %}

@ -1,4 +1,4 @@
<form action="modifyPassword" method="GET">
<form action="{{base}}/user/modifyPassword" method="GET">
<input type="hidden" name="user" value={{user.id}}>
<input type="text" name="currentPassword" placeholder="current password" required>
<input type="text" name="newPassword" placeholder="new password" required>

@ -32,7 +32,7 @@
<tr><td>ID : </td><td>{{user.id}}</td></tr>
<tr><td>Nickname : </td><td>{{user.nickname}}</td>
<td>
<form action="modifyNickname" method="GET">
<form action="{{base}}/user/modifyNickname" method="GET">
<input type="hidden" name="user" value={{user.id}}>
<input name="newNickname" type="text" placeholder="new nickname" required>
<input type="submit" value="Modify your nickname">

@ -0,0 +1,33 @@
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="secondNav">
<div class="container px-4 px-lg-5">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
aria-label="Toggle navigation">
Menu
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto">
{% if userRole == 'admin' %}
<li class="nav-item"><a class="nav-link" href="{{ { base }/admin/{{ userID }}/showAllGroups}}">Groups</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/admin/{{ userID }}/showAllUsers}}">Users</a></li>
{% elseif userRole == 'student' %}
<li class="nav-item"><a class="nav-link" href="{{ { base }/user/memory}}">Learn a lesson</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/user/game}}">Play</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/student/{{ userID }}/createFC}}">Create flashcards</a></li>
{% elseif userRole == 'teacher' %}
<li class="nav-item"><a class="nav-link" href="{{ { base }/teacher/memory}}">Learn a lesson</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/teacher/game}}">Play</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/teacher/createFC}}">Create flashcards</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{{ path('login') }}">Login</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>

@ -0,0 +1,29 @@
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="secondNav">
<div class="container px-4 px-lg-5">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
aria-label="Toggle navigation">
Menu
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto">
{% if userRole == 'admin' %}
<li class="nav-item"><a class="nav-link" href="{{ { base }/admin/{{ userID }}/showAllGroups}}">Groups</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/admin/{{ userID }}/showAllUsers}}">Users</a></li>
{% elseif userRole == 'student' %}
<li class="nav-item"><a class="nav-link" href="{{ { base }/user/memory}}">Learn a lesson</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/user/game}}">Play</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/student/{{ userID }}/createFC}}">Create flashcards</a></li>
{% elseif userRole == 'teacher' %}
<li class="nav-item"><a class="nav-link" href="{{ { base }/teacher/memory}}">Learn a lesson</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/teacher/game}}">Play</a></li>
<li class="nav-item"><a class="nav-link" href="{{ { base }/teacher/createFC}}">Create flashcards</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{{ path('login') }}">Login</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>

@ -1,61 +0,0 @@
<table>
{% if translations is defined %}
{% for row in translations %}
<tr>
<td>{{ row.id }}</td>
<td>{{ row.word1 }}</td>
<td>{{ row.word2 }}</td>
<td>{{ row.listVocab }}</td>
</tr>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Manage groups</title>
<!-- Vos liens de styles et de scripts -->
</head>
<body>
<section>
<h1>Quiz</h1>
<form action="quiz" method="post">
{% if translations is defined %}
{% for translation in translations %}
<h2>{{ translation.word1 }}</h2>
{% set answers = [translation.word2] %}
{% for i in 0..3 %}
<input type="radio" name="answer{{ i }}" value="{{ valid[i] }}"> {{ answers[i] }}<br>
{% endfor %}
{% endfor %}
{% endif %}
<input type="submit" value="Submit">
</form>
<h1>Translator</h1>
<form action="quiz" method="POST">
{% if translations is defined %}
<table>
<tr>
<td>ID</td>
<td>Word 1</td>
<td>Word 2</td>
<td>List Vocabulary</td>
</tr>
{% for translation in translations %}
<tr>
<td>{{ translation.id }}</td>
<td>{{ translation.word1 }}</td>
<td>{{ translation.word2 }}</td>
<td>{{ translation.listVocab }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</form>
</section>
</body>
</html>
</table>

@ -24,17 +24,17 @@
{% if action is defined %}
{% if action == 'removeUserFromGroup' %}
<td><a href="removeUserFromGroup?id={{row.id}}&selectedGroup={{selectedGroup}}">
<td><a href="{{base}}/admin/{{ userID }}/removeUserFromGroup?id={{row.id}}&selectedGroup={{selectedGroup}}">
<input class="btn-black" type="button" value="Delete from group"/>
</a></td>
{% elseif action == 'addUserToGroup' %}
<td><a href="addUserToGroup?userID={{row.id}}&groupID={{selectedGroup}}">
<td><a href="{{base}}/admin/{{ userID }}/addUserToGroup?userID={{row.id}}&groupID={{selectedGroup}}">
<input class="btn-black" type="button" value="Add to group"/>
</a></td>
{% elseif action == 'removeUser' %}
<td><a href="removeUser?userID={{row.id}}">
<td><a href="{{base}}/admin/{{ userID }}/removeUser?userID={{row.id}}">
<input class="btn-black" type="button" value="Delete"/>
</a></td>
{% endif %}

Loading…
Cancel
Save