dirname() is a slow function compared with __DIR__ and using
'/../'. Moodle has a large number of legacy files that are included
each time a page loads and is not able to use an autoloader as it is
functional code. This allows those required includes to perform as
best as possible in this situation.
If for any reason the referenced context does not exist any more, the
forms defined in relevant areas are considered removed (even if their
records still exist in the database).
If the target area already contains a form, we can't pick anything to
use there. If the user works in two windows or there are several
teachers modifying the same course, it can happen that the form suddenly
appears in the target area while we have the form picker still open. In
such case, we simply redirects the user to the target area instead of
displaying the pooky exception.