Пример #1
0
 public function __construct($testId, $password)
 {
     $this->user = UserSession::getInstance()->getUser();
     $this->testId = $testId;
     $this->password = $password;
     $tprbBS = new TestProblemsBS(null);
     $qbuilder = new QueryBuilder('testproblems');
     $qbuilder->addEqual("tpb_tst_id", $testId);
     $qbuilder->addOrder("tpb_questionNumber", QueryBuilder::$ASC);
     $this->problems = $tprbBS->findNotDeleted($qbuilder);
     $testBS = new TestBS(null);
     $qbuilder = new QueryBuilder('test');
     $qbuilder->addEqual("tst_id", $testId);
     $qbuilder->addEqual("tst_password", $password);
     $tests = $testBS->findNotDeleted($qbuilder);
     if (count($tests) < 1) {
         die("<h3>ACESSO NEGADO</h3>");
     }
     $this->test = $tests[0];
     $ttrialBS = new TestTrialBS(null);
     $ttrialBS->createUserTrials($this->problems);
     $qbuilder = new QueryBuilder('testtrial');
     $qbuilder->addEqual("ttl_tst_id", $testId);
     $qbuilder->addEqual("ttl_usr_id", $this->user->get('usr_id'));
     $trials = $ttrialBS->findNotDeleted($qbuilder);
     $this->trials = array();
     if (count($trials) > 0) {
         foreach ($trials as $t => $trial) {
             $this->trials[$trial->get('ttl_prb_id')] = $trial;
         }
     }
     // Gravando log
     if ($this->test->get("tst_enableLogging") != 0) {
         $testBS->logAction($this->user->get('usr_id'), $this->testId, "Usuário abriu a prova.");
     }
 }
Пример #2
0
        public function renderNotDeleted($disciplineSelected = null)
        {
            $bs = new TestBS(null);
            if (!isset($disciplineSelected) || $disciplineSelected == "") {
                $tests = $bs->findNotDeleted(null);
            } else {
                $qbuilder = new QueryBuilder('test');
                $qbuilder->addEqual('tst_dsc_id', $disciplineSelected);
                $qbuilder->addOrder('tst_openUntil', QueryBuilder::$DESC);
                $qbuilder->addOrder('tst_visibleUntil', QueryBuilder::$DESC);
                $qbuilder->addOrder('tst_createdAt', QueryBuilder::$DESC);
                $qbuilder->addOrder('tst_title', QueryBuilder::$ASC);
                $qbuilder->addOrder('tst_openSince', QueryBuilder::$DESC);
                $qbuilder->addOrder('tst_visibleSince', QueryBuilder::$DESC);
                $tests = $bs->findNotDeleted($qbuilder);
            }
            if (count($tests) <= 0) {
                ?>
					<br/><i>Nenhuma prova cadastrada ainda.</i><br />
				<?php 
            } else {
                ?>
					<script type="text/javascript">
					function deleteTest(id) {
						if (confirm("Deseja realmente excluir esta prova?")) {
							$("#test-action-form input[name='_action']").val("delete");
							$("#test-action-form input[name='tst_id']").val(id);
							$("#test-action-form").submit();
						}
					}
					</script>
					<form method="POST" action="./controller/TestController.php" style="display:none;"
					id="test-action-form">
						<input type="hidden" name="_action" />
						<input type="hidden" name="tst_id" />
					</form>
					<table class="dataView">
					<tr>
						<th>Disciplina</th>
						<th>Título</th>
						<th>Visível de</th>
						<th>Visível até</th>
						<th>Aberta de</th>
						<th>Aberta até</th>
						<th>Nº de Questões</th>
						<th style="min-width:140px;width:140px;max-width:140px;">Ações</th>
					</tr>
					<?php 
                foreach ($tests as $t => $test) {
                    ?>
						<tr class="color<?php 
                    echo $t % 2;
                    ?>
">
							<td><?php 
                    echo $test->getForeignModel('tst_dsc_id')->get('dsc_code');
                    ?>
</td>
							<td><?php 
                    echo $test->get('tst_title');
                    ?>
</td>
							<td><?php 
                    echo Model::parseSQLToInputDate($test->get('tst_visibleSince'));
                    ?>
</td>
							<td><?php 
                    echo Model::parseSQLToInputDate($test->get('tst_visibleUntil'));
                    ?>
</td>
							<td><?php 
                    echo Model::parseSQLToInputDate($test->get('tst_openSince'));
                    ?>
</td>
							<td><?php 
                    echo Model::parseSQLToInputDate($test->get('tst_openUntil'));
                    ?>
</td>
							<?php 
                    $questions = $test->getMetaField("tst_numberOfQuestions");
                    if (!isset($questions) || $questions < 1) {
                        ?>
									<td style="background:#ff8888;"><?php 
                    } else {
                        ?>
									<td><?php 
                    }
                    echo $questions;
                    ?>
</td>
							<td class="actions">
								<span class="ui-state-default ui-corner-all" title="Editar Prova"
								onClick="location.assign('./testEdit.php?tst_id=<?php 
                    echo $test->get("tst_id");
                    ?>
');">
									<span class="ui-icon ui-icon-pencil"></span>
								</span>
								<span class="ui-state-default ui-corner-all" title="Configurar Problemas/Questões da Prova"
								onClick="location.assign('./testProblems.php?tpb_tst_id=<?php 
                    echo $test->get("tst_id");
                    ?>
');">
									<span class="ui-icon ui-icon-gear"></span>
								</span>
								<span class="ui-state-default ui-corner-all"
								title="Baixar ProblemBundleInit.hpp para o módulo AlGod Corretor (C++)."
								onClick="location.assign('./problemBundleInit.php?tpb_tst_id=<?php 
                    echo $test->get("tst_id");
                    ?>
');">
									<span class="ui-icon ui-icon-arrowthickstop-1-s"></span>
								</span>
								<span class="ui-state-default ui-corner-all"
								title="Visualizar logs da Prova."
								onClick="location.assign('./testLogs.php?tsl_tst_id=<?php 
                    echo $test->get("tst_id");
                    ?>
');">
									<span class="ui-icon ui-icon-note"></span>
								</span>
								<span class="ui-state-default ui-corner-all"
								title="Gerar relatório de notas."
								onClick="location.assign('./testReport.php?tpb_tst_id=<?php 
                    echo $test->get("tst_id");
                    ?>
');">
									<span class="ui-icon ui-icon-document"></span>
								</span>
								<span class="ui-state-default ui-corner-all" title="Excluir Prova"
								onClick="deleteTest(<?php 
                    echo $test->get('tst_id');
                    ?>
)">
									<span class="ui-icon ui-icon-trash"></span>
								</span>
							</td>
						</tr>
					<?php 
                }
                ?>
				</table>
				<?php 
            }
        }
