dta_result.php 3.37 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// This file is part of Moodle - http://moodle.org/
// 
// 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.
// 
// 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.
// 
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * 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;

defined('MOODLE_INTERNAL') || die();

/**
 * 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.
     */
41
    const ASSIGNSUBMISSION_DTA_COMPONENT_NAME = 'assignsubmission_dta';
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
98
99
100
101
102

    /**
     * @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
     */
103
    public static function assignsubmission_dta_get_statename(int $state): string {
104
        if ($state == 1) {
105
            return get_string('tests_successful', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
106
        } else if ($state == 2) {
107
            return get_string('failures', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
108
        } else if ($state == 3) {
109
            return get_string('compilation_errors', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
110
        } else {
111
            return get_string('unknown_state', self::ASSIGNSUBMISSION_DTA_COMPONENT_NAME);
112
113
114
        }
    }
}