public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', 'fallCollectionPromoDescription', 'I don\'t see you printing the unknown variable yet...');
     $htmlGrader->assertOutputContains('Still wearing your summer swim shorts');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $htmlGrader->assertOutputContains('<strong>', 'The `<strong>` tag still looks escaped - how can you make it raw?');
     $normalGrader->assertInputContains('singleItem.twig', 'raw', 'Use the `raw` filter to *not* escape HTML tags');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', 'collectionTitle');
     $htmlGrader->assertElementContains('h1', 'Fall in love and look your best in the snow.');
 }
Beispiel #4
0
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $htmlGrader->assertOutputContains('We promise, 1 more pair of pants is coming very soon!');
     $normalGrader->assertInputContains('fallCollection.twig', 'length', 'Use the `length` filter to count the products');
     $normalGrader->assertInputContains('fallCollection.twig', 'is odd', 'Use the `is odd` to see if there are an odd number of products');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $htmlGrader->assertOutputDoesNotContain('The Black and Tan Trouser');
     $htmlGrader->assertOutputContains('Starfish Halloween Costume');
     $normalGrader->assertInputDoesNotContain('fallCollection.twig', '{% if', 'Hide the products with zero quantity, but without a new `{% if ...` statement: add an "if" part to the `{% for ...` tag.');
 }
Beispiel #6
0
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', 'else', 'Use an `else` with your `for` tag.');
     $normalGrader->assertInputContains('fallCollection.twig', 'No pants for you!');
     $normalGrader->assertInputDoesNotContain('fallCollection.twig', '{% if', 'You don\'t need the `{% if` statement that checks for the products anymore!');
 }
Beispiel #7
0
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', 'saleStartsAt');
     $normalGrader->assertInputContains('fallCollection.twig', 'F jS', 'Make sure you use the `F jS` (e.g. January 5th) format for the date');
     $htmlGrader->assertElementContains('h3', $this->getSaleStartsAt()->format('F jS'));
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $htmlGrader->assertElementContains('.stock-status', 'Out of Stock');
     $htmlGrader->assertElementContains('.stock-status', '62');
     $normalGrader->assertInputDoesNotContain('fallCollection.twig', '{% if', 'Remove the `{% if` statement and replace it with a single line that does the same thing');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('layout.twig', 'block(', 'Use the `block(\'sidebar\') function to determine if the child template has any sidebar content');
     $htmlGrader->assertOutputDoesNotContain('col-xs-3', 'Make sure the `.col-xs-3` element does not print at all, since there is no sidebar on this page.');
     $htmlGrader->assertOutputContains('col-xs-12', 'Change the main content div\'s class to be `col-xs-9` when there is no sidebar content.');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $htmlGrader->assertOutputContains('Winter is coming! Get your pants!');
     $htmlGrader->assertElementContains('footer', 'Winter is coming! Get your pants!', 'It looks like the `<footer>` HTML tag is gone. Print the text inside of this tag');
     $normalGrader->assertInputDoesNotContain('fallCollection.twig', '<footer>', 'You don\'t need to have the `<footer>` tag inside of `fallCollection.twig`. Instead, only put this `layout.twig`, and make your block only override the contents *inside* of it');
     $normalGrader->assertInputContains('layout.twig', 'You\'re hip, you\'re cool, you\'re a penguin!', 'Oh no! The original caption - `You\'re hip, you\'re cool, you\'re a penguin!` will now be missing from every other template that does *not* override the block. Make this be the default footer content.');
 }
