This project is a prototype that should help in experimenting event-driven development in PHP.
The aim is not to produce an entire application, but just a service layer that is able to reproduce the workflow of an exam and allow to build flexible applications on it.
All following documentation can be subject to modifications by the working group.
examination: a set of questions or exercises evaluating skill or knowledge;
In a wider view, an exam could also just be a forced set of lectures/audio tracks to ensure that a user has obtained some knowledge. It could also be an extended poll for market research and so on.
-
An exam has (in most cases) following workflow:
- Exam is booked/generated for various users (like at university). User gets notification about the assigned exam (optional)
- User takes the exam by starting it
- User goes through the various steps that compose the exam and answer/follow instructions in each step
- User completes the exam or eventually aborts it. Abort can either be explicit or implicit (user does not complete it in time, if time limit is set)
- Exam is evaluated
- User get achievements (optional)
To achieve what is defined in the requirements and still keep a very flexible structure, event driven design has been chosen as the best suited pattern for this prototype. Other approaches and suggestions are welcome.
Implementations should use either Symfony2's Symfony\Component\EventDispatcher
component
or Zend Framework 2's Zend\EventManager
component. This decision is up to the developers
working on the concept. Also, suggestions for improvement for both components could be
collected.
- An
Exam
is a set ofExam\Step
instances. - An
Exam
has a reference to aUser
that is taking it. - An
Exam
can generate anExam\Evaluation
- An
Exam\Step
can generate anExam\Step\Evaluation
Exam
:- must provide a description of itself
- must provide the
User
that is taking it - must provide its current status (
new
,started
,aborted
,completed
) - must behave like an
Iterator
for steps (moving to arbitrary step is not a requirement) - must provide an evaluation
- could provide a start and/or an end time limit
- must trigger events for
create
when created/plannedstart
when taken by theUser
complete
when completedabort
when aborted (also: how do we know when it is aborted?)iterate
whenever iteration over steps happens (more events can be applied to the iterator)
Exam\Step
- must provide a description of itself
- must provide its status (
new
,read
,answered
) - could accept an answer (steps with forced lectures could not need an answer)
- must provide an evaluation
- must trigger events for
visit
when visitedanswer
when answered
Exam\Evaluation
- must provide a boolean serialization (
passed
/failed
)
- must provide a boolean serialization (
Exam\Step\Evaluation
- must provide a boolean serialization (
passed
/failed
)
- must provide a boolean serialization (
will provide sample interface and eventually sample implementation
- Define how an eventual service should be structured:
- Should it provide exam instances (like a
Doctrine\Common\Persistence\ObjectRepository
?) - Should it provide ways to interact with an exam
instance, like
$service->startExam($exam);
or should those methods be used on theExam
instance itself?
- Should it provide exam instances (like a
- Define a basic interface
- What methods are needed?
- What methods are against "YAGNI"?
- What objects should register event listeners (if the event components are used)?
- Build simple implementation of the interface and ensure that all that all events are fired correctly through unit tests with mocked event listeners.
- Eventually proceed with building a schema/entity/document graph compatible with
the concepts of the
Doctrine\Common\Persistence
project (do not keep persistence in mind until interface is done!)