. /** * Entity class for DTA submission plugin result. * * @package assignsubmission_dta * @copyright 2023 Gero Lueckemeyer and student project teams * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace assignsubmission_dta\models; /** * Entity class for DTA submission plugin result. * * @package assignsubmission_dta * @copyright 2023 Gero Lueckemeyer and student project teams * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class dta_result { /** * Broadly used in logic, parametrized for easier change. */ public const ASSIGNSUBMISSION_DTA_COMPONENT_NAME = 'assignsubmission_dta'; /** * @var string $packagename Package name of the test. */ public $packagename; /** * @var string $classname Unit name of the test. */ public $classname; /** * @var string $name Name of the test. */ public $name; /** * @var int $state State is defined as: * 0 UNKNOWN * 1 SUCCESS * 2 FAILURE * 3 COMPILATIONERROR */ public $state; /** * @var string $failuretype Type of test failure if applicable, empty string otherwise. */ public $failuretype; /** * @var string $failurereason Reason of test failure if applicable, empty string otherwise. */ public $failurereason; /** * @var string $stacktrace Stack trace of test failure if applicable, empty string otherwise. */ public $stacktrace; /** * @var int|string $columnnumber Column number of compile failure if applicable, empty string otherwise. */ public $columnnumber; /** * @var int|string $linenumber Line number of compile failure if applicable, empty string otherwise. */ public $linenumber; /** * @var int|string $position Position of compile failure if applicable, empty string otherwise. */ public $position; /** * Returns the name of a state with the given number for display. * * @param int $state Number of the state. * @return string Name of state as defined. */ public static function assignsubmission_dta_get_statename(int $state): string { if ($state === 1) { return get_string('tests_successful', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME); } else if ($state === 2) { return get_string('failures', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME); } else if ($state === 3) { return get_string('compilation_errors', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME); } else { return get_string('unknown_state', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME); } } }