. namespace tool_generator\form; defined('MOODLE_INTERNAL') || die(); use moodleform; global $CFG; require_once($CFG->dirroot . '/lib/formslib.php'); /** * Form for importting a testing scenario feature file. * * @package tool_generator * @copyright 2023 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class featureimport extends moodleform { public function definition(): void { $mform = &$this->_form; // File upload. $mform->addElement( 'filepicker', 'featurefile', get_string('testscenario_file', 'tool_generator'), null, ['accepted_types' => ['.feature']] ); $mform->addRule('featurefile', null, 'required'); $this->add_action_buttons(false, get_string('import')); } /** * Get the feature file contents. * @return string|null the feature file contents or null if not found. */ public function get_feature_contents(): ?string { $result = $this->get_file_content('featurefile'); if (!$result) { return null; } return $result; } }