if (!$isPlayerConnected) { RequestTool::redirect('/'); } // Checks if quizz is initialized $player = $authenticationInstance->getConnectedPlayer(); $structureId = RequestTool::getParameter('structureId', RequestTool::PARAM_TYPE_UNSIGNED_INT, false, null); if ($structureId !== null || !$player->current_quizz) { try { $structureId = RequestTool::getParameter('structureId', RequestTool::PARAM_TYPE_UNSIGNED_INT); $structure = OsteoFactory::getElement('Structure', $structureId); } catch (Exception $e) { // Incorrect parameter or invalid structure: do nothing RequestTool::redirect('/'); } $isCraft = RequestTool::getParameter('craft', RequestTool::PARAM_TYPE_BOOLEAN, false, false); $questionList = OsteoFactory::getElementList('Question', ($isCraft ? 'question_is_in_craft_quizz=1 AND ' : '') . 'structure_id=' . $structureId, 'RAND() LIMIT ' . $structure->question_number); $quizz = array('structureId' => $structureId, 'questionList' => array()); foreach ($questionList as $question) { $quizz['questionList'][] = array('questionId' => $question->id, 'answer' => null); } $quizz['isCraft'] = $isCraft; $quizz['startDate'] = DateTool::getTimestamp(); $player->current_quizz = json_encode($quizz); $player->update(); $currentQuestionIndex = 0; $currentQuestion = reset($questionList); } else { if ($player->current_quizz) { $quizz = json_decode($player->current_quizz, true); foreach ($quizz['questionList'] as $questionNumber => $quizzQuestion) { if ($quizzQuestion['answer'] === null) {
<?php require_once '../../init/initAdmin.inc.php'; OsteoFactory::getElementList('StructureCategory'); $structureList = OsteoFactory::getElementList('Structure'); //$smarty->assign('javascript', array('manageQuestion')); //$smarty->assign('css', array('manageElement')); $smarty->assign('structureList', Osteo::elementListToArray($structureList, Osteo::FORMAT_ADMIN)); $smarty->assign('page', 'admin/structureList'); $smarty->display('admin/layout.tpl'); require_once 'init/end.inc.php';
<?php require_once '../../init/initAdmin.inc.php'; OsteoFactory::getElementList('QuestionCategory'); $structureList = OsteoFactory::getElementList('Structure'); $structureId = RequestTool::getParameter('structureId', RequestTool::PARAM_TYPE_UNSIGNED_INT, false, null); $questionList = OsteoFactory::getElementList('Question', $structureId !== null ? 'structure_id=' . $structureId : null); //$smarty->assign('javascript', array('manageQuestion')); //$smarty->assign('css', array('manageElement')); $smarty->assign('structureList', Osteo::elementListToArray($structureList, Osteo::FORMAT_ADMIN)); $smarty->assign('questionList', Osteo::elementListToArray($questionList, Osteo::FORMAT_ADMIN)); $smarty->assign('currentUrl', RequestTool::getCurrentURL(false)); $smarty->assign('page', 'admin/questionList'); $smarty->display('admin/layout.tpl'); require_once 'init/end.inc.php';
<?php require_once '../init/init.inc.php'; //$smarty->assign('javascript', array('manageQuestion')); //$smarty->assign('css', array('manageElement')); $smarty->assign('page', 'index'); if (AuthenticationTool::getInstance()->isPlayerConnected()) { OsteoFactory::getElementList('Component'); $structureList = OsteoFactory::getElementList('Structure', null, 'structure_category_order, structure_order ASC', 'structure LJ player_has_structure, structure_category IJ structure'); $smarty->assign('structureList', Osteo::elementListToArray($structureList, Structure::FORMAT_PLAYER_STRUCTURE_LIST)); $componentList = OsteoFactory::getElementList('Component'); $smarty->assign('componentList', Osteo::elementListToArray($componentList, Component::FORMAT_PLAYER_COMPONENT_LIST)); } $scoreDataList = Structure::getDatabaseConnection()->selectRequest('SELECT player_name, SUM(is_crafted) AS crafted, SUM(best_score) AS score, SUM(best_time) AS time FROM player INNER JOIN player_has_structure ON player.player_id = player_has_structure.player_id GROUP BY player.player_id ORDER BY crafted DESC, score DESC, time ASC LIMIT 10'); $scoreList = array(); foreach ($scoreDataList as $scoreData) { if (!$scoreData['time']) { $formattedTime = '-'; } else { $formattedTime = DateTool::timestampToString($scoreData['time'], DateTool::FORMAT_MINUTES); if (StringTool::startsWith($formattedTime, '00m')) { $formattedTime = StringTool::truncateFirstChars($formattedTime, 4); } if (StringTool::startsWith($formattedTime, '0')) { $formattedTime = StringTool::truncateFirstChars($formattedTime, 1); } } $scoreList[] = array('player_name' => $scoreData['player_name'], 'crafted' => $scoreData['crafted'], 'score' => $scoreData['score'], 'time' => $formattedTime); } $smarty->assign('scoreList', $scoreList); $smarty->display('layout.tpl');
if ($correctAnswerNumber > $playerStructure->best_score) { $isBestScore = true; } $playerStructure->best_score = $correctAnswerNumber; if ($correctAnswerNumber > $previousBestScore || $correctAnswerNumber === $previousBestScore && $time < $previousBestTime) { $playerStructure->best_time = $time; $isBestTime = true; } $playerStructure->update(); } //Checks if structures are unlocked if ($isSuccess) { $relatedStructureList = OsteoFactory::getElementList('StructureRequiredStructure', 'required_structure_id=' . $quizz['structureId']); foreach ($relatedStructureList as $relatedStructure) { $structure = OsteoFactory::getElement('Structure', $relatedStructure->structure_id); $requiredStructureList = OsteoFactory::getElementList('StructureRequiredStructure', 'structure_id=' . $structure->id . ' AND required_structure_id !=' . $quizz['structureId']); $isUnlocked = true; foreach ($requiredStructureList as $requiredStructure) { try { OsteoFactory::getElement('PlayerHasStructure', null, 'player_id=' . $player->id . ' AND structure_id=' . $requiredStructure->required_structure_id); } catch (ElementNoResultException $e) { LogTool::getInstance()->logWarning('no unlock'); $isUnlocked = false; break; } } if ($isUnlocked) { try { $newPlayerStructure = new PlayerHasStructure(); $newPlayerStructure->player_id = $player->id; $newPlayerStructure->structure_id = $relatedStructure->structure_id;