Workflow support

Workflow support

by David Mudrák -
Number of replies: 19
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi,

this is initial proposal of a new feature that I'd like to implement into the Database module. Please add your ideas, comments, contra-proposals etc.

Database module - workflow support (draft)

The goal of the feature is the ability to control the state of a database record, permissions at different state levels and email notifications.

Examples (use cases)
  • when student adds a new record, it is waiting to be approved by a teacher. The teacher can either approve or discard the record.
  • a student starts to work on a database record. During the work, only he/she as the author has access to it. After some time, he/she decides to make it available to his classmates (eg group members) for review and/or clean-up, modification etc. When the review is done, the author can push the record into the final state, it is made public to all course participants and can not be edited any more
  • simple issue tracker - every site user can create a new issue. IT staff members can accept it and then close it once it is solved. The reporter receives email notifications about the progress
Implementation proposal

(inspired by Zope/Plone workflow machinery)
  • new tab called Workflow appears in the module UI. The workflow handling is an optional feature of the database module instance.
  • teacher (ie a user role with a capability to setup workflow) defines a set of states the records can be in. Eg private, draft, pending, published
  • teacher (or other workflow manager) defines actions. The action is directed path from one state to another. Eg publish as draft, submit to review, approve, decline, publish
  • there are permissions defined for every state and every action. The author of the record can always view it. All other permissions must be granted explicitely. Eg role Student can create new records. Student can publish a record as a draft. Student can submit a record to review. Role Teacher can approve pending records (ie make them published) or decline them (ie make them drafts again). Role Student can see all record in state published. Etc etc...
  • email notifications can be sent when the state of the record changes (ie an action is performed)
Workflow can be very well described in UML diagrams notation. It would be nice to import the workflow from the UML directly, like Plone Archetypes can do (eg. diagrams made in ArgoUML and similar tools).
Average of ratings: Useful (1)
In reply to David Mudrák

Re: Workflow support

by akshit sharma -
I have just gone through this proposal. I have also seen and studied Plone Workflow tool (DCWorkflow - By Zope Corp.). Let me take this chance to describe how DCWorkflow works, so that other can have an idea as to what to expect from this project and contribute with their ideas and suggestions :-
  1. Workflow is a chain of "actions" that occours on a "content type" to achieve an objective by transiting over "states".
  2. Plone has two workflows build into it - folder workflow and default workflow.
  3. These workflows can be applied to various content types - for e.g.,
  • Discussion item
  • Document
  • Events
  • Files/Folders etc.
Each workflow has predefined states. For e.g., default workflow has following states :-
  1. Pending,
  2. Private,
  3. Published,
  4. Visible
There is an initial state. For e.g., default workflow has Visible as the initial state.
Each workflow has predefined actions (or transitions). These actions take the subject from one state to another. For e.g., default workflow has following actions associated with it :-
  1. Submit,
  2. Hide,
  3. Show,
  4. Publish,
  5. Retract (Undo Publish and/or Submit)
These actions take the workflow from one state to another.
  1. Submit: Visible -> Pending
  2. Publish: Pending -> Published
  3. Hide: Visible/Pending -> Private
  4. Show: Private -> Visible
  5. Retract: Pending/Published -> Visible
There is a permission hierarchy for the content type (for which workflow is applied). For e.g., "Edit" > "View" are two permissions in decreasing hierarchy. "Edit" permission implies "View" permission.
Each state has predefined permissions for each type of users. For e.g. there can be a administrator ("Admin") and a normal user ("User"), for the default workflow :-
  1. In Pending state, the "Admin" can "Edit" the document, but the "User" can only "View" the document.
  2. In Private state, the "Admin" can only "View" the document, but the "User" has no permissions on the document.
  3. In "Published" and "Visible" states, both the "Admin" and "User" have only the "View" permission over the document.
Plone allows the users to create their own workflows.
States can be added, initial state can be changed, and actions can be modified to existing workflows. Newly created workflows can be also assigned to various content-types.

Creating a workflow module as specified above is obviously beyond the scope of a SoC project. We can however, create a workflow module with :-
  • Fixed content type
  • Pre-defined workflows.
