|
2 | 2 |
|
3 | 3 | namespace PhpSchool\PhpWorkshop\ExerciseRunner; |
4 | 4 |
|
| 5 | +use PhpSchool\PhpWorkshop\Check\CodeParseCheck; |
| 6 | +use PhpSchool\PhpWorkshop\Check\FileExistsCheck; |
| 7 | +use PhpSchool\PhpWorkshop\Check\PhpLintCheck; |
5 | 8 | use PhpSchool\PhpWorkshop\Event\CgiExecuteEvent; |
6 | 9 | use PhpSchool\PhpWorkshop\Event\Event; |
7 | 10 | use PhpSchool\PhpWorkshop\Event\EventDispatcher; |
8 | 11 | use PhpSchool\PhpWorkshop\Exception\CodeExecutionException; |
9 | 12 | use PhpSchool\PhpWorkshop\Exception\SolutionExecutionException; |
10 | 13 | use PhpSchool\PhpWorkshop\Exercise\CgiExercise; |
| 14 | +use PhpSchool\PhpWorkshop\ExerciseDispatcher; |
11 | 15 | use PhpSchool\PhpWorkshop\Output\OutputInterface; |
12 | 16 | use PhpSchool\PhpWorkshop\Result\CgiOutFailure; |
13 | 17 | use PhpSchool\PhpWorkshop\Result\CgiOutRequestFailure; |
@@ -85,6 +89,22 @@ public function getName() |
85 | 89 | return 'CGI Program Runner'; |
86 | 90 | } |
87 | 91 |
|
| 92 | + /** |
| 93 | + * Configure the exercise dispatcher. For example set the required checks |
| 94 | + * for this exercise type. |
| 95 | + * |
| 96 | + * @param ExerciseDispatcher $exerciseDispatcher |
| 97 | + * @return self |
| 98 | + */ |
| 99 | + public function configure(ExerciseDispatcher $exerciseDispatcher) |
| 100 | + { |
| 101 | + $exerciseDispatcher->requireCheck(FileExistsCheck::class); |
| 102 | + $exerciseDispatcher->requireCheck(PhpLintCheck::class); |
| 103 | + $exerciseDispatcher->requireCheck(CodeParseCheck::class); |
| 104 | + |
| 105 | + return $this; |
| 106 | + } |
| 107 | + |
88 | 108 | /** |
89 | 109 | * @param RequestInterface $request |
90 | 110 | * @param string $fileName |
@@ -113,7 +133,7 @@ private function checkRequest(RequestInterface $request, $fileName) |
113 | 133 | $this->eventDispatcher->dispatch(new Event('cgi.verify.student-execute.fail', ['exception' => $e])); |
114 | 134 | return Failure::fromNameAndCodeExecutionFailure($this->getName(), $e); |
115 | 135 | } |
116 | | - |
| 136 | + |
117 | 137 | $solutionBody = (string) $solutionResponse->getBody(); |
118 | 138 | $userBody = (string) $userResponse->getBody(); |
119 | 139 | $solutionHeaders = $this->getHeaders($solutionResponse); |
|
0 commit comments