Auto role assignment block

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 2.9. Up-to-date documentation for the latest stable version of Moodle may be available here: Auto role assignment block.

Why this block

Consider the situation. In the course the student has role of "student", he has permission to pass tests, viewing lectures, correspondence with other course participants, etc. When a student, for example, gives examination test it should be out some rights such as viewing the lectures and correspondence. If it is done manually, as is done now, it will take a lot of time, because group usually more than 10 people, moreover after the end of the test must return the user to the previous permission.

This block will automatically change the user's role on the events in the system (in this case the beginning of the test and the end of the test).

Rules

Rule - is a term used to describe the process of checking the current state of the user and the ability to change the role by event in system.

For the example above:

  • Event in system: the beginning of passing the test;
  • Current state: role of "student";
  • New state: role of "students taking examination test".

Rule works as follows:

  1. The system event is triggered - the student began to take the test
  2. If for this event find rule, then
    1. Check the user's current role (in this case "student"), if the role needs to change (in this case "students taking examination test"), then
      1. Change user role (in this case role "student" change on role "student taking examination test")

Role returns of the same principle, only handling the event of the "student finished the test".

Parameters of rules

  • id of the course - a specific course for which the rule is intended
  • type rule - modules of Moodle for which should work rule, now realized work rules for two types of module quiz and block supervised, planned to implement for the module poasasssignment.
  • user Group - rule is triggered (depending on type) for:
    • One user
    • User groups on the course
    • All users on the course
  • allowed roles - roles of users who are allowed to change in the rule

Rule structure

Rule changes the permissions of the user depending on the event in the system.

Rules structure:

Required parameters:

  • Name of rule;
  • Type of rule;
  • A role that will be assigned to the user when the rule will trigger;
  • Roles that are permitted a transition;
  • Elements of the course for which the rule is triggered.

Optional parameters may be added depending on the type of rule.

Block appearance

The block contains three links:

  1. Link to current rules page
  2. Link to active rules page
  3. Current role of user in course

block role assign.jpg

Current rules page

On this page you can see rules that already exist. On this page you can go to add/edit page of rule; delete rule (if you have the necessary permissions).

current rules.jpg

Add rule page

In this page you can add new rule: Step 1:

  • you must input name of rule
  • you must select type of rule

click 'next'.

new rule.jpg

Step 2:

  • you must select 'new role' (this role will receive a user when a rule is triggered)
  • you must select 'allow roles' (this user roles on this course, which allowed triggering rules)
  • you must select elements of course for this type of rule, which rule is triggered

click 'save'.

add edit rule.jpg

Active rules page

On this page you can see active rules.

active rules.jpg

DB structure

database.jpg

  • block_role_assign_rules - table for rules:
  • block_role_assign_instances - table with active rule
  • block_role_assign_values - table for optional parameters
  • block_role_assign_roles - table for allow roles
  • block_role_assign_types - table where sets type of rule
  • block_role_assign_tasks - table with types of rule

Capabilities

  • block/role_assign:addrule - ability add rule
  • block/role_assign:editrule - ability edit rule
  • block/role_assign:deleterule - ability delete rule
  • block/role_assign:viewactiverules - ability view page "active rules"
  • block/role_assign:viewcurrentrules - ability view page "current rules"