There are a few doubts I have, regarding these specific details. I would be really grateful if you could answer a few queries.
  1. From what I understand, this project aims to apply a workflow to database record. What exactly is a "database record". I have outlined various content types above, but how is database record related to any of this. In the examples, you have mentioned "when student adds a new record", so it appears that database record is a content-type. Please elaborate on this.
  2. Assuming that by database record, you don't intend to generalize a lot of content-types, do you plan to allow the user to apply a workflow to any content-type, or just the "database record".
  3. Do you plan to provide users with the ability to create their own workflows ?? Or do we provide a few basic (or just one default) pre-defined workflows only and not the ability to create more workflows.
  • My suggestion is that if content types are limited, then it makes sense to only provide few basic pre-defined workflows which can be thought of logically.
  • For each workflow that user has created (assuming we are letting them), user will have to define :-
    • states
    • transitions
    • transition rules
    • initial state
    • permission to each type of user on content-type in each state
  • This is too much pain for the user, and in an environment like Moodle, we can easily think of different content-types, and various workflows that a user may want to associate the content-type with.

Assuming that we are not letting a user create forkflows, we can (maybe) provide an inteface where a user can Export workflow. Note we allow him to "export" and not "create". The possibility of this aspect depends if there is a standard way workflows can be represented. Can you help me a bit in this direction ?? Or we can investigate this facility later.
I am highly interested in this project. And I have experience with Moodle previously. I know it is a bit late, but I would be grateful, if you can help me with these queries, so that I can create and submit a proposal.

Thanks,
Akshit Sharma

In reply to akshit sharma

Re: Workflow support

by akshit sharma -
A more detailed description of the proposal is provided at http://docs.moodle.org/en/Student_projects/Workflow_Support
In reply to akshit sharma

Re: Workflow support

by Robert Brenstein -
I think that this workflow business would be more appropriate for the tracker module if it is made to be more general-purpose module than pure bugtracker. See CONTRIB-811 and other improvement suggestions. That module has workflow built in by definition.

Some of what you described in the proposal is part of the (old) workshop module. If implemented in the database module, it could effectively replace the workshop, although setting up database instance is more work and requires more advanced knowledge than most teachers have.
In reply to Robert Brenstein

Re: Workflow support

by akshit sharma -
Thanks for your suggestions Robert.

Sure, in fact, one of the example use cases provided by David Mudrák is that of an issue tracker (which is more general-purpose than a pure bug tracker).

Also, this module will be able to achieve the functionality provided by the workshop module. But it is also true, that workshop module is easy to set up than setting up workflows for teachers (because this proposal is general in nature). Which is why, the end-user interface should be as simple as possible (see screenshots of DCWorkflow tool in the proposal).
In reply to akshit sharma

Re: Workflow support

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Akshit,

sorry for my delay in replying. I would like to make several things clear.
  • firstly Moodle is not Plone. Moodle is not Content Management System (CMS). And even the content storage/publication is not the primary goal of Moodle (regardless how many teachers actually use it as a PDF publishing system). I mean, what works in CMS, might not work in Moodle. Can you provide more pedagogical use cases/scenarios where workflow support should help teachers to achieve their goals and intentions? We should not add a feature into the core just because we can.
  • what I am a little bit confused with your GSoC proposal: are you really talking about general workflow support for all database records/tables? If so, you must explain how this should fit into the Moodle architecture because I can't imagine it working. My proposal was focused on the Database activity module, not the DB API. If you have mod/data in your mind, it is not clear from the proposal.
  • in the proposal, you are talking about a "block" that would control the workflow. You know, the term has its explicit meaning in Moodle. Are you sure the block is the best plugin to implement this?
  • also, I disagree with the proposition that DCWorkflow interface is teacher-friendly. Even a lot of Zope admins hate it.
  • even if you add a workflow support into the Database module, it can't replace Workshop, for a lot of reasons.
Please can you find a minute on replying these comments so we can evaluate your proposal. Thanks in advance.
In reply to David Mudrák

Re: Workflow support

by akshit sharma -
Thanks a lot, David, for the valuable feedback.

  • Actually I wasn't sure if I should provide workflow support for all database entries or for database records corresponding to database module only (just the mdl_data). And I couldn't get in touch with you before proposal deadline so I proposed for DB records in general (which did sound a bit far fetched!!).

  • There can be infinite uses for providing workflow support for DB module as a lot of things that can't be done currently will be allowed. It is all upto the creativity of the teacher. A few of them have been mentioned by you in the original proposal (example - use cases). The basic idea is to allow students/teachers to move an assignment according to a complex workflow like the one shown in the proposal (this image).

  • It makes more sense to implement workflow support for DB module only. The approach (mentioned here in proposal) will remain the same (AFAIK).

  • The implementation scheme will be trimmed down a bit (since we now deal with only the database module records). I will give a detailed implementation scheme, with database schemas and where how all the information will be stored.

