Workflow block

Blocks ::: block_workflow
Maintained by Tim at Lone Pine Koala SanctuaryTim Hunt
This block allows you to manage the process of producing courses or activities. A workflow make it clear who is responsible for doing the next step, and what tasks they should be doing. The workflow can also assign and unassign roles, or automatically set certain settings, when the workflow moves from one step to the next.
Latest release:
420 sites
66 fans

The Workflow system is used at the OU to manage the production of courses and some activities. It comprises a block and a related admin report.

A workflow (for our purposes) is a linear sequence of steps. A step has

  • a name
  • some instructions;
  • a check-list of actions;
  • a list of roles who are responsible for performing this step;
  • a list of actions that are taken automatically when the step is started/finished, for example assigning roles or changing activity settings.

The system allows the definition of different workflows. Each workflow has

  • a name
  • a description
  • an indication of the type of thing it relates to (e.g. ‘course’, ‘mod_quiz’)

Under Admin -> Plugins -> Blocks -> Workflow, there is an interface for Administrators to define and edit workflows, and to import and export workflow definitions as XML.

To use a workflow to manage the production of, say, a course, you go to the course, and add a workflow block to it. Initially, the block will display a message “There is currently no workflow associated with this course.” with an Add workflow button. Clicking the button allows you to select from any of the workflows that are appropriate for ‘course’.

When the workflow is added to the course, the first step in the workflow becomes active. The workflow block now displays the step instructions for the currently active step; the checklist items as a list of check-boxes; a comments area; a Finish step button; and a link to the workflow overview.

When a step becomes active, all the people responsible for completing the step are sent an email informing them that they should do the step. These people may also get an additional role assigned to them in the context the workflow applies to.

The comments area in the workflow block is a simple editable text area where people working on the step can leave notes for each other.

The Finish step button leads to a confirmation page. If the action is confirmed, then the workflow advances to the next step. When the last step of the workflow is finished, the workflow either stops, or loops back to one of the other steps.

The workflow overview gives an overview of all the steps in this workflow, and the progress through it. The system tracks the timestamp, and the user, each time a step is finished or made active.

The overview page also allows workflow administrators (those with an appropriate capability) to jump the workflow to any particular step.

There is also an admin reports that summarise the workflow across a selection of courses or activities.


Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4


