- all persistent objects inherit from
db_model_base
, this is a small ORM layer that adds methods likecreate
,update
, etc. - all persistent objects have a base class and a 'instance' class. Base classes contain database info
(e.g. column names, table name, etc.), allow creation of new records and contain helper methods.
Instance classes are populated with related data, e.g.
learner_task_submission
instance class will be populated withlearner_attempt
class instances and so on.
- root page (e.g.
view.php
) sets up the page, performs permission checks and initializes any required variables - appropriate
renderer
method is called from the root page (e.g.view.php
callsview_activity
) - renderer method performs more granular permission check and will contain most of the logic (not ideal, but it works)
- renderer method populates template data, usually starting with
export_template_data
method on thetemplateable
interface, any additional data not exported by thetemplateable
interface is appended to the 'extra' array to make it easier to find the data source when working with mustache templates - finally,
render_from_template
is passed template data and result is returned and rendered
Contains methods called by AJAX. These are a major pain in the ass to work with, refer to the almighty moodle documentation
Act as both log entries and event emitters. Careerforce' Marker block depends on these to populate its data.
Avoid altering, creating or deleting columns in this project. If altered, you must update the backup/restore logic too, which is much harder than it seems at first glance. Pay special attention to how files are handled, some corners had to be cut there...
Do not rely on jQuery plugins, they are notoriously difficult to initialize in Moodle. Always write your JS as AMD
modules and don't forget to minify using the built-in grunt task.
Similar rules apply to CSS, write your CSS in ./less/styles.less
and compile using grunt to ./styles.css
for
Moodle to pick up the styles.
Contains helper methods.
Contains scripts that help to get around Moodle's annoying logic, e.g. upgrading the plugin, reinstalling database, etc.