Skip to content

Commit fe9091a

Browse files
committed
Make event names consistent and coherent
1 parent 2075d9e commit fe9091a

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

src/Check/DatabaseCheck.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public function attach(EventDispatcher $eventDispatcher)
110110
$e->getParameter('exercise')->seed($db);
111111
});
112112

113-
$eventDispatcher->listen('cli.verify.solution-execute.pre', function (CliExecuteEvent $e) {
113+
$eventDispatcher->listen('cli.verify.reference-execute.pre', function (CliExecuteEvent $e) {
114114
$e->prependArg($this->solutionDsn);
115115
});
116116

117117
$eventDispatcher->listen(
118-
['cli.verify.user-execute.pre', 'cli.run.user-execute.pre'],
118+
['cli.verify.student-execute.pre', 'cli.run.student-execute.pre'],
119119
function (CliExecuteEvent $e) {
120120
$e->prependArg($this->userDsn);
121121
}
@@ -133,7 +133,7 @@ function (CliExecuteEvent $e) {
133133

134134
$eventDispatcher->listen(
135135
[
136-
'cli.verify.solution-execute.fail',
136+
'cli.verify.reference-execute.fail',
137137
'verify.finish',
138138
'run.finish'
139139
],

src/ExerciseRunner/CgiRunner.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,22 @@ public function getName()
8585
private function checkRequest(RequestInterface $request, $fileName)
8686
{
8787
try {
88-
$event = $this->eventDispatcher->dispatch(new CgiExecuteEvent('cgi.verify.solution-execute.pre', $request));
88+
$event = $this->eventDispatcher->dispatch(new CgiExecuteEvent('cgi.verify.reference-execute.pre', $request));
8989
$solutionResponse = $this->executePhpFile(
9090
$this->exercise->getSolution()->getEntryPoint(),
9191
$event->getRequest(),
92-
'solution'
92+
'reference'
9393
);
9494
} catch (CodeExecutionException $e) {
95-
$this->eventDispatcher->dispatch(new Event('cgi.verify.solution-execute.fail', ['exception' => $e]));
95+
$this->eventDispatcher->dispatch(new Event('cgi.verify.reference-execute.fail', ['exception' => $e]));
9696
throw new SolutionExecutionException($e->getMessage());
9797
}
9898

9999
try {
100-
$event = $this->eventDispatcher->dispatch(new CgiExecuteEvent('cgi.verify.user-execute.pre', $request));
101-
$userResponse = $this->executePhpFile($fileName, $event->getRequest(), 'user');
100+
$event = $this->eventDispatcher->dispatch(new CgiExecuteEvent('cgi.verify.student-execute.pre', $request));
101+
$userResponse = $this->executePhpFile($fileName, $event->getRequest(), 'student');
102102
} catch (CodeExecutionException $e) {
103-
$this->eventDispatcher->dispatch(new Event('cgi.verify.user-execute.fail', ['exception' => $e]));
103+
$this->eventDispatcher->dispatch(new Event('cgi.verify.student-execute.fail', ['exception' => $e]));
104104
return Failure::fromNameAndCodeExecutionFailure($this->getName(), $e);
105105
}
106106

@@ -215,8 +215,10 @@ public function run($fileName, OutputInterface $output)
215215
{
216216
$success = true;
217217
foreach ($this->exercise->getRequests() as $i => $request) {
218-
$event = $this->eventDispatcher->dispatch(new CgiExecuteEvent('cgi.run.user-execute.pre', $request));
219-
$process = $this->getProcess($fileName, $event->getRequest());
218+
$event = $this->eventDispatcher->dispatch(
219+
new CgiExecuteEvent('cgi.run.student-execute.pre', $request)
220+
);
221+
$process = $this->getProcess($fileName, $event->getRequest());
220222

221223
$output->writeTitle("Request");
222224
$output->emptyLine();
@@ -225,7 +227,9 @@ public function run($fileName, OutputInterface $output)
225227
$output->writeTitle("Output");
226228
$output->emptyLine();
227229
$process->start();
228-
$this->eventDispatcher->dispatch(new CgiExecuteEvent('cgi.run.executing', $request, ['output' => $output]));
230+
$this->eventDispatcher->dispatch(
231+
new CgiExecuteEvent('cgi.run.student.executing', $request, ['output' => $output])
232+
);
229233
$process->wait(function ($outputType, $outputBuffer) use ($output) {
230234
$output->write($outputBuffer);
231235
});

src/ExerciseRunner/CliRunner.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,22 @@ public function verify($fileName)
9797
$args = new ArrayObject($this->exercise->getArgs());
9898

9999
try {
100-
$event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.solution-execute.pre', $args));
100+
$event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.reference-execute.pre', $args));
101101
$solutionOutput = $this->executePhpFile(
102102
$this->exercise->getSolution()->getEntryPoint(),
103103
$event->getArgs(),
104-
'solution'
104+
'reference'
105105
);
106106
} catch (CodeExecutionException $e) {
107-
$this->eventDispatcher->dispatch(new Event('cli.verify.solution-execute.fail', ['exception' => $e]));
107+
$this->eventDispatcher->dispatch(new Event('cli.verify.reference-execute.fail', ['exception' => $e]));
108108
throw new SolutionExecutionException($e->getMessage());
109109
}
110110

111111
try {
112-
$event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.user-execute.pre', $args));
113-
$userOutput = $this->executePhpFile($fileName, $event->getArgs(), 'user');
112+
$event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.student-execute.pre', $args));
113+
$userOutput = $this->executePhpFile($fileName, $event->getArgs(), 'student');
114114
} catch (CodeExecutionException $e) {
115-
$this->eventDispatcher->dispatch(new Event('cli.verify.user-execute.fail', ['exception' => $e]));
115+
$this->eventDispatcher->dispatch(new Event('cli.verify.student-execute.fail', ['exception' => $e]));
116116
return Failure::fromNameAndCodeExecutionFailure($this->getName(), $e);
117117
}
118118
if ($solutionOutput === $userOutput) {
@@ -131,7 +131,7 @@ public function run($fileName, OutputInterface $output)
131131
{
132132
/** @var CliExecuteEvent $event */
133133
$event = $this->eventDispatcher->dispatch(
134-
new CliExecuteEvent('cli.run.user-execute.pre', new ArrayObject($this->exercise->getArgs()))
134+
new CliExecuteEvent('cli.run.student-execute.pre', new ArrayObject($this->exercise->getArgs()))
135135
);
136136

137137
$args = $event->getArgs();
@@ -147,7 +147,7 @@ public function run($fileName, OutputInterface $output)
147147
$output->writeTitle("Output");
148148
$process = $this->getPhpProcess($fileName, $args);
149149
$process->start();
150-
$this->eventDispatcher->dispatch(new CliExecuteEvent('cli.run.executing', $args, ['output' => $output]));
150+
$this->eventDispatcher->dispatch(new CliExecuteEvent('cli.run.student.executing', $args, ['output' => $output]));
151151
$process->wait(function ($outputType, $outputBuffer) use ($output) {
152152
$output->writeLine($outputBuffer);
153153
});

0 commit comments

Comments
 (0)