Remove temporary test data from installer

This commit is contained in:
Wojtek
2026-10-15 08:57:42 +02:00
parent c0a6253dbe
commit 1f5c773477
18 changed files with 129 additions and 4 deletions
@@ -9,13 +9,50 @@ use Joomla\CMS\MVC\Model\ListModel;
class QuestionsModel extends ListModel
{
protected function populateState($ordering = 'ordering', $direction = 'asc')
{
parent::populateState($ordering, $direction);
$menu = Factory::getApplication()->getMenu()->getActive();
$menuSymbol = $menu ? (string) $menu->getParams()->get('test_symbol', '') : '';
$symbol = Factory::getApplication()->getInput()->getString('test_symbol', $menuSymbol);
$this->setState('filter.test_symbol', trim($symbol));
}
protected function getListQuery()
{
$db = Factory::getContainer()->get('DatabaseDriver');
return $db->getQuery(true)
->select(['question_type', 'question', 'answer_a', 'answer_b', 'answer_c', 'answer_d', 'answer_open', 'correct_answer', 'image'])
$query = $db->getQuery(true)
->select(['question_type', 'question', 'answer_a', 'answer_b', 'answer_c', 'answer_d', 'answer_open', 'correct_answer', 'image', 'time_limit', 'points'])
->from($db->quoteName('#__testquestions_questions'))
->where($db->quoteName('published') . ' = 1')
->order($db->quoteName('ordering') . ' ASC, ' . $db->quoteName('id') . ' ASC');
$symbol = $this->getState('filter.test_symbol');
if ($symbol !== '') {
$query->where($db->quoteName('test_symbol') . ' = ' . $db->quote($symbol));
} else {
$query->where('1 = 0');
}
return $query;
}
public function getTestSymbols()
{
$db = Factory::getContainer()->get('DatabaseDriver');
return $db->setQuery(
$db->getQuery(true)
->select([
$db->quoteName('test_symbol', 'value'),
$db->quoteName('test_symbol', 'text'),
])
->from($db->quoteName('#__testquestions_questions'))
->where($db->quoteName('published') . ' = 1')
->where($db->quoteName('test_symbol') . ' <> ' . $db->quote(''))
->group($db->quoteName('test_symbol'))
->order($db->quoteName('test_symbol') . ' ASC')
)->loadObjectList();
}
}
@@ -9,10 +9,14 @@ use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
class HtmlView extends BaseHtmlView
{
protected $items;
protected $symbol;
protected $symbols;
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->symbol = $this->get('State')->get('filter.test_symbol');
$this->symbols = $this->get('TestSymbols');
return parent::display($tpl);
}
}