<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_survey_index
 *
 * @copyright   Copyright (C) 2025. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

// Load CSS directly from the module folder
/** @var Joomla\CMS\Document\HtmlDocument $doc */
$doc = Factory::getDocument();
$cssPath = 'modules/mod_survey_index/media/css/style.css';
$doc->addStyleSheet(Uri::root(true) . '/' . $cssPath . '?v=' . filemtime(dirname(__FILE__) . '/media/css/style.css'));

// Get parameters
$items = $params->get('items', []);

// If passing subform data, typically it comes as an array of objects or arrays depending on JVersion/Storage
// We ensure it is iterable
if (empty($items)) {
    return;
}

require ModuleHelper::getLayoutPath('mod_survey_index', $params->get('layout', 'default'));
