public function grade(CodingExecutionResult $result)
 {
     $expected = 'I luv puppies';
     $result->assertInputContains('index.php', 'rand(');
     $result->assertOutputContains($expected);
     $text = trim($result->getCrawler()->filter('h3 span')->text());
     if (!is_numeric($text)) {
         throw new GradingException(sprintf('Are you printing the random number inside the span tag? I see "%s"', $text));
     }
     if ($text > 200 || $text < 100) {
         throw new GradingException(sprintf('Make sure the rand() function only returns numbers between 100 and 200', $text));
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $crawler = $result->getCrawler()->filter('form');
     if (count($crawler) == 0) {
         throw new GradingException('Did you create a `<form>` tag yet?');
     }
     if ($crawler->attr('action') != '/new_toy.php') {
         throw new GradingException('Make sure your form submits to `/new_toy.php`');
     }
     if (strtolower($crawler->attr('method')) != 'post') {
         throw new GradingException('Make sure your form has a `method` attribute on your `form` set to `POST`');
     }
     $form = $crawler->form();
     if (!$form->has('toy_name')) {
         throw new GradingException('I don\'t see any field with `name="toy_name"`');
     }
     if (!$form->has('description')) {
         throw new GradingException('I don\'t see any field with `name="description"`');
     }
 }