SlideShare a Scribd company logo
Tools and Tips for
Moodle Developers
Dan Poltawski
Integrator
Moodle HQ
@dan_p
the world’s open source learning platform
#mootus16
$CFG->debug = (E_ALL | E_STRICT); // DEBUG_DEVELOPER.
$CFG->debugdisplay = 1; // (unless you tail logs)
$CFG->cachejs = false; // But beware of browser cache!
$CFG->debugstringids = true; // With strings=1 url param.
$CFG->debugusers = ‘2,3,10’; // List of users ids
Debugging: config.php settings
the world’s open source learning platform
// Beginner.
echo "Course ID: $course->id”;
// Intermediate.
print_object($SESSION);
// Advanced.
debugging('a stack trace too!', DEBUG_DEVELOPER);
if ($CFG->debugdeveloper) {
echo '[..] some diagnostic code.';
}
// Wizard.
// (Uses xdebug and variable introspection)
Stages of Moodle printf() debugging (PHP)
the world’s open source learning platform
Stages of Moodle printf() debugging (JS)
// Beginner:
alert('courseid is: ' + course.id);
// Intermediate:
console.dir(course);
// Advanced:
Y.log('Info example in YUI module', 'info');
define(['core/log'], function(log) {
log.info('Info example from AMD Module.');
});
// Wizard:
// (uses web inspector, variable introspection)
the world’s open source learning platform
Performance debugging
the world’s open source learning platform
$CFG->perfdebug = 15; // First step.
xhprof
the world’s open source learning platform
xhprof
the world’s open source learning platform
the world’s open source learning platform
PHPUnit
Useful CLI Options
Filtering
vendor/bin/phpunit --filter block_online_users
vendor/bin/phpunit --testsuite block_online_users_testsuite
vendor/bin/phpunit blocks/online_users/tests/online_users_test.php
Coverage
vendor/bin/phpunit --coverage-html=coverage --filter block_online_users
PHPUnit
Test authoring tips:
• Use most specific assertion possible
• Make use of @dataProvider to
reduce duplication and get better
errors
• Remember we have data generators
to simplify setup code
/**
* Data provider for test_get_real_size().
*
* @return array An array of arrays contain test data
*/
public function data_for_test_get_real_size() {
return array(
array('8KB', 8192),
array('8G', 8589934592),
);
}
/**
* @dataProvider data_for_test_get_real_size
*/
public function test_get_real_size($input, $expectedbytes) {
$this->assertEquals($expectedbytes,get_real_size($input));
}
There was 1 failure:
1) core_setuplib_testcase::test_get_real_size with data set #0
('8KB', 8193)
Failed asserting that 8192 matches expected 8193.
the world’s open source learning platform
Behat
Useful CLI Options:
Filtering
—tags @block_online_users
—name “Add the online users on course
page and see other logged in users”
Rerun
—rerun
Profiles
—profile chrome
$CFG->behat_profiles = array(
'phantomjs' => array(
'browser' => ‘chrome’,
'wd_host' => ‘http://10.0.0.3:4444/wd/hub',
));
the world’s open source learning platform
Behat
Tips:
• Solutions for headless running:
• All platforms: Phantom JS
• Linux: Xvfb - X virtual framebuffer
• Mac: Fast user switching - with background user
• $x() in web developer console extremely useful for constructing
XPath queries
the world’s open source learning platform
Grunt
• grunt
• grunt watch
• grunt css
• grunt js
• grunt amd
• grunt yui
the world’s open source learning platform
• Analysing code for potential errors
• Good feedback loop
• Ensure consistency
• Integrate with your development workflow FTW!
Code Linting
the world’s open source learning platform
• Code-checker (local_codechecker)
• Available from Plugins Directory
• Uses PHP Code-sniffer underneath
• Integrations configured with path to local_codechecker/moodle/
location
Moodle Code Linters: PHP
the world’s open source learning platform
• ESLint
• New in Moodle 3.2 (MDL-52127), replaced jshint
• grunt js: checks for errors on AMD modules and YUI modules
• Integrations usually work without configuration ( eslintrc bundled)
Moodle Code Linters: Javascript
the world’s open source learning platform
• Packages: linter
• linter-phpcs
• linter-eslint
• Config:
"linter-phpcs":
codeStandardOrConfigFile: “/path/to/moodle-
Lint in your editor: Atom
the world’s open source learning platform
• Package: syntastic
• vimrc:
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_php_checkers = ['php', 'phpcs']
let g:syntastic_php_phpcs_args='--standard="/
path/to/moodle-local_codechecker/moodle/"'
Lint in your editor: vim
the world’s open source learning platform
Lint in your editor: PHPStorm
Configured in Editor > Inspections:
• PHP > PHP Code SnifferValidation
• Select ‘Custom’ coding standard and
choose path to local_codechecker/
moodle/
• Javascript > Code Quality Tools >
ESLint
the world’s open source learning platform
• SublimeLinter
• SublimeLinter-phpcs
• SublimeLinter-contrib-eslint
Sublime
"linters": {
"eslint": {
"@disable": false,
"args": [],
"excludes": []
},
"phpcs": {
"@disable": false,
"args": [],
"excludes": [],
"standard": “/path/to/moodle-local_codechecker/moodle/"
}}the world’s open source learning platform
Lint in your editor….
I’m sure their is an emacs integration too 🙄😘
the world’s open source learning platform
the world’s open source learning platform
“The goal of this project is to facilitate the running of
tests and code analysis tools against a Moodle plugin in
Travis CI.”
• https://github.com/moodlerooms/moodle-plugin-ci
• Created by Mark Nielsen (Moodlerooms)
• Extremely simple and comprehensive way to add CI to
your plugin
moodle-plugin-ci
the world’s open source learning platform
moodle-plugin-ci
the world’s open source learning platform
“A collection of tools meant to make developers' lives easier.”
• https://github.com/FMCorz/mdk
• Created by Frédéric Massart (Moodle HQ)
• Python tools - works with Linux and Mac
• (Windows patches welcomed!)
• Developed for core development tasks, but useful for non-core
work too
Moodle Development Kit (mdk)
• mdk create
• mdk upgrade
• mdk install
• mdk run
• mdk remove
MDK: Instance management
the world’s open source learning platform
• mdk phpunit
• init
• mdk behat
• init
• fail dumps
• seleneium server start
MDK: Testing
the world’s open source learning platform
• mdk fix
• mdk pull
• mdk push
MDK: Fixing issues
the world’s open source learning platform
• mdk fix
• mdk pull
• mdk push
MDK: Fixing continued
the world’s open source learning platform
the world’s open source learning platform
Email testing: config options
// Disable all Email.
$CFG->noemailever = true;
// Divert all outgoing emails to this address to test and debug emailing features
$CFG->divertallemailsto = 'youremail@example.com';
// Except for certain email addresses you want to let through for testing. Accepts
// a comma separated list of regexes.
$CFG->divertallemailsexcept = 'tester@dev.com, fred(+.*)?@example.com';
Email testing: mailcatcher
$CFG->smtphosts = 'localhost:1025';
$ gem install mailcatcher
$ mailcatcher
Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080
*** MailCatcher runs as a daemon by default.
Go to the web interface to quit.
the world’s open source learning platform
the world’s open source learning platform
Accessibility testing
• ChromeVox
• Chrome Extension - Quick and straight forward to get started
• Not JAWS but better than nothing
• Accessibility Developer Tools - Accessibility audit useful
git
• git log
• git blame
• git bisect
• https://github.com/dmonllao/who-broke-it
• git log --author=Damyon --grep="services"
the world’s open source learning platform
Questions?
@dan_p
the world’s open source learning platform