Beispiel #11
0
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', '{%', 'Make sure to use the "do" something tag `{%` with the `for` tag');
     $normalGrader->assertInputContains('fallCollection.twig', 'for', 'Use the `for` tag to loop');
     $htmlGrader->assertElementContains('h3', 'The Black and Tan Trouser');
     $htmlGrader->assertElementContains('h3', 'Antarctic Snow Pants (in leopard seal print)');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $htmlGrader->assertOutputContains('The Black and Tan Trouser', 'Are you printing the product names?');
     $htmlGrader->assertOutputContains(99, 'Are you printing the product prices?');
     $normalGrader->assertInputContains('fallCollection.twig', 'product.name', 'You can just use `product.name` to print the name. Behind the scenes. Twig calls the `getName()` function on `PantsProduct`.');
     $normalGrader->assertInputContains('fallCollection.twig', 'product.price', 'You can just use `product.price` to print the price. Behind the scenes. Twig calls the `getPrice()` function on `PantsProduct`.');
 }
 public function grade(CodingExecutionResult $result)
 {
     $phpGrader = new PhpGradingTool($result);
     $phpGrader->assertVariableExists('deathStar');
     $deathStar = $result->getDeclaredVariableValue('deathStar');
     if (!$deathStar instanceof \DeathStarII) {
         throw new GradingException('The `$deathStar` variable exists, but is not set to a `DeathStarII` object.');
     }
     if (!$deathStar instanceof \DeathStar) {
         throw new GradingException('The `DeathStarII` class is not extending `DeathStar` one.');
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', 'extends', '`fallCollection.twig` needs to "extend" `layout.twig`');
     $normalGrader->assertInputContains('fallCollection.twig', 'layout.twig', '`fallCollection.twig` needs to "extend" `layout.twig`');
     $normalGrader->assertInputContains('mainCollection.twig', 'extends', '`mainCollection.twig` needs to "extend" `layout.twig`');
     $normalGrader->assertInputContains('mainCollection.twig', 'layout.twig', '`mainCollection.twig` needs to "extend" `layout.twig`');
     $normalGrader->assertInputContains('layout.twig', '<html', 'Put the entire HTML layout into `layout.twig`');
     $normalGrader->assertInputContains('layout.twig', '</html>', 'Put the entire HTML layout into `layout.twig`');
     $normalGrader->assertInputContains('layout.twig', '<header>', 'The `<header>` belongs in `layout.twig` too, since it\'s repeated on both pages');
     $normalGrader->assertInputDoesNotContain('fallCollection.twig', '<html', 'You no longer need the HTML layout (e.g. the `<html>` tag) inside of `fallCollection.twig`');
     $htmlGrader->assertOutputContains('The fall products are coming soon!');
 }
 public function grade(CodingExecutionResult $result)
 {
     $phpGrader = new PhpGradingTool($result);
     $phpGrader->assertVariableExists('original');
     $phpGrader->assertVariableExists('new');
     $original = $result->getDeclaredVariableValue('original');
     $new = $result->getDeclaredVariableValue('new');
     if (!$original instanceof \DeathStar) {
         throw new GradingException('The `$original` variable exists, but is not set to a `DeathStar` object.');
     }
     if (!$new instanceof \DeathStarII) {
         throw new GradingException('The `$new` variable exists, but is not set to a `DeathStarII` object.');
     }
     if (!$new instanceof \DeathStar) {
         throw new GradingException('The `DeathStarII` class is not extending `DeathStar` one.');
     }
     if ('Thermal Exhaust Port' != $original->getWeakness()) {
         throw new GradingException('The return value of `getWeakness()` method in a `DeathStar` class was changed. You should override it.');
     }
     if (null !== $new->getWeakness()) {
         throw new GradingException('The `getWeakness()` method of `DeathStarII` class does not return `null`.');
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', 'random(', 'Are you using the random() function?');
     $normalGrader->assertInputContains('fallCollection.twig', 'upper', 'Don\'t forget to use the `upper` filter to uppercase the colors!');
     $normalGrader->assertInputContains('fallCollection.twig', 'black', 'Use `black` (lowercase) as one of the random colors', true);
     $normalGrader->assertInputContains('fallCollection.twig', 'white', 'Use `black` (lowercase) as one of the random colors', true);
     $normalGrader->assertInputContains('fallCollection.twig', 'green', 'Use `black` (lowercase) as one of the random colors', true);
     if (!$htmlGrader->doesOutputContain('BLACK', true) && !$htmlGrader->doesOutputContain('WHITE', true) && !$htmlGrader->doesOutputContain('GREEN', true)) {
         throw new GradingException('The output does not contain any of the colors BLACK, GREEN or WHITE - are you randomly selecting one of these and uppercasing them?');
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $grader = new GenericGradingTool($result);
     $phpGrader = new PhpGradingTool($result);
     if (!class_exists('\\Cache')) {
         throw new GradingException('Class `Cache` does not exist. Did you create it?');
     }
     $cacheClass = new \ReflectionClass('\\Cache');
     if (!$cacheClass->hasMethod('fetchFromCache')) {
         throw new GradingException('Method `fetchFromCache` does not exist in the `Cache` class.');
     }
     if (!$cacheClass->hasMethod('saveToCache')) {
         throw new GradingException('Method `saveToCache` does not exist in the `Cache` class.');
     }
     $phpGrader->assertVariableExists('transformer', 'I don\'t see the $transformer variable in index.php anymore - did you delete it?');
     $transformer = $result->getDeclaredVariableValue('transformer');
     $transformerClass = new \ReflectionObject($transformer);
     if (!$transformerClass->hasMethod('__construct')) {
         throw new GradingException('Make sure you give the `StringTransformer` class a `__construct()`. It should have one argument: a `Cache` object.');
     }
     $grader->assertInputDoesNotContain('StringTransformer.php', 'file_get_contents', 'I still see `file_get_contents()` inside of `StringTransformer`. Make sure you\'ve moved all of the caching logic into the Cache class');
     // todo - create a mocked Cache, pass it into
     // $transformer and assert that its cache methods are called
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $normalGrader->assertInputContains('macros.twig', 'printSizingChart(', 'I don\'t see the `printSizingChart` macro in `macros.twig`');
     $normalGrader->assertInputContains('macros.twig', 'showXLColumn', 'I don\'t see the `showXLColumn` argument for the `printSizingChart` macro. Add this and use it to hide/show the XL column.');
     $normalGrader->assertInputContains('fallCollection.twig', 'printSizingChart', 'You\'ll need to use the `printSizingChart` macro inside `fallCollection.twig');
     $normalGrader->assertInputContains('mainCollection.twig', 'printSizingChart', 'You\'ll need to use the `printSizingChart` macro inside `mainCollection.twig');
     $normalGrader->assertInputContains('mainCollection.twig', 'import', 'Don\'t forget to `import` `macros.twig` in `mainCollection.twig`.');
     $htmlGrader->assertOutputContains('5-15 lbs');
     $htmlGrader->assertOutputDoesNotContain('61-85 lbs');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $normalGrader->assertInputContains('fallCollection.twig', 'products[randomProductKey]', 'Use the `products[variableName]` syntax to get a variable key from the array.');
 }
Beispiel #20
0
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $htmlGrader = new HtmlOutputGradingTool($result);
     $htmlGrader->assertOutputContains('pin-striped full suit');
     $normalGrader->assertInputContains('fallCollection.twig', 'include');
     $normalGrader->assertInputContains('_featuredProduct.twig', 'pin-striped full suit');
     $normalGrader->assertInputDoesNotContain('fallCollection.twig', 'pin-striped full suit', 'Now that you\'re including `_featuredProduct.twig`, you should remove the "pin-striped full suit" text from `fallCollection.twig`');
     $normalGrader->assertInputContains('mainCollection.twig', 'include');
 }
 public function grade(CodingExecutionResult $result)
 {
     $normalGrader = new PhpGradingTool($result);
     $normalGrader->assertInputContains('_featuredProduct.twig', 'defined', 'Use the `defined` filter to see if `quantityRemaining` is defined');
     $normalGrader->assertInputContains('_featuredProduct.twig', 'is not odd', 'Use `is not odd` to make sure `quantityRemaining` is not an odd number. (Hint: you could also use `is even` in real life... but not to pass this challenge)');
 }