public static function render($test, $problem, $trial, $tpb)
        {
            if (!isset($test) || !isset($problem)) {
                die("É necessário uma prova e um problema para utilizar este componente.");
            }
            if (!isset($trial)) {
                $tried = false;
            } else {
                $tried = true;
            }
            ?>
					<div class="problem-try-ct">
						<h3>
							Questão <?php 
            echo $tpb->get("tpb_questionNumber");
            ?>
:
							<?php 
            echo $problem->get("prb_title");
            ?>
						</h3>
						<p><b>Peso:</b> <?php 
            echo $tpb->get("tpb_weight");
            ?>
</p>
						<p><b>Descrição:</b></p>
						<div class="description-display-box">
							<?php 
            echo $problem->get("prb_description");
            ?>
						</div><br />
						<?php 
            if ($tried === false) {
                ?>
							<p><i>Você ainda não fez nenhuma tentativa nesta questão.</i></p>
						<?php 
            } else {
                ?>
							<p>
								<b>Ultima tentativa:</b>
								<?php 
                echo Model::parseSQLToInputDate($trial->get('ttl_lastTrial'));
                ?>
							</p>
							<p>
								<b>Total de tentativas:</b>
								<?php 
                echo $trial->get('ttl_trials');
                ?>
								(máximo de <?php 
                echo $test->get("tst_maxTrials");
                ?>
)
							</p>
							<p>
								<b>Nota (0 a 100):</b>
								<?php 
                echo $trial->get('ttl_score');
                ?>
							</p>
							<p>
								<b>Computador Utilizado:</b>
								<?php 
                echo $trial->get('ttl_hostname');
                ?>
							</p>
							<p>
								<b>IP Utilizado:</b>
								<?php 
                echo $trial->get('ttl_remoteAddr');
                ?>
							</p>
							<p>
								<b>Status ou Justificativa de Nota:</b>
								<?php 
                echo $trial->get('ttl_reason');
                ?>
							</p>
							<button onClick="openDivAsDialog('lastTrial<?php 
                echo $trial->get('ttl_prb_id');
                ?>
');">Ver Última Tentativa</button>
							<div style="display:none;" id='lastTrial<?php 
                echo $trial->get('ttl_prb_id');
                ?>
'>
								<textarea class="cpp-code-view"><?php 
                echo $trial->get('ttl_sourcefile');
                ?>
</textarea>
							</div>
						<?php 
            }
            if ($tried === true && $trial->get('ttl_trials') >= $test->get("tst_maxTrials")) {
                ?>
						<br />
						<p><i>Você esgotou o máximo de tentativas nesta questão.</i></p>
						<br />
						<?php 
            } else {
                ?>
						<br />
						<form method=POST action="controller/TestTrialController.php" class="centering">
							<table class="formTable">
								<tr>
									<td><label for="ttl_code">Código Impresso pelo Corretor</label>:</td>
									<td><input name="ttl_code" type="text" size=50 class="notempty" /></td>
								</tr>
								<tr>
									<td><label for="ttl_sourcefile">Código-fonte em C++</label>:</td>
									<td><textarea name="ttl_sourcefile" cols=80 rows=10 class="notempty"></textarea></td>
								</tr>
							</table>
							<input type="hidden" name="ttl_tst_id" value="<?php 
                echo $test->get("tst_id");
                ?>
" />
							<input type="hidden" name="tst_password" value="<?php 
                echo $test->get("tst_password");
                ?>
" />
							<input type="hidden" name="ttl_prb_id" value="<?php 
                echo $problem->get("prb_id");
                ?>
" />
                                                        <input type="hidden" name="ttl_questNumber" value="<?php 
                echo $tpb->get("tpb_questionNumber");
                ?>
" />
                                                        <input type="hidden" name="ttl_score" value="<?php 
                echo $trial->get('ttl_score');
                ?>
" />
							<input type="hidden" name="_action" value="save" />
							<input type="submit" value="Salvar Nova Tentiva" />
						</form>
						<br />
						<?php 
            }
            ?>
					</div>
				<?php 
        }