More Related Content

What's hot

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
Dinh Pham
 
Building Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI FrameworkBuilding Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI Framework
Charles Severance
 
Introduction to building joomla! components using FOF
Introduction to building joomla! components using FOFIntroduction to building joomla! components using FOF
Introduction to building joomla! components using FOFTim Plummer
 
Django
DjangoDjango
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
Edureka!
 
Tsugi Workshop @ Notre Dame
Tsugi Workshop @ Notre DameTsugi Workshop @ Notre Dame
Tsugi Workshop @ Notre Dame
Charles Severance
 
How Browser Works?
How Browser Works?How Browser Works?
How Browser Works?
Vova Voyevidka
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
Joram Salinas
 
Drupal debugging tips
Drupal debugging tipsDrupal debugging tips
Drupal debugging tipsAdolfo Nasol
 
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Mark Hamstra
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Mark Hamstra
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
mohamedsamirgalal
 
Django Documentation
Django DocumentationDjango Documentation
Django Documentation
Ying wei (Joe) Chou
 
MozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: TaipeiMozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: Taipeilittlebtc
 
Updated Version: Tsugi Overview
Updated Version: Tsugi OverviewUpdated Version: Tsugi Overview
Updated Version: Tsugi Overview
Charles Severance
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
Pavan Kumar N
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
sparkfabrik
 
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Mark Hamstra
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP TestingRan Mizrahi
 

