Skip to content

Commit

Permalink
Add code activities for ch2 and ch3 (BDD features and scenarios)
Browse files Browse the repository at this point in the history
  • Loading branch information
bocharsky-bw committed Oct 12, 2015
1 parent 4e4beaa commit 776a94b
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
50 changes: 50 additions & 0 deletions knpu/Challenges/BddFeatures/BestBusinessValueMC.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Challenges\BddFeatures;

use KnpU\ActivityRunner\Activity\MultipleChoice\AnswerBuilder;
use KnpU\ActivityRunner\Activity\MultipleChoiceChallengeInterface;

class BestBusinessValueMC implements MultipleChoiceChallengeInterface
{
/**
* @return string
*/
public function getQuestion()
{
return <<<EOF
For the messaging feature, you and the intern (Bob) are in
a heated debate over how to phrase the business value.
Which if the following is the *best* business value for the
message feature:
EOF;
}

/**
* @param AnswerBuilder $builder
*/
public function configureAnswers(AnswerBuilder $builder)
{
$builder
->addAnswer('In order to type messages and click to send them to scientists.')
->addAnswer('In order to communicate with other scientists.')
->addAnswer('In order to exchange information and resources with other scientists.', true)
->addAnswer('In order to send cat videos.')
;
}

/**
* @return string
*/
public function getExplanation()
{
return <<<EOF
Business value is subjective. But to help, forget about the technology
and think about the problem that your user role (scientist) wants to
solve. Both "communicate" and "exchange information and resources"
are pretty good business values, but I like the second, because it
contains a few more details about what the scientists actually
want to do.
EOF;
}
}
71 changes: 71 additions & 0 deletions knpu/Challenges/BddFeatures/RegistrationFeatureCoding.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Challenges\Interfaces;

use KnpU\ActivityRunner\Activity\CodingChallenge\CodingContext;
use KnpU\ActivityRunner\Activity\CodingChallenge\CorrectAnswer;
use KnpU\ActivityRunner\Activity\CodingChallengeInterface;
use KnpU\ActivityRunner\Activity\CodingChallenge\CodingExecutionResult;
use KnpU\ActivityRunner\Activity\CodingChallenge\FileBuilder;
use KnpU\ActivityRunner\Activity\Exception\GradingException;

class RegistrationFeatureCoding implements CodingChallengeInterface
{
/**
* @return string
*/
public function getQuestion()
{
return <<<EOF
You've assembled a crack team for a brand new project:
a site where paleontologists and other dinosaur scientists
can send each other important scientific messages, along
with the usual cat photos.
Each scientist will need to register to gain access, and
you - knowing that using BDD will create a better product -
are writing a registration feature. Fill in the 4 feature
lines in `registration.feature`.
EOF;
}

public function getFileBuilder()
{
$fileBuilder = new FileBuilder();
$fileBuilder
->addFileContents('registration.feature', <<<EOF
EOF
)
->setEntryPointFilename('registration.feature')
;

return $fileBuilder;
}

public function getExecutionMode()
{
return self::EXECUTION_MODE_PHP_NORMAL;
}

public function setupContext(CodingContext $context)
{
}

public function grade(CodingExecutionResult $result)
{
throw new GradingException('Oops...');
}

public function configureCorrectAnswer(CorrectAnswer $correctAnswer)
{
$correctAnswer
->setFileContents('registration.feature', <<<EOF
Feature: Registration
In order to send and receive messages from scientists I know
As a scientist
I can register for a new account
EOF
)
;
}
}

0 comments on commit 776a94b

Please sign in to comment.