Skip to content

Commit

Permalink
Adicionando opção de avaliação.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoborgesmachado committed Feb 19, 2024
1 parent 91d5ab3 commit c057591
Show file tree
Hide file tree
Showing 14 changed files with 1,639 additions and 37 deletions.
103 changes: 83 additions & 20 deletions src/components/Navbar/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as React from 'react';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import IconButton from '@mui/material/IconButton';
import Typography from '@mui/material/Typography';
import Menu from '@mui/material/Menu';
import MenuIcon from '@mui/icons-material/Menu';
import Container from '@mui/material/Container';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import Tooltip from '@mui/material/Tooltip';
Expand All @@ -19,11 +17,22 @@ import {Link} from 'react-router-dom';
import { toast } from 'react-toastify';
import api from '../../services/api.js';

const pages = ['📚 Provas', '🧾 Simulados', '🎓 Sisu', '➕Pratique Tabuada'];
const pages = ['📚 Provas', '🧾 Simulados', '📒Avaliações', '🎓 Sisu', '➕Pratique Tabuada'];
if(localStorage.getItem(Config.ADMIN) === '1'){
pages.push('Admin');
}
const settings = ['Olá ' + localStorage.getItem(Config.Nome), 'Perfil👽', 'Histórico de Questões⏳', 'Histórico Simulados🧾', 'Ranking dos usuários🔝','Sair👋'];

const settings = ['Olá ' + localStorage.getItem(Config.Nome)];
settings.push('Perfil👽');

if(localStorage.getItem(Config.ADMIN) === '2'){
settings.push('Minhas Avaliações');
}

settings.push('Histórico de Questões⏳');
settings.push('Histórico Simulados🧾');
settings.push('Ranking dos usuários🔝');
settings.push('Sair👋');

