<?php
// $Id: verprova.php,v 1.10 2007/03/24 20:08:54 marcellobrandao Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
/**
* verprova.php, Responsável por gerar o formulário de abertura da prova
*
* Este arquivo exibe as instruções da prova que o aluno está fazendo e o permite
* que ele crie um resultado para a sua prova
* @author Marcello Brandão <hide@address.com>
* @version 1.0
* @package nivelamento
*/
/**
* Arquivos de cabeçalho do Xoops para carregar ...
*/
include("../../mainfile.php");
include("../../header.php");
/**
* Inclusões das classes do módulo
*/
include("class/nivelamento_perguntas.php");
include("class/nivelamento_provas.php");
include("class/nivelamento_respostas.php");
include("class/nivelamento_resultados.php");
/**
* Definindo arquivo de template da página
*/
$xoopsOption['template_main'] = 'nivelamento_verprova.html';
/**
* Pegando cod_prova do formulário e uid do aluno da session
*/
$cod_prova = $_GET['cod_prova'];
$uid = $xoopsUser->getVar('uid');
/**
* Criação das Fábricas de objetos que vamos precisar
*/
$fabrica_de_provas= new Xoopsnivelamento_provasHandler($xoopsDB);
$fabrica_de_resultados= new Xoopsnivelamento_resultadosHandler($xoopsDB);
$fabrica_de_perguntas= new Xoopsnivelamento_perguntasHandler($xoopsDB);
/**
* Fabricando o objeto prova
*/
$prova = $fabrica_de_provas->get($cod_prova);
/**
* Verificando privilégios do aluno para esta prova
*/
if (!($prova->isAutorizado())){
redirect_header("index.php",5,_MD_NIV_PROIBIDO);
}
/**
* Verificando prova já expirou
*/
$fim = $prova->getVar("data_fim","n");
$tempo = $prova->getVar("tempo","n");
$fimmaistempo = $fabrica_de_provas->dataMysql2dataUnix($fim)+$tempo;
if ($fimmaistempo<time()){
redirect_header("index.php",5,_MD_NIV_PROIBIDO);
}
/**
* Criação de objetos de critério para passar para as Fábricas
*/
$criteria_prova = new criteria ('cod_prova',$cod_prova);
$criteria_aluno = new criteria('uid_aluno',$uid);
$criteria_terminou = new criteria('terminou',1);
$criteria_resultado = new criteriaCompo ($criteria_aluno);
$criteria_resultado->add($criteria_prova);
$criteria_resultado->add($criteria_terminou);
/**
* Verificando se aluno já tinha terminado a prova antes em caso positivo
* informa atraves de mensagem
*/
if ($fabrica_de_resultados->getCount($criteria_resultado)>0){
redirect_header("index.php",5,_MD_NIV_JATERMINOU);
}
/**
* Pegando os dados da prova e o campo de segurança(TOKEN)
*/
$qtd_perguntas = $fabrica_de_perguntas->getCount($criteria_prova);
$titulo = $prova->getVar('titulo');
$descricao = $prova->getVar('descricao');
$instrucoes = $prova->getVar('instrucoes');
$nome_modulo = $xoopsModule->getVar('name');
$campo_token = $GLOBALS['xoopsSecurity']->getTokenHTML();
/**
* Atribuindo variáveis ao template
* obs: poderia ter sido feito direto na étapa anterior
* mas por questões de leitura de código separei os dois
* depois podemos pensar em juntar numa seção só
*/
$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar("name"). " - ".$titulo);
$xoopsTpl->assign('campo_token', $campo_token);
$xoopsTpl->assign('nome_modulo', $nome_modulo);
$xoopsTpl->assign('titulo', $titulo);
$xoopsTpl->assign('descricao', $descricao);
$xoopsTpl->assign('instrucoes', $instrucoes);
$xoopsTpl->assign('qtd_perguntas', $qtd_perguntas);
$xoopsTpl->assign('cod_prova', $cod_prova);
$xoopsTpl->assign('lang_instrucoes',_MD_NIV_INSTRUCOES);
$xoopsTpl->assign('lang_comecar',_MD_NIV_COMECAR);
$xoopsTpl->assign('lang_prova',_MD_NIV_PROVA);
/**
* Inclusão de arquivo de fechamento da página
*/
include("../../footer.php");
?>