What's hot (20)

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
 
Building Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI FrameworkBuilding Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI Framework
 
Introduction to building joomla! components using FOF
Introduction to building joomla! components using FOFIntroduction to building joomla! components using FOF
Introduction to building joomla! components using FOF
 
Django
DjangoDjango
Django
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
Bootstrap4 x pages
Bootstrap4 x pagesBootstrap4 x pages
Bootstrap4 x pages
 
Tsugi Workshop @ Notre Dame
Tsugi Workshop @ Notre DameTsugi Workshop @ Notre Dame
Tsugi Workshop @ Notre Dame
 
How Browser Works?
How Browser Works?How Browser Works?
How Browser Works?
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Drupal debugging tips
Drupal debugging tipsDrupal debugging tips
Drupal debugging tips
 
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
 
Django Documentation
Django DocumentationDjango Documentation
Django Documentation
 
MozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: TaipeiMozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: Taipei
 
Updated Version: Tsugi Overview
Updated Version: Tsugi OverviewUpdated Version: Tsugi Overview
Updated Version: Tsugi Overview
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 

Viewers also liked

How integrators bring you a better Moodle
How integrators bring you a better MoodleHow integrators bring you a better Moodle
How integrators bring you a better MoodleDan Poltawski
 
Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16
Dan Poltawski
 
Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle
Dan Poltawski
 
Testing Moodle functionality automatically
Testing Moodle functionality automaticallyTesting Moodle functionality automatically
Testing Moodle functionality automatically
David Monllaó
 
Moodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party BarcelonaMoodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party Barcelona
Pau Ferrer Ocaña
 
Building a Moodle theme with bootstrap
Building a Moodle theme with bootstrapBuilding a Moodle theme with bootstrap
Building a Moodle theme with bootstrap
Bas Brands
 
A basic introduction to the Moodle architecture
A basic introduction to the Moodle architectureA basic introduction to the Moodle architecture
A basic introduction to the Moodle architecture
Tim Hunt
 
What is Moodle explained with Lego
What is Moodle explained with LegoWhat is Moodle explained with Lego
What is Moodle explained with Lego
Tomaz Lasic
 

Viewers also liked (8)

How integrators bring you a better Moodle
How integrators bring you a better MoodleHow integrators bring you a better Moodle
How integrators bring you a better Moodle
 
Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16
 
Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle
 
Testing Moodle functionality automatically
Testing Moodle functionality automaticallyTesting Moodle functionality automatically
Testing Moodle functionality automatically
 
Moodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party BarcelonaMoodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party Barcelona
 
Building a Moodle theme with bootstrap
Building a Moodle theme with bootstrapBuilding a Moodle theme with bootstrap
Building a Moodle theme with bootstrap
 
A basic introduction to the Moodle architecture
A basic introduction to the Moodle architectureA basic introduction to the Moodle architecture
A basic introduction to the Moodle architecture
 
What is Moodle explained with Lego
What is Moodle explained with LegoWhat is Moodle explained with Lego
What is Moodle explained with Lego
 

Similar to Tools and Tips for Moodle Developers - #mootus16

modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
Chris Cowan
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
Michelangelo van Dam
 
Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI
Ortus Solutions, Corp
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
chartjes
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
lutter
 
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxOrdering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
hopeaustin33688
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
Joe Stein
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodesnihiliad
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
Mikel Torres Ugarte
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebookguoqing75
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
Gordon Forsythe
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
Pavel Makhrinsky
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011camp_drupal_ua
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 

Similar to Tools and Tips for Moodle Developers - #mootus16 (20)

modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxOrdering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodes
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 

Recently uploaded

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

Tools and Tips for Moodle Developers - #mootus16

  • 1. Tools and Tips for Moodle Developers Dan Poltawski Integrator Moodle HQ @dan_p the world’s open source learning platform #mootus16
  • 2. $CFG->debug = (E_ALL | E_STRICT); // DEBUG_DEVELOPER. $CFG->debugdisplay = 1; // (unless you tail logs) $CFG->cachejs = false; // But beware of browser cache! $CFG->debugstringids = true; // With strings=1 url param. $CFG->debugusers = ‘2,3,10’; // List of users ids Debugging: config.php settings the world’s open source learning platform
  • 3. // Beginner. echo "Course ID: $course->id”; // Intermediate. print_object($SESSION); // Advanced. debugging('a stack trace too!', DEBUG_DEVELOPER); if ($CFG->debugdeveloper) { echo '[..] some diagnostic code.'; } // Wizard. // (Uses xdebug and variable introspection) Stages of Moodle printf() debugging (PHP) the world’s open source learning platform
  • 4. Stages of Moodle printf() debugging (JS) // Beginner: alert('courseid is: ' + course.id); // Intermediate: console.dir(course); // Advanced: Y.log('Info example in YUI module', 'info'); define(['core/log'], function(log) { log.info('Info example from AMD Module.'); }); // Wizard: // (uses web inspector, variable introspection) the world’s open source learning platform
  • 5. Performance debugging the world’s open source learning platform $CFG->perfdebug = 15; // First step.
  • 6. xhprof the world’s open source learning platform
  • 7. xhprof the world’s open source learning platform
  • 8. the world’s open source learning platform PHPUnit Useful CLI Options Filtering vendor/bin/phpunit --filter block_online_users vendor/bin/phpunit --testsuite block_online_users_testsuite vendor/bin/phpunit blocks/online_users/tests/online_users_test.php Coverage vendor/bin/phpunit --coverage-html=coverage --filter block_online_users
  • 9. PHPUnit Test authoring tips: • Use most specific assertion possible • Make use of @dataProvider to reduce duplication and get better errors • Remember we have data generators to simplify setup code /** * Data provider for test_get_real_size(). * * @return array An array of arrays contain test data */ public function data_for_test_get_real_size() { return array( array('8KB', 8192), array('8G', 8589934592), ); } /** * @dataProvider data_for_test_get_real_size */ public function test_get_real_size($input, $expectedbytes) { $this->assertEquals($expectedbytes,get_real_size($input)); } There was 1 failure: 1) core_setuplib_testcase::test_get_real_size with data set #0 ('8KB', 8193) Failed asserting that 8192 matches expected 8193. the world’s open source learning platform
  • 10. Behat Useful CLI Options: Filtering —tags @block_online_users —name “Add the online users on course page and see other logged in users” Rerun —rerun Profiles —profile chrome $CFG->behat_profiles = array( 'phantomjs' => array( 'browser' => ‘chrome’, 'wd_host' => ‘http://10.0.0.3:4444/wd/hub', )); the world’s open source learning platform
  • 11. Behat Tips: • Solutions for headless running: • All platforms: Phantom JS • Linux: Xvfb - X virtual framebuffer • Mac: Fast user switching - with background user • $x() in web developer console extremely useful for constructing XPath queries the world’s open source learning platform
  • 12. Grunt • grunt • grunt watch • grunt css • grunt js • grunt amd • grunt yui the world’s open source learning platform
  • 13. • Analysing code for potential errors • Good feedback loop • Ensure consistency • Integrate with your development workflow FTW! Code Linting the world’s open source learning platform
  • 14. • Code-checker (local_codechecker) • Available from Plugins Directory • Uses PHP Code-sniffer underneath • Integrations configured with path to local_codechecker/moodle/ location Moodle Code Linters: PHP the world’s open source learning platform
  • 15. • ESLint • New in Moodle 3.2 (MDL-52127), replaced jshint • grunt js: checks for errors on AMD modules and YUI modules • Integrations usually work without configuration ( eslintrc bundled) Moodle Code Linters: Javascript the world’s open source learning platform
  • 16. • Packages: linter • linter-phpcs • linter-eslint • Config: "linter-phpcs": codeStandardOrConfigFile: “/path/to/moodle- Lint in your editor: Atom the world’s open source learning platform
  • 17. • Package: syntastic • vimrc: let g:syntastic_javascript_checkers = ['eslint'] let g:syntastic_php_checkers = ['php', 'phpcs'] let g:syntastic_php_phpcs_args='--standard="/ path/to/moodle-local_codechecker/moodle/"' Lint in your editor: vim the world’s open source learning platform
  • 18. Lint in your editor: PHPStorm Configured in Editor > Inspections: • PHP > PHP Code SnifferValidation • Select ‘Custom’ coding standard and choose path to local_codechecker/ moodle/ • Javascript > Code Quality Tools > ESLint the world’s open source learning platform
  • 19. • SublimeLinter • SublimeLinter-phpcs • SublimeLinter-contrib-eslint Sublime "linters": { "eslint": { "@disable": false, "args": [], "excludes": [] }, "phpcs": { "@disable": false, "args": [], "excludes": [], "standard": “/path/to/moodle-local_codechecker/moodle/" }}the world’s open source learning platform
  • 20. Lint in your editor…. I’m sure their is an emacs integration too 🙄😘 the world’s open source learning platform
  • 21. the world’s open source learning platform “The goal of this project is to facilitate the running of tests and code analysis tools against a Moodle plugin in Travis CI.” • https://github.com/moodlerooms/moodle-plugin-ci • Created by Mark Nielsen (Moodlerooms) • Extremely simple and comprehensive way to add CI to your plugin moodle-plugin-ci
  • 22. the world’s open source learning platform moodle-plugin-ci
  • 23. the world’s open source learning platform “A collection of tools meant to make developers' lives easier.” • https://github.com/FMCorz/mdk • Created by Frédéric Massart (Moodle HQ) • Python tools - works with Linux and Mac • (Windows patches welcomed!) • Developed for core development tasks, but useful for non-core work too Moodle Development Kit (mdk)
  • 24. • mdk create • mdk upgrade • mdk install • mdk run • mdk remove MDK: Instance management the world’s open source learning platform
  • 25. • mdk phpunit • init • mdk behat • init • fail dumps • seleneium server start MDK: Testing the world’s open source learning platform
  • 26. • mdk fix • mdk pull • mdk push MDK: Fixing issues the world’s open source learning platform
  • 27. • mdk fix • mdk pull • mdk push MDK: Fixing continued the world’s open source learning platform
  • 28. the world’s open source learning platform Email testing: config options // Disable all Email. $CFG->noemailever = true; // Divert all outgoing emails to this address to test and debug emailing features $CFG->divertallemailsto = 'youremail@example.com'; // Except for certain email addresses you want to let through for testing. Accepts // a comma separated list of regexes. $CFG->divertallemailsexcept = 'tester@dev.com, fred(+.*)?@example.com';
  • 29. Email testing: mailcatcher $CFG->smtphosts = 'localhost:1025'; $ gem install mailcatcher $ mailcatcher Starting MailCatcher ==> smtp://127.0.0.1:1025 ==> http://127.0.0.1:1080 *** MailCatcher runs as a daemon by default. Go to the web interface to quit. the world’s open source learning platform
  • 30. the world’s open source learning platform Accessibility testing • ChromeVox • Chrome Extension - Quick and straight forward to get started • Not JAWS but better than nothing • Accessibility Developer Tools - Accessibility audit useful
  • 31. git • git log • git blame • git bisect • https://github.com/dmonllao/who-broke-it • git log --author=Damyon --grep="services" the world’s open source learning platform
  • 32. Questions? @dan_p the world’s open source learning platform