const ResponsiveAppBar = () => {
const navigate = useNavigate();
Expand All @@ -33,6 +42,7 @@ const ResponsiveAppBar = () => {
const [anchorElProva, setAnchorElProva] = React.useState(null);
const [anchorElSisu, setAnchorElSisu] = React.useState(null);
const [anchorElAdmin, setAnchorElAdmin] = React.useState(null);
const [anchorElMinhasAvaliacoes, setAnchorElMinhasAvaliacoes] = React.useState(null);
const [tipos, setTipos] = React.useState([]);

async function buscaTipos(){
Expand Down Expand Up @@ -93,35 +103,46 @@ const ResponsiveAppBar = () => {
setAnchorElUser(null);
};

const handleOpenMinhasAvaliacoes = (event) => {
setAnchorElMinhasAvaliacoes(event.currentTarget);
};

const handleCloseMinhasAvaliacoes = () => {
setAnchorElMinhasAvaliacoes(null);
setAnchorElUser(null);
};

function SelecionaOpcao(page){
handleCloseNavMenu();
if(page === pages[1]){
navigate('/simulado', {replace: true});
}
else if(page === pages[3]){
window.open("https://www.tabuadadivertida.com/", "_blank");
else if(page === pages[2]){
navigate('/avaliacoes', {replace: true});
}
else if(page === pages[4]){
abreTelaListagemHistoricoUsuario();
window.open("https://www.tabuadadivertida.com/", "_blank");
}
}

function SelecionaOpcaoUsuario(setting){
handleCloseUserMenu();
if(setting !== 'Minhas Avaliações'){
handleCloseUserMenu();
}

if(setting === settings[1]){
if(setting === 'Perfil👽'){
navigate('/perfil', {replace: true});
}
else if(setting === settings[2]){
else if(setting === 'Histórico de Questões⏳'){
navigate('/historico', {replace: true});
}
else if(setting === settings[3]){
else if(setting === 'Histórico Simulados🧾'){
navigate('/historicosimulado', {replace: true});
}
else if(setting === settings[4]){
else if(setting === 'Ranking dos usuários🔝'){
navigate('/ranking', {replace: true});
}
else if(setting === settings[5]){
else if(setting === 'Sair👋'){
sair();
}
}
Expand Down Expand Up @@ -198,9 +219,21 @@ const ResponsiveAppBar = () => {
navigate('/historicotabuadadivertida', {replace: true});
}

function abreTelaCadastroAvaliacao(){
handleCloseMinhasAvaliacoes();
handleCloseUserMenu();
navigate('/cadastroavaliacao', {replace: true});
}

function abreTelaMinhasAvaliacoes(){
handleCloseMinhasAvaliacoes();
handleCloseUserMenu();
navigate('/listagemminhasavaliacoes', {replace: true});
}

return (
<AppBar position="static" className='varBarResponsive'>
<div className='conNav'>
<div className='conNav'>
<div disableGutters className='toolNav'>
<BatteryChargingFullIcon sx={{ display: { xs: 'none', md: 'flex' }, mr: 1 }} />
<Typography
Expand Down Expand Up @@ -251,7 +284,7 @@ const ResponsiveAppBar = () => {
}}
>
{pages.map((page, index) => (
index != 0 && index != 2 && index != 4 ?
index != 0 && index != 3 && index != 5 ?
<MenuItem key={index} onClick={(e) => SelecionaOpcao(page)}>
<Typography textAlign="center">
{page}
Expand Down Expand Up @@ -294,7 +327,7 @@ const ResponsiveAppBar = () => {
</Menu>
</>
:
index == 2?
index == 3?
<>
<MenuItem key={page} onClick={handleOpenSisuMenu} >
<Typography textAlign="center">
Expand Down Expand Up @@ -392,7 +425,7 @@ const ResponsiveAppBar = () => {
</Typography>
<Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}>
{pages.map((page, index) => (
index != 0 && index != 2 && index != 4 ?
index != 0 && index != 3 && index != 5 ?
<Button
key={index}
onClick={(e) => SelecionaOpcao(page)}
Expand Down Expand Up @@ -434,7 +467,7 @@ const ResponsiveAppBar = () => {
</Menu>
</>
:
index == 2 ?
index == 3 ?
<>
<Button key={index} onClick={handleOpenSisuMenu} sx={{ my: 2, color: 'white', display: 'block' }}>
{page}
Expand Down Expand Up @@ -538,11 +571,41 @@ const ResponsiveAppBar = () => {
open={Boolean(anchorElUser)}
onClose={handleCloseUserMenu}
>
{settings.map((setting) => (
{settings.map((setting, index) => (
<MenuItem key={setting} onClick={(e) => SelecionaOpcaoUsuario(setting)}>
<Typography textAlign="center">
{
index == 2 && localStorage.getItem(Config.ADMIN) === '2'?
<>
<Typography key={setting} onClick={handleOpenMinhasAvaliacoes}>
{setting}
</Typography>
<Menu
sx={{ ml: '45px' }}
id="menu-appbar"
anchorEl={anchorElMinhasAvaliacoes}
keepMounted
open={Boolean(anchorElMinhasAvaliacoes)}
onClose={handleCloseMinhasAvaliacoes}
>
<MenuItem onClick={(e) => abreTelaCadastroAvaliacao()}>
<Typography textAlign="center">
Cadastrar
</Typography>
</MenuItem>
<MenuItem onClick={(e) => abreTelaMinhasAvaliacoes()}>
<Typography textAlign="center">
Listar Avaliações
</Typography>
</MenuItem>
</Menu>
</>
:
<Typography textAlign="center">
{setting}
</Typography>


}
</MenuItem>
))}
</Menu>
Expand Down
24 changes: 24 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -757,4 +757,28 @@ table{
.center-h2{
display: flex;
justify-content: center;
}

.center-text{
text-align: center;
}

.opcoes-botoes{
margin: 16px;
}

.opcoes-botoes button{
margin-bottom: 8px;
}

.alunosResponderamAvaliacao{
margin-top: 24px;
}

.alunosResponderamAvaliacao h4{
margin-bottom: 16px;
}

.select-item{
color: black;
}
14 changes: 12 additions & 2 deletions src/pages/Admin/Usuarios/Usuario.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function Usuarios(){
<h3>Log</h3>
</div>
<div className="separator separator--withMargins"></div>
<div>
<div className="detalhesModal">
<h4>
Id: {usuarios[index].id}
<br/>
Expand All @@ -108,7 +108,9 @@ function Usuarios(){
<br/>
Foi verificado: {usuarios[index].isVerified}
<br/>
Admin: {usuarios[index].admin}
Perfil: {usuarios[index].tipoPerfil?.descricao}
<br/>
Instituicao: {usuarios[index].instituicao}
</h4>
</div>
</div>
Expand All @@ -127,6 +129,9 @@ function Usuarios(){
<th>
Email
</th>
<th>
Perfil
</th>
<th>
Verificado
</th>
Expand Down Expand Up @@ -155,6 +160,11 @@ function Usuarios(){
{item.email}
</h4>
</td>
<td>
<h4>
{item.tipoPerfil?.descricao}
</h4>
</td>
<td>
<h4>
{item.isVerified}
Expand Down
88 changes: 88 additions & 0 deletions src/pages/Avaliacao/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import api from '../../services/api.js';
import { useParams, useNavigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
import {toast} from 'react-toastify';

function Avaliacao(){
const navigate = useNavigate();
const{code} = useParams();
const[loadding, setLoadding] = useState(true);

const[avaliacao, setAvaliacao] = useState({});

function BuscaAvaliacao(code){
setLoadding(true);
api.get(`/Avaliacao/getById?id=${code}`)
.then(response => {
setLoadding(false);
if(response.data.success){
setAvaliacao(response.data.object);
}
else{
toast.error('Erro ao buscar dados da avaliação');
navigate('/', {replace: true});
}
})
}

useEffect(() => {
BuscaAvaliacao(code);
}, [])

function abrirAvaliacao(id){
navigate('/questoes/avaliacao&' + id, { replace: true });
}

function abrirRespostas(id){
navigate('/resultadoAvaliacao/' + id, {replace: true});
}

function voltar(){
navigate('/avaliacoes', {replace: true});
}

function createMarkup(text) {
return {__html: text};
};

if(loadding){
return(
<div className='loaddingDiv'>
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
</div>
)
}

return(
<div className="containerpage global-fullW">
<div className='global-infoPanel'>
<div className='total'>
<button className='global-button global-button--transparent' onClick={voltar}>Voltar</button>
</div>
<div className="separator separator--withMargins"></div>
<div className='dadosAvaliacao'>
<h3 className='center-text'>{avaliacao.nome}</h3>
<h4>Professor: {avaliacao.usuario.nome}</h4>
<h4>Instituição: {avaliacao.usuario.instituicao}</h4>
<h4>Quantidade de questões: {avaliacao.questoesAvaliacao.length}</h4>
<h4>Nota total: {avaliacao.notaTotal}</h4>
{
avaliacao.orientacao ?
<>
<h3 className='center-text'>Instruções para prova: </h3>
<h4 dangerouslySetInnerHTML={createMarkup(avaliacao.orientacao.replaceAll('\n', '<br>'))}></h4>
</>
:<></>
}
</div>
<div className="separator separator--withMargins"></div>
<div className='opcoes-botoes'>
<button className='global-button global-button--full-width' onClick={() => abrirAvaliacao(avaliacao.id)}>Iniciar Avaliacao</button>
<button className='global-button global-button--full-width' onClick={() => abrirRespostas(avaliacao.id)}>Visualizar Minhas Respostas</button>
</div>
</div>
</div>
)
}

export default Avaliacao;
Loading

0 comments on commit c057591

Please sign in to comment.