Example #2
0
        public function render()
        {
            $today = new DateTime('now');
            $since = DateTime::createFromFormat(Model::$SQL_DATE_FORMAT, $this->test->get('tst_openSince'));
            $until = DateTime::createFromFormat(Model::$SQL_DATE_FORMAT, $this->test->get('tst_openUntil'));
            if ($today->getTimestamp() < $since->getTimestamp()) {
                echo "<i>Essa prova não está aberta ainda.</i>";
            } else {
                if ($today->getTimestamp() > $until->getTimestamp()) {
                    echo "<i>Essa prova já está fechada.</i>";
                } else {
                    ?>
					<h2><?php 
                    echo $this->test->get('tst_title');
                    ?>
</h2>
					<p>
						<b>Corretor:</b>
						<a href="correctors/algod<?php 
                    echo $this->test->get('tst_id');
                    ?>
">Baixar</a>
					</p>
					<p>
						<b>Prova Aberta Até:</b>
						<?php 
                    echo Model::parseSQLToInputDate($this->test->get('tst_openUntil'));
                    ?>
					</p>
					<p>
						<b>Número Máximo de Tentativas:</b>
						<?php 
                    echo $this->test->get('tst_maxTrials');
                    ?>
					</p>
					<p>
						<b>Atenuação da Nota por Tentativa (multiplicativa):</b>
						<?php 
                    echo $this->test->get('tst_scoreAttenuationPerTrial');
                    ?>
					</p>
					<p>
						<b>Nota Máxima por Tentativa:</b>
						<ol style="text-align: left; padding-left: 12ex;">
						<?php 
                    for ($i = 0; $i < $this->test->get('tst_maxTrials'); $i++) {
                        ?>
								<li><?php 
                        echo 100.0 * pow($this->test->get('tst_scoreAttenuationPerTrial'), $i);
                        ?>
</li>
							<?php 
                    }
                    ?>
						</ol>
					</p>
					<p>
						<b>Descrição:</b>
					</p>
					<div class="description-display-box">
						<?php 
                    echo $this->test->get('tst_description');
                    ?>
					</div>
					<br /><h3>QUESTÕES</h3><br /><br />
					<?php 
                    foreach ($this->problems as $tp => $testpb) {
                        TestProblemTryView::render($this->test, $testpb->getForeignModel('tpb_prb_id'), @$this->trials[$testpb->get('tpb_prb_id')], $testpb);
                    }
                    ?>
				<?php 
                }
            }
        }
Example #3
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 
            }
        }
        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 
                }
            }
        }
Example #5
0
        public function render($testSelected = null)
        {
            $bs = new TestLogBS(null);
            if (!isset($testSelected) || $testSelected == "") {
                echo "<i>Nenhuma prova selecionada.</i>";
                return;
            } else {
                $qbuilder = new QueryBuilder('testlog');
                $qbuilder->addEqual('tsl_tst_id', $testSelected);
                $qbuilder->addOrder("usr_name", QueryBuilder::$ASC, 'user');
                $qbuilder->addOrder("tsl_time", QueryBuilder::$DESC);
                $qbuilder->addOrder("tsl_remoteAddr", QueryBuilder::$ASC);
                $tlogs = $bs->findAll($qbuilder);
            }
            $nLogs = count($tlogs);
            if ($nLogs <= 0) {
                ?>
					<br/><i>Nenhum log recuperado referente à esta prova.</i><br />
				<?php 
            } else {
                $test = $tlogs[0]->getForeignModel('tsl_tst_id');
                ?>
					<h2><?php 
                echo $test->get('tst_title');
                ?>
</h2><br /><br />
					<?php 
                $first = true;
                $prevUser = -1;
                foreach ($tlogs as $tl => $tlog) {
                    if ($prevUser != $tlog->get('tsl_usr_id')) {
                        $user = $tlog->getForeignModel('tsl_usr_id');
                        $prevUser = $tlog->get('tsl_usr_id');
                        if ($first == true) {
                            $first = false;
                        } else {
                            ?>
								</table>
							<?php 
                        }
                        ?>
							<br /><h3><?php 
                        echo $user->get("usr_name");
                        ?>
</h3>
							<table class="dataView">
							<tr>
								<th style="min-width:150px;width:150px;max-width:150px;">Horário</th>
								<th style="min-width:130px;width:130px;max-width:130px;">IP</th>
								<th style="min-width:150px;width:150px;max-width:150px;">Hostname</th>
                                                                <th style="min-width:150px;width:150px;max-width:150px;">Questão</th>
                                                                <th style="min-width:150px;width:150px;max-width:150px;">Nota</th>
								<th>Mensagem</th>
							</tr>
						<?php 
                    }
                    ?>
						<tr class="color<?php 
                    echo $tl % 2;
                    ?>
">
							<td><?php 
                    echo Model::parseSQLToInputDate($tlog->get('tsl_time'));
                    ?>
</td>
							<td><?php 
                    echo $tlog->get('tsl_remoteAddr');
                    ?>
</td>
							<td><?php 
                    echo $tlog->get('tsl_hostname');
                    ?>
</td>
                                                        <td><?php 
                    echo $tlog->get('tsl_questNumber');
                    ?>
</td>
                                                        <td><?php 
                    echo $tlog->get('tsl_score');
                    ?>
</td>
							<td style="cursor:pointer" onClick="openDivAsDialog('logmessagediv-<?php 
                    echo $tl;
                    ?>
');">
								<?php 
                    echo substr($tlog->get('tsl_message'), 0, 50);
                    ?>
...
								<div style='display:none;' id='logmessagediv-<?php 
                    echo $tl;
                    ?>
'>
									<textarea class="cpp-code-view"><?php 
                    echo $tlog->get('tsl_message');
                    ?>
</textarea>
								</div>
							</td>
						</tr>
						<?php 
                }
                ?>
</table><?php 
            }
        }
Example #6
0
        public function render()
        {
            $update = true;
            if (!isset($this->test)) {
                $this->test = new Test();
                $update = false;
            }
            @($enableLogging = $this->test->get("tst_enableLogging"));
            ?>
				<form method="POST" class="centering"
					action="./controller/TestController.php">
					<table class="formTable">
						<tr>
							<td><label for="tst_title">Título da Prova</label>:</td>
							<td><input name="tst_title" type="text" size=30 class="notempty"
								value="<?php 
            echo @$this->test->get("tst_title");
            ?>
" /> *</td>
						</tr>
						<tr>
							<td><label for="tst_description">Descrição/Instruções</label>:</td>
							<td><textarea name="tst_description" rows=8 cols=60 class="notempty"
								><?php 
            echo @$this->test->get("tst_description");
            ?>
</textarea>*</td>
						</tr>
						<tr>
							<td><label for="tst_password">Senha da Prova</label>:</td>
							<td><input name="tst_password" type="password" size=30 class="password" /> *</td>
						</tr>
						<tr>
							<td><label for="passwordconfirm">Confirmar Senha</label>:</td>
							<td><input name="passwordconfirm" type="password" size=30 class="passwordconfirm" /> *</td>
						</tr>
						<tr>
							<td><label for="tst_visibleSince">Visível a partir de</label>:</td>
							<td>
								<input name="tst_visibleSince" type="text" size=30 class="notempty datetime"
									value="<?php 
            echo @Model::parseSQLToInputDate($this->test->get("tst_visibleSince"));
            ?>
" /> 
								* (dd/mm/yyyy hh:mm:ss)
							</td>
						</tr>
						<tr>
							<td><label for="tst_visibleUntil">Visível até</label>:</td>
							<td>
								<input name="tst_visibleUntil" type="text" size=30 class="notempty datetime"
									value="<?php 
            echo @Model::parseSQLToInputDate($this->test->get("tst_visibleUntil"));
            ?>
" /> 
								* (dd/mm/yyyy hh:mm:ss)
							</td>
						</tr>
						<tr>
							<td><label for="tst_openSince">Aberta a partir de</label>:</td>
							<td>
								<input name="tst_openSince" type="text" size=30 class="notempty datetime"
									value="<?php 
            echo @Model::parseSQLToInputDate($this->test->get("tst_openSince"));
            ?>
" /> 
								* (dd/mm/yyyy hh:mm:ss)
							</td>
						</tr>
						<tr>
							<td><label for="tst_openUntil">Aberta até</label>:</td>
							<td>
								<input name="tst_openUntil" type="text" size=30 class="notempty datetime"
									value="<?php 
            echo @Model::parseSQLToInputDate($this->test->get("tst_openUntil"));
            ?>
" /> 
								* (dd/mm/yyyy hh:mm:ss)
							</td>
						</tr>
						<tr>
							<td><label for="tst_maxTrials">Número Máximo de Tentativas</label>:</td>
							<td><input name="tst_maxTrials" type="text" size=30 class="notempty integer"
								value="<?php 
            echo @$this->test->get("tst_maxTrials");
            ?>
" /> * Ex: 2</td>
						</tr>
						<tr>
							<td><label for="tst_scoreAttenuationPerTrial">Atenuação da Nota por Tentativa</label>:</td>
							<td><input name="tst_scoreAttenuationPerTrial" type="text" size=30 class="notempty number"
								value="<?php 
            echo @$this->test->get("tst_scoreAttenuationPerTrial");
            ?>
" /> * Ex: 0.5</td>
						</tr>
						<tr>
							<td><label for="tst_enableLogging">Habilitar Log da Prova</label>:</td>
							<td>
								<input id="disableLogging" name="tst_enableLogging" type="radio" value="0"
									<?php 
            echo !isset($enableLogging) || $enableLogging == 0 ? "checked" : "";
            ?>
 />
									<label for="disableLogging">Não</label>
								&nbsp;&nbsp;|&nbsp;&nbsp;
								<input id="enableLogging" name="tst_enableLogging" type="radio" value="1"
									<?php 
            echo isset($enableLogging) && $enableLogging != 0 ? "checked" : "";
            ?>
 />
									<label for="enableLogging">Sim</label>
							</td>
						</tr>
						<tr>
							<td><label for="tst_dsc_id">Disciplina</label>:</td>
							<td>
								<?php 
            $select = new DisciplineSelect();
            if ($update === true) {
                $select->render("tst_dsc_id", $this->test->get("tst_dsc_id"), "notempty");
            } else {
                $select->render("tst_dsc_id", null, "notempty");
            }
            ?>
 *
							</td>
						</tr>
					</table>
					<?php 
            if ($update === true) {
                ?>
						<input type="hidden" name="tst_id" value="<?php 
                echo @$this->test->get("tst_id");
                ?>
" />
					<?php 
            }
            ?>
					<input type="hidden" name="_action" value="save" />
					<input type="submit" value="Salvar" />
					<input type="reset" value="Limpar Campos" />
				</form>
				<?php 
        }