dta_result.php 3.34 KB
Newer Older
1
<?php
2
// This file is part of Moodle - http://moodle.org/.
3
//
4
5
6
7
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
8
//
9
10
11
12
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
13
//
14
15
16
17
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
18
 * Entity class for DTA submission plugin result.
19
20
21
22
23
24
25
26
27
 *
 * @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;

/**
28
 * Entity class for DTA submission plugin result.
29
30
31
32
33
34
35
36
37
38
 *
 * @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.
     */
39
    public const ASSIGNSUBMISSION_DTA_COMPONENT_NAME = 'assignsubmission_dta';
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

    /**
     * @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.
     *
98
99
     * @param int $state Number of the state.
     * @return string Name of state as defined.
100
     */
101
    public static function assignsubmission_dta_get_statename(int $state): string {
102
        if ($state === 1) {
103
            return get_string('tests_successful', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
104
        } else if ($state === 2) {
105
            return get_string('failures', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
106
        } else if ($state === 3) {
107
            return get_string('compilation_errors', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
108
        } else {
109
            return get_string('unknown_state', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
110
111
112
        }
    }
}