Tim at Lone Pine Koala Sanctuary
Tim Hunt (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Fri, Apr 21, 2017, 1:09 AM
    This is what I was hoping to hear! It seems you attach an instance of a workflow to an activity via context id. From there you can simply load the workflow and step through it at will, right?
  • Wed, May 10, 2017, 5:57 AM
    So, for those following or looking for a way to use workflow block outside the block itself, seems you can pass any old number to $workflow->add_to_context($contextid); where contextid is literally any unique number. I'm hoping it works out in the long run. I got stuck for the longest time trying to get a course_module context for an activity object NOT attached to a particular course. I ended up using the unique id of the activity itself as the $contextid.
  • Wed, Jun 28, 2017, 5:51 AM
    Tim, have you thought about altering the workflow engine so that it's able to support multiple branches? It's currently really linear but I think with a few tweaks it could be made to branch and work quite nicely for literally any workflow need in Moodle.
  • Coolie and Andrew
    Mon, Feb 5, 2018, 10:43 AM
    Please note that you MUST NOT use 'any unique number' for the contextid when calling $workflow->add_to_context($contextid);.
    Contexts are used throughout Moodle and have meaning.
    The contextid is what ties the instance of the workflow block to some content - i.e. a course, category, activity, block, etc.
    If you do this, then you may find that you shoot yourself in the foot should you add the block to different places in the future and that location is one of the 'unique' numbers you've chosen.
  • Wed, Feb 21, 2018, 4:47 PM
    I am using moodle 3.2, I have installed workflow block and after adding this block on course I am not getting add workflow button option.
    Please help in this issue, It's URGENT.
    Thanks in advance.
  • Tim at Lone Pine Koala Sanctuary
    Wed, Feb 21, 2018, 6:15 PM
    What exactly have you tried? As a test, can you add a standard HTML block? (Adding the workflow block is similar.)
  • Wed, Feb 21, 2018, 7:10 PM
    Hi Tim,
    Thank you for your reply in such short time.
    I got my mistake. But now I am facing another problem that is:
    The steps defined in the workflow should be performed by the roles assigned to that particular step. But when I defined two steps with different roles both roles can perform both the steps which is not as expected. Kindly guide for the same.
  • Tim at Lone Pine Koala Sanctuary
    Wed, Feb 21, 2018, 8:56 PM
    What do you mean "can perform both the steps"? Do you mean "can see and click the Finish step button?"

    The way it works is a little bit complicated. Users will see the button if EITHER they have 'block/workflow:dostep' capability, or if they have one of the step roles.

    So, perhaps you need to change the role definitions, so that the users do not have block/workflow:dostep?
  • Fri, Feb 23, 2018, 2:28 PM
    I have created a workflow for 2 roles:
    Role1- Instructor
    Role2- Trainer
    Workflow has 2 steps, Step-1 should be performed by Trainer and Step-2 should be performed by Instructor.
    Hence step-1 should be visible only to Trainer while step-2 should be visible to Instructor , however step 1 is also visible to Instructor and even he can perform this step which is not desirable... Kindly help me with this issue.

    I have another question that is :
    Is there any restriction that at a time only 1 workflow can be added on any course?

    Thanks in advance
  • Tim at Lone Pine Koala Sanctuary
    Fri, Mar 2, 2018, 9:32 PM
    Part of the point of the workflow block is to co-ordinate work between different people. Therefore, it is a feature that everyone (with the right capability) can see what the current step is. You should word the instructions so it is clear who is responsible for doing what.

    If you really want it to work differently, you could probably do it using the 'When step starts' script to assign a role that Prevents some of the workflow capabilities, to hide the block from people who are not supposed to do this step.

    There is a restriction that you can only have one workflow in each context. Therefore, you can have one workflow for each activity, as well as one for the course. Not sure if that helps.
  • CaveMan with LapTop
    Sat, Jan 9, 2021, 5:39 PM
    Hi Tim,
    There is a lang string named invalidemailemail that says: "An invalid email email was specified. The email specified was '{$a}'"
    I am trying to translate it to greek.
    Could it be changed to
    "Invalid email specified: '{$a}'" or
    "Invalid email: '{$a}'" or
    "'{$a}' is not a valid email"
    Or does it mean something else?
    Thank you
  • Tim at Lone Pine Koala Sanctuary
    Mon, Jan 11, 2021, 10:15 PM
    A better string would be: "The email template {$a} does not exist.". Thank you for pointing this out.
  • Mon, Feb 22, 2021, 2:40 AM
    Hi Tim,
    is there any plans to support MS SQL as when I tried the block with MS SQL Server I got the below error when I tried to create a new Workflow
    Error Code: 102
    Message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near 'LIMIT'.

    SELECT stepno FROM mdl_block_workflow_steps WHERE workflowid = '2' ORDER BY stepno DESC LIMIT 1
    -- line 900 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()
    -- line 976 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql()
    -- line 1671 of \lib\dml\moodle_database.php: call to sqlsrv_native_moodle_database->get_records_sql()
    -- line 285 of \blocks\workflow\classes\workflow.php: call to block_workflow_step->create_step()
    -- line 107 of \blocks\workflow\editsettings.php: call to block_workflow_workflow->create_workflow()
    [array (
    0 => 2,
    Error code: dmlreadexception
  • Sun, Apr 4, 2021, 2:49 PM
    Hi Tim
    Thank you for this plugin, would really appreciate help on a specific issue. Am running on version 3.9, there is no problem linking an e-mail template at course level and mail is successfully sent on step completion. At activity level (using quizz activity) the identical e-mail template does not send to the relevant e mail addresses. Any pointers would be welcome.
  • Tim at Lone Pine Koala Sanctuary
    Tue, Apr 6, 2021, 5:25 PM
    Check the output from cron, to see if any errors are being reported.

    We user quiz workflows which send emails, and it works for us. So, it can work. There must be something about how your particlar workflow is set up which is causing problems, and you need to find what that is.
1 2 3 4
Please login to post comments