Lesson 4.2: Developers, practical task
The task is a small, complete extension: a page that greets a visitor, protected by a policy, with its own template, and kept in Git with correct metadata. It covers the developer's daily loop: write, check, activate, clear, test.
Note
This is the trainer's own assessment, not an official certification. Each learner works on their own training installation (a Git clone, as in the Developers course). Nothing is pushed anywhere and no tag is made: a pushed tag is permanent.
At a glance
| Course | Assessments and practical exercises |
| Module | Module 4: Assessing the technical courses |
| Duration | 105 minutes (5 briefing, 75 task, 25 scoring) |
| Level | Intermediate to advanced |
| Audience | Learners at the end of the Developers course |
| Prerequisites | Lesson 4.1; a shell, an editor and Git on the learner's own training installation |
Learning objectives
Learners who pass this task have shown that they can:
- write an extension with metadata, settings, a module, a view and a template;
- protect a view with a function and grant it with a role;
- activate the extension and make the system see it (autoloads, caches);
- write a template override for one object and check template syntax;
- keep the work in Git with consistent version fields.
Trainer's notes
How to run it
- Before: each learner has a training installation from a Git clone, served on a local port, signed in as administrator, and a terminal. The guide Extensions, section 6.1 may be open: it shows a similar but simpler extension.
- Briefing: hand out the steps and the rubric; 75 minutes. Learners name the extension
<account>greet(lower case, letters, digits and underscores). - Scoring: read the files, run
php -lon them, open the page in a private window and as the test user, and readgit login the extension.
Common questions
May learners copy the guide's code? Yes, and adapt it: the task differs (a policy, an override, Git). Copying without adapting fails steps 4 and 6.
The page is empty after activation. A new template needs the caches cleared; see Extensions, section 8. That is part of the task.
Pitfalls
- Velocity workers. If the site runs on Velocity, new classes and settings need a restart or deploy; tell learners which server their lab uses.
- A shared installation. Two learners activating extensions on one installation get in each other's way. One installation per learner.
Hands-on exercise
The task, as handed to learners. Work in the installation root of your own training installation.
- Create
extension/<account>greet/withezinfo.phpandextension.xml, both with version0.1.0, your name in the copyright line, and the license "GNU General Public License v2.0 (or any later version)". - Add
settings/module.ini.append.phpandsettings/design.ini.append.phpso the kernel finds your module and your design. - Write a module
greetwith a viewhellothat takes a parameterNameand shows it through the templatedesign/standard/templates/greet/hello.tpl. Print the name with|wash. - Protect the view: declare a function
readinmodule.phpand require it on the view. - Check every PHP file with
php -l, and the template withphp bin/php/eztemplatecheck.php -s<public siteaccess> <path to hello.tpl> --allow-root-user. - Activate the extension (browser or
exp:ini add), regenerate the autoloads and clear the caches. Reload the server process if your lab needs it. - Open
/greet/hello/Adain a private window as an anonymous visitor. Note what you see. - Create a role
Greet readerswith the policygreetread, assign it to the Anonymous Users group, and open the page again. Note what you see. Then try/greet/hello/<script>alert(1)</script>and note what the page prints. - Write an override for one article of the site (by object id) of
node/view/full.tplin your extension's design that adds a lineOverride from <account>greetabove the content. Add the rule in your extension'ssettings/override.ini.append.php, clear the override and template caches, and check the article. - In
extension/<account>greet/, rungit init, add your files and commit with the messageAdded: Greeting page with access control. - Raise the version to
0.1.1in bothezinfo.phpandextension.xml, check both files, and commit withUpdated: Version 0.1.1. Do not tag and do not push.
Expected result
- Step 7: access is refused for the anonymous visitor. Step 8: the page shows Hello, Ada; the script text is shown as text, not run.
- The article shows the override line; the other articles do not.
php -lreports no syntax errors;eztemplatecheck.phpreports the template valid.- Setup > Extensions lists the extension with version 0.1.1 after a cache clear.
git logshows two commits with the two messages; both version fields say0.1.1; no tag exists.
Scoring rubric
| Criterion | 0: Not shown | 1: Partly | 2: Mostly | 3: Fully | Evidence |
|---|---|---|---|---|---|
| Extension structure and metadata | Missing files | Files present, metadata inconsistent | Consistent, license or copyright missing | Both files consistent and complete | The files |
| Module, view and template | Page does not work | Page works without the parameter | Works, name not washed | Works, name washed | /greet/hello/Ada and the script test |
| Access control (must) | View unprotected | Function declared, not required | Required, role not created or misassigned | Refused before, allowed after the role | Steps 7 and 8, the role page |
| Activation and checks | Not activated | Activated, caches or autoloads skipped | Working, checks not run | Activated, php -l and template check clean | Terminal history, Setup > Extensions |
| Override | None | File without rule, or rule without file | Works, but on every article | Works for the one object only | The article and another article |
| Git and versions | No repository | One commit, message without prefix | Two commits, versions disagree | Two commits with prefixes, both fields 0.1.1, no tag | git log, the files |
Pass: 12 of 18 points or more and Access control at 2 or 3.
Quiz
Debrief questions to ask after scoring.
- Why did step 7 refuse access, and what would have happened without step 4?
- What did
|washdo in the script test? - Why are you told not to tag in this task?
- Your override shows on every article. What is wrong in the rule?
Answers
- The view requires the function
readand no role granted it; without it anyone could open the view (Extensions). - It escaped the HTML, so the script was printed as text (Templates and design).
- A pushed tag is permanent; releases are chosen from what is published and tagged after the version commit (Extensions).
- The
Match[object]condition is missing or wrong (Templates and design).
Further reading
- Extensions: the smallest extension, activation, release.
- Templates and design: overrides and template checks.
- Develop with Git: everyday work with clones.
Related pages
- Lesson 4.1: Developers, written test
- Module 4: Assessing the technical courses
- Assessments and practical exercises: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.