PHASE 1
    • Either use .wfd files for describing workflow, or store the workflow description in the database as a separate table, for e.g. wf_description which will store states and actions.
    • Associate each workflow (whether a .wfd file or a workflow stored in the wf_description table) with an id.
      • If we use .wfd files, we can create a wf_description which will just store the following information.
        • <wf_id, wf_file>
      • If we are already using a table wf_description to store workflow, we can include the wf_id within that table itself.
    • create a "default" workflow as described in the original proposal. Store this workflow in database wf_description with wf_id = 0.
    • Instead of adding a block, we will work within the database module (adding a tab in the DB module UI).
    • Each database will now have a workflow tab also. The first thing in that tab will be whether creator wants workflow support for that database or not. This info will be stored separately in db in wf_association as below.
      • wf_associations <db_id, wf_support, wf_id>
      • db_id is foreign key from mdl_data
      • wf_support is boolean value to indicate if workflow for that db is supported or not.
      • wf_id is the foreign key to a table that stores workflows (wf_description, as defined above)
    • After asking whether to associate the DB with a workflow, we ask user which workflow to associate the DB with (we list all workflows from wf_description table). This will also include the default workflow (wf_id=0).
    • Otherwise, the user can modify the "default" workflow to his own needs, and on clicking save, we save the workflow (in the wf_description) and update mdl_data_workflow to reflect that this database has been associated with a workflow.
    • By the end of Phase 1, the user should be able to create a workflow, and associate DB with a workflow.

PHASE 2
    • This phase will focus on how to actually apply (not just associate, but actually apply) a the associated workflow to the DB. This can be discussed in greater detail during the implementation to work out the specific details.
    • Store the current state of DB record in the wf_states table as follows
      • <record_id, current_state>
      • record_id is foreign key referring to mdl_data_records
      • current_state is one of the states of the workflow described in wf_description corresponding to workflow associated with the given record (which is stored in wf_associations)
    • The template can be modified to allow tags corresponding to the actions specified in the workflow associated with that DB. This means, if the DB is associated with a workflow wf1, and wf1 has actions: "approve", "hide", "show", then these actions will be visible in the Available Tags section of the template.
    • whenever an action is taken, the new state of the record is updated by the following sequence. A handler for each action as described below will have to be defined in views.php (from my understanding of the code).
      • Find which state the record was initially in (using wf_states)
      • Find which workflow is associated with the record (using wf_associations)
      • after knowing the associated workflow, obtain the action definition using the wf_description table.
      • Find the new state using the workflow action definition and the initial state (both obtained above).
      • Update the record's state (in the wf_states table).
    • Default permissions for different types of users (teacher, admin, course-creator etc) corresponding to each action are stored in access.php
    • Permissions corresponding to each action/state can be specified by over-riding permissions for the database instance. For e.g., corresponding to the "Publish" (action) - Allow, Prevent, Prohibit, are the different permissions for this action. These permissions for "Publish" action can be set for each of the users - Teacher, Course Creator, Admin etc. This can be done usingAssign roles page via the Roles tab in editing database page. Similarly permissions like view_draft can be there.
    • By end of Phase 2, only users with the permission to do an action will be able to do that action. And doing an action will cause a handler of that action to be called. And also update the state of the record in DB.
  • As mentioned above, we wont be using blocks now.

  • Hopefully, the interface will be much simpler now than DCWorkflow. Various components of the interface will be :
    • a new tab in the module UI to assign a workflow to the database instance whose tab is open right now.
    • allow user to create/modify workflow within that tab itself.
    • use the Assign roles page via the Roles tab to set permissions.

The initial proposal was a bit vague on implementation front, as I focussed more on describing what the end result should be like. I hope I have answered all your queries and tried to make the proposal as clear and ambiguity free as possible (even though some later steps in Phase 2 are a bit vague, but i think they can only become completely clear after we implement the Phase 1). If there are any more clarifications/suggestions, I'd be really grateful if you could let me know them.

And finally I am sorry for replying so late, I had my semester exams going on. I assure you this doesn't happen otherwise.

In reply to akshit sharma

Re: Workflow support

by akshit sharma -
Hi again,

I have summarized the database schema and relations for phase 1 using this image (shown below).

DB schemas and relations for phase 1


And for phase 2 using this image (shown below).

DB schemas and relations for phase 2


Hope this makes things even more clear. Thank you for your time.
In reply to akshit sharma

Re: Workflow support

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Akshit,

thanks for reviewing your application. I am thinking about the proposed DB scheme. If you plan to implement the workflow support in the context of the Database activity module only, new tables should have "mdl_data_*" prefix. Anyway, that's a technical detail.
What makes me worry more is the scheme and the meaning of your "wf_descritpion" table. Is "wf_id" the primary key of the table? Are all states and actions defined here?
Also, I do not think the proposed way of using roles/capabilities would work here. If we want to allow teacher to define their own workflows, we can't map actions to the current capabilities. Their list is staticaly defined in access.php and can't be extended by teachers.
In reply to David Mudrák

Re: Workflow support

by akshit sharma -
David,
  • I thought so about the database names, but I dropped the "mdl_data_" prefix just to make things clearer.

  • wf_description basically stores the workflow definition. In other words, it must store the states of a workflow and transition rules on actions. The schema described previously is not normalized. A normalized schema for wf_description is described here.
    • wf_list <wf_id>
    • wf_states_list <state_id, state_name>
    • wf_description_states <wf_id, state_id>
    • wf_actions_list <action_id, action_name, action_initial_state, action_final_state>
    • wf_description_actions <wf_id, action_id>

  • The original schema wf_description <wf_id, states, actions> is basically broken up into two tables - wf_description_states and wf_description_actions. This is more clear from this image (primary keys marked with *).

    wf_description
  • Now, whenever an action is taken, the following will be executed in order.
    • Find which state (i.e., get state_id) the record was initially in (using wf_states) - same as before
    • Find which workflow is associated with the record (i.e., get wf_id) (using wf_associations) - same as before
    • Get list of all the actions (i.e. get all action_id's) associated with wf_id computed in last step (from wf_description_actions).
    • Check if the action taken is in this list or not. If not, then raise error that action taken is not defined for the workflow associated with the database record. This will never happen, because only the actions associated with the workflow will be presented to the user.
    • Now check if the action taken is defined for the initial state or not. i.e. if action_id for action taken is 4, we check if the initial state id computed in 1st step is same as the initial_state id for action 4 (use wf_actions_list for this purpose).
    • If so, we check the final state and update it in wf_states - same as before.

  • The process is same as before, I just added a few checks, which wouldn't be very important (because we let user take only those actions that are defined for the current workflow, and whose initial state is same as the state in which the database record is in).

  • I agree that the proposed way of using roles/capabilities would work because actions are defined dynamically and the list of capabilities is statically defined in access.php. However, can we skip the access.php and dynamically add the capability to mdl_capabilities (i.e. directly to the database) ? The new capability added (corresponding to the action) in the database will now be visible in the override permissions section. A very very nasty hack, i know !! Can you suggest some line of thought using which we can solve this problem.
Thanks again for reviewing my proposal.
In reply to akshit sharma

Re: Workflow support

by akshit sharma -
Note 1:
I mentioned in the last post :-
"Check if the action taken is in this list or not. If not, then raise error that action taken is not defined for the workflow associated with the database record. This will never happen, because only the actions associated with the workflow will be presented to the user."

This is because, I have already mentioned in the implementation scheme Phase2 that :-
"The template can be modified to allow tags corresponding to the actions specified in the workflow associated with that DB. This means, if the DB is associated with a workflow wf1, and wf1 has actions: "approve", "hide", "show", then these actions will be visible in the Available Tags section of the template."

Hence the actions (which are basically buttons, corresponding to tags in the templates), will be only those which are defined for the workflow.

Note 2: A correction.
I mentioned in the previous post that :-
"The process is same as before, I just added a few checks, which wouldn't be very important (because we let user take only those actions that are defined for the current workflow, and whose initial state is same as the state in which the database record is in)."

There is a small correction.
The user is allowed to take all those actions which defined for current workflow. However, he may be presented with the option of taking an action for which the initial state is not the same as the state in which the database record is in.

This exception will be caught in the 5th step of the execution sequence -
"Now check if the action taken is defined for the initial state or not. i.e. if action_id for action taken is 4, we check if the initial state id computed in 1st step is same as the initial_state id for action 4 (use wf_actions_list for this purpose)."

If such a case happens, error is raised, and action is not taken. Hence one of the two checks are important (I preciously mentioned that both are not important).



In reply to David Mudrák

Re: Workflow support (implementation plan)

by Wiktor Wandachowicz -
Picture of Core developers

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 smile 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).

Attachment Example_workflows.png
In reply to Wiktor Wandachowicz

Re: Workflow support (implementation plan)

by Itamar Tzadok -

There is work underway that implements an infrastructure for notifications and may be extended to support workflow of the type described in your post. It would probably be released next week. smile

In reply to Itamar Tzadok

Odp: Re: Workflow support (implementation plan)

by Wiktor Wandachowicz -
Picture of Core developers

Can you give me any more details?

Is there a specification in Wiki or a ticket in Moodle Tracker for it? Do you know if there is any repository on GitHub I can look for the code? Will it be for Moodle-2.4-dev or any other older STABLE versions?

In reply to Wiktor Wandachowicz

Re: Odp: Re: Workflow support (implementation plan)

by Itamar Tzadok -

It's part of the Dataform module. The module is available from the plugins repo and from git and supports all Moodle 2 versions.

The spec for the notifications support is not publicly available but the feature will be documented as soon as it's implementation is completed.

The approach is somewhat different from what you describe above. For instance, your proposal seems to constrain all entries in a given activity to one workflow by assigning the workflow in the activity level (mdl_data, Add: workflowenable, workflowid).

smile

In reply to Itamar Tzadok

Re: Workflow support (implementation plan)

by Wiktor Wandachowicz -
Picture of Core developers

The approach is somewhat different from what you describe above. For instance, your proposal seems to constrain all entries in a given activity to one workflow by assigning the workflow in the activity level (mdl_data, Add: workflowenable, workflowid).

Well, yes actually. It seemed natural to use only one workflow for a given activity, since when need arises for a different workflow, one can simply create another activity for it. Database module supports only one set of fields, user-defined HTML template and (possibly) one workflow for all records of given activity.

Are there legitimate use cases where multiple workflows for one activity is required?

In reply to Wiktor Wandachowicz

Re: Workflow support (implementation plan)

by Itamar Tzadok -

Whatever the case may be it seems unnecessary to store workflow id in mdl_data since you already associate a workflow with a database in your mdl_data_wf.

But consider a case where particular entries by certain users may require a different workflow either in state transitions or in time frames or some other factor. It seems more reasonable to allow that within the same activity than to create separate activities.

A similar case is the quiz user/group overrides. It is simpler to override the time frame of a given quiz for designated users or a group, than to duplicate the quiz for each user or group.

smile

 

In reply to Itamar Tzadok

Odp: Re: Workflow support (implementation plan)

by Wiktor Wandachowicz -
Picture of Core developers

You raise valid issues, however:

  • mdl_data points to only one workflow at a time via workflowid column
  • mdl_data_wf either has dataid=0 - which means that the workflow is global, or contains a specific dataid - which means it is a database-specific workflow
    (on the second thought I think I should replace dataid with courseid, so workflow with non-zero courseid would be course-specific and could be reused in several databases)
  • If the owner turns on workflowenable in mdl_data and selects workflowid (either global, or course-specific), then all ##ACTION## buttons are handled according to the workflow definition
    (for example, "Edit" button may be hidden and the data module would refuse to display edit form, if workfow state does not allow edits)
  • If the owner changes workflowid then we have several options for records which were assigned state from the old workflow:
    • hide such records,
    • disable all actions on such records, and leave "View" only
    • for records which are in the initial state of the old workflow, move them to initial state of the new workflow
  • For the case when some particular entries in the database require a different workflow, I think it's overengineering at this point where only simple transitions between states with view/edit blocking is required. And when the need arises it can be extended to include a general workflow engine (with guard conditions for state transitions and extra scripting, like in Plone for example).

And by the way, please forgive my memory for not including one more important modification to Moodle database structure (in mdl_data_records, and update for mdl_data_wf):

mdl_data
========
Add: workflowenable, workflowid

mdl_data_records
================
Add: wfstateid

mdl_data_wf
===========
Table: id, wfname, courseid (global if 'courseid'=0), initstateid

For now I'm going to add this functionality to original mod_data anyway, and if your notifications infrastructure becomes published, I will look into using it to build workflow support. This way at least I will hopefully have simple working mechanism as another reference smile