Recently I have started working on enhancing Moodle database module with support for workflow states.
Short-term goal is to enable submission and approval of applications of employees (like vacation/holiday requests, recreation funding, etc.) However, I've found that there was a similar feature considered for Moodle 2.0 - right here - but as it was rejected as potential Google Summer of Code project, it never came to the implementation.
My goal is to create such functionality, and if there's interest I will surely share my implementation in hope to be included in mainline of Moodle codebase.
I already support HelpDesk block for our univeristy installation of Moodle. I've noticed this block also uses statuses and paths (in their terminology) to determine possible status transitions of tickets. Just like workflow states here so I have at least a working reference to build upon.
My current plan is as such:
- Modify existing database schema and enhnance table/columns creation code
- Manually add default workflow(s) and states
- Enhance existing roles/capabilities to distinguish between user types
- Modify code which handles record actions (for example, disable actions in certain states)
- Add code to handle transitions between states
- Add configuration option to enable workflow support for database
- (at this point the feature should be at least usable)
Later on:
- Create workflow editor - either for global workflows, per course, or per database (to be determined)
- i18n - to show names of states and actions in selected language (or at least local rename, like for roles in course)
- Support operations: backup, export, import
Any help / suggestions are welcome.
Best regards,
Wiktor Wandachowicz
Below you can find proposed changes to database structure, as well as example data with workflow and states definitions.
mdl_data
========
Add: workflowenable, workflowid
mdl_data_wf
===========
Table: id, wfname, dataid (global if 'dataid'=>0), initstateid
Ref:
$MOODLE/lib/grade/grade_scale.php
public function fetch_all_global()
public static function fetch_all_local($courseid)
mdl_data_wf_states
==================
Table: id, wfid, statename, statedescr
mdl_data_wf_actions
===================
Table: id, wfid, fromstateid, tostateid, actname, actdescr, (optional: capabilityname)
Example data:
# mdl_data_wf
# -----------
id=1, wfname='Document publishing with review process', dataid=0, initstateid=1
id=2, wfname='Submission and approval of applications', dataid=0, initstateid=5
# mdl_data_wf_states
# ------------------
id=1, wfid=1, statename='Visible', statedescr='Editable by author, visible to reviewer'
id=2, wfid=1, statename='Pending', statedescr='Author requested publishing, non-editable by author'
id=3, wfid=1, statename='Private', statedescr='Only editable by author'
id=4, wfid=1, statename='Published', statedescr='Visible to everybody, non-editable'
id=5, wfid=2, statename='Editing', statedescr='Employee creates/edits application'
id=6, wfid=2, statename='Submitted', statedescr='Application waits for approval, non-editable'
id=7, wfid=2, statename='Approved', statedescr='Application was approved'
id=8, wfid=2, statename='Rejected', statedescr='Application was rejected'
id=9, wfid=2, statename='Retracted', statedescr='Application was retracted for complementing by employee'
id=10, wfid=2, statename='Updating', statedescr='Employee complements/edits retracted application'
id=11, wfid=2, statename='Complemented', statedescr='Application was re-submitted and waits for approval'
id=12, wfid=2, statename='Cancelled', statedescr='Application was withdrawn by employee'
# mdl_data_wf_actions
# -------------------
id=1, wfid=1, fromstateid=1, tostateid=2, actname='Submit', actdescr='Author requests publishing'
id=2, wfid=1, fromstateid=1, tostateid=3, actname='Hide', actdescr='Author makes content private'
id=3, wfid=1, fromstateid=2, tostateid=4, actname='Publish', actdescr='Reviewer publishes content'
id=4, wfid=1, fromstateid=2, tostateid=3, actname='Hide', actdescr='Author makes content private'
id=5, wfid=1, fromstateid=2, tostateid=1, actname='Retract', actdescr='Author retracts submission'
id=6, wfid=1, fromstateid=4, tostateid=1, actname='Retract', actdescr='Reviewer retracts submission'
id=7, wfid=1, fromstateid=3, tostateid=1, actname='Show', actdescr='Author makes content visible'
id=20, wfid=2, fromstateid=5, tostateid=6, actname='Submit', actdescr='Employee submits application for approval'
id=21, wfid=2, fromstateid=6, tostateid=7, actname='Approve', actdescr='Decision-maker approves application'
id=22, wfid=2, fromstateid=6, tostateid=8, actname='Reject', actdescr='Decision-maker rejects application'
id=23, wfid=2, fromstateid=6, tostateid=9, actname='Retract', actdescr='Decision-maker retracts application to be complemented by employee'
id=24, wfid=2, fromstateid=9, tostateid=10, actname='Update', actdescr='Employee complements retracted application'
id=25, wfid=2, fromstateid=10, tostateid=11, actname='Re-submit', actdescr='Employee re-submits complemented application for approval'
id=26, wfid=2, fromstateid=11, tostateid=7, actname='Approve', actdescr='Decision-maker approves complemented application'
id=27, wfid=2, fromstateid=11, tostateid=8, actname='Reject', actdescr='Decision-maker rejects complemented application'
id=28, wfid=2, fromstateid=9, tostateid=12, actname='Cancel', actdescr='Employee withdrawns application'
id=29, wfid=2, fromstateid=10, tostateid=12, actname='Cancel', actdescr='Employee withdrawns application'
id=30, wfid=2, fromstateid=5, tostateid=12, actname='Cancel', actdescr='Employee withdrawns application'
Attached is an image of workflow states for original proposal (Document publishing with review process), as well as states for my intended workflow (Submission and approval of applications).