Пример #3
0
        public function renderNotDeleted()
        {
            $bs = new TestBS(null);
            $qbuilder = new QueryBuilder('test');
            $today = new DateTime('now');
            $qbuilder->addLessEqual("tst_visibleSince", $today->format(Model::$SQL_DATE_FORMAT));
            $qbuilder->addGreaterEqual("tst_visibleUntil", $today->format(Model::$SQL_DATE_FORMAT));
            $qbuilder->addOrder('tst_openSince', QueryBuilder::$DESC);
            $qbuilder->addOrder('tst_visibleSince', QueryBuilder::$DESC);
            $qbuilder->addOrder('tst_title', QueryBuilder::$ASC);
            $qbuilder->addOrder('tst_createdAt', QueryBuilder::$DESC);
            $tests = $bs->findNotDeleted($qbuilder);
            if (count($tests) <= 0) {
                ?>
					<br/><i>Nenhuma prova aberta no momento.</i><br />
				<?php 
            } else {
                foreach ($tests as $t => $test) {
                    ?>
						<div class="data-view-box">
							<h3><?php 
                    echo $test->getForeignModel('tst_dsc_id')->get('dsc_code');
                    ?>
 -
							<?php 
                    echo $test->get('tst_title');
                    ?>
</h3>
							<p><b>INFORMAÇÕES:</b><br />
							<b>Visível de:</b>
							<?php 
                    echo Model::parseSQLToInputDate($test->get('tst_visibleSince'));
                    ?>
<br />
							<b>Visível até:</b>
							<?php 
                    echo Model::parseSQLToInputDate($test->get('tst_visibleUntil'));
                    ?>
<br />
							<b>Aberta de:</b>
							<?php 
                    echo Model::parseSQLToInputDate($test->get('tst_openSince'));
                    ?>
<br />
							<b>Aberta até:</b>
							<?php 
                    echo Model::parseSQLToInputDate($test->get('tst_openUntil'));
                    ?>
<br />
							<b>Descrição:</b><br />
							<?php 
                    echo $test->get('tst_description');
                    ?>
</p>
							<form method="POST" class="centering" action="encodePassword.php">
								<table class="formTable">
									<tr>
										<td>Senha de Acesso:</td>
										<td><input type="password" name="tst_password" size=40 /></td>
									</tr>
								</table>
								<input type="hidden" value="<?php 
                    echo $test->get("tst_id");
                    ?>
" name="tst_id" />
								<input type="submit" value="Abrir Prova" />
							</form>
						</div><br />
				<?php 
                }
            }
        }