Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Web interface to list and filter steps
19
 *
20
 * @package    tool_generator
21
 * @copyright  2023 Ferran Recio <ferran@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
use tool_generator\local\testscenario\runner;
26
use tool_generator\form\featureimport;
27
use tool_generator\output\parsingresult;
28
 
29
require(__DIR__ . '/../../../config.php');
30
require_once($CFG->libdir . '/adminlib.php');
31
require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
32
 
33
// Executing behat generator can take some time.
34
core_php_time_limit::raise(300);
35
 
36
admin_externalpage_setup('toolgenerator_runtestscenario');
37
 
38
$currenturl = new moodle_url('/admin/tool/generator/runtestscenario.php');
39
$runner = new runner();
40
 
41
/** @var core_renderer $output*/
42
$output = $PAGE->get_renderer('core');
43
 
44
echo $output->header();
45
echo $output->heading(get_string('testscenario', 'tool_generator'));
46
 
47
echo $output->paragraph(get_string('testscenario_description', 'tool_generator'));
48
 
49
try {
50
    $runner->init();
51
} catch (Exception $e) {
52
    echo $output->notification(get_string('testscenario_notready', 'tool_generator'), null, false);
53
    echo $output->footer();
54
    die;
55
}
56
 
57
echo $output->paragraph(get_string('testscenario_filedesc', 'tool_generator'));
58
 
59
$mform = new featureimport();
60
 
61
$data = null;
62
if (!$mform->is_cancelled()) {
63
    $data = $mform->get_data();
64
}
65
 
66
if (empty($data)) {
67
    $mform->display();
68
    echo $OUTPUT->footer();
69
    die;
70
}
71
 
72
$content = $mform->get_feature_contents();
73
 
74
if (empty($content)) {
75
    echo $output->notification(get_string('testscenario_invalidfile', 'tool_generator'));
76
    echo $output->continue_button($currenturl);
77
    echo $output->footer();
78
    die;
79
}
80
 
81
try {
82
    $parsedfeature = $runner->parse_feature($content);
83
} catch (\Throwable $th) {
84
    echo $output->notification(get_string('testscenario_errorparsing', 'tool_generator', $th->getMessage()));
85
    echo $output->continue_button($currenturl);
86
 
87
    echo $output->footer();
88
    die;
89
}
90
 
91
$runner->execute($parsedfeature);
92
 
93
echo $output->render(new parsingresult($parsedfeature));
94
echo $output->continue_button($currenturl);
95
echo $output->footer();