public function getTerminyHodnotenia(Trace $trace) { $result = array(); $this->openIfNotAlready($trace); $predmety = $this->executor->readTable(array(), 'zapisanePredmety'); foreach ($predmety as $predmetIndex => $unused) { $terminy = $this->executor->readTable(array('predmet' => $predmetIndex), 'terminy'); foreach ($terminy as $terminIndex => $unused2) { $info = $this->executor->readTable(array('predmet' => $predmetIndex, 'termin' => $terminIndex), 'prihlas'); if (isset($info['jePrihlaseny'])) { $terminData = $info['prihlasenyData']; $terminData[0] = $info['jePrihlaseny'] ? 'TRUE' : 'FALSE'; $result[] = $terminData; } } } return new DataTableImpl(MojeTerminyRegression::get(), $result); }
/** * Akcia ktora sa pokusi prihlasit cloveka na danu skusku * * @param Trace $trace trace object * @param Context $context */ public function runPrihlasNaSkusku(Trace $trace, Context $context) { $request = $context->getRequest(); $response = $context->getResponse(); $predmetIndex = $request->getParameter("prihlasPredmetIndex"); $terminIndex = $request->getParameter("prihlasTerminIndex"); $predmety = $this->terminyHodnoteniaScreen->getPredmetyZapisnehoListu($trace->addChild('Predmety zapisneho listu')); FajrUtils::warnWrongTableStructure($response, 'terminy hodnotenia - predmety', regression\ZapisanePredmetyRegression::get(), $predmety->getTableDefinition()); $predmetyData = $predmety->getData(); $predmetKey = -1; foreach ($predmetyData as $key => $row) { if ((string) $row[PredmetyFields::INDEX] === $predmetIndex) { $predmetKey = $key; } } $childTrace = $trace->addChild('Zoznam terminov'); $terminyDialog = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($childTrace, $predmetIndex); $terminy = $terminyDialog->getZoznamTerminov($childTrace); FajrUtils::warnWrongTableStructure($response, 'zoznam mojich terminov', regression\MojeTerminyRegression::get(), $terminy->getTableDefinition()); $terminyData = $terminy->getData(); $terminKey = -1; foreach ($terminyData as $key => $terminyRow) { if ((string) $terminyRow[TerminyFields::INDEX] === $terminIndex) { $terminKey = $key; } } if ($predmetKey == -1 || $terminKey == -1) { throw new Exception("Ooops, predmet/termín nenájdený. Pravdepodobne\n zmena dát v AISe."); } $hash = StudiumUtils::hashNaPrihlasenie($predmetyData[$predmetKey][PredmetyFields::SKRATKA], $terminyData[$terminIndex]); if ($hash != $request->getParameter('hash')) { throw new Exception("Ooops, nesedia údaje o termíne. Pravdepodobne zmena\n dát v AISe spôsobila posunutie tabuliek."); } if (!$terminyDialog->prihlasNaTermin($trace->addChild('prihlasujem na termin'), $terminIndex)) { throw new Exception('Na skúšku sa nepodarilo prihlásiť.'); } $response->setTemplate('redirect'); FajrUtils::redirect(array('action' => 'studium.MojeTerminyHodnotenia', 'studium' => $this->studium, 'list' => $this->zapisnyList)); }