Moodle
  1. Moodle
  2. MDL-29538

Conditional code based on user fields.

    Details

    • Testing Instructions:
      Hide

      1. Enable conditional activities on your Moodle site.
      2. Create some random custom profile fields.
      3. Create a course, and enrol a student into the course.
      4. Create an activity and restrict the activity using all the custom profile fields, and user fields in the drop down (make sure you use all the types of operators as well (equal, contains, is empty etc))
      5. Restrict a whole topic section as well
      6. Log in as the student and visit the course.
      7. Ensure the message explaining that the items being restricted makes sense.
      8. One by one fulfill all the requirements that you have put in place on the restriction for that particular user and check to see if the restriction disappears in the message.
      9. Once all have been done, make sure you can access the activity/section.
      10. Backup and restore the course!

      Just a note, we have a large client that has been using this code heavily for 8 months with no issues.

      Show
      1. Enable conditional activities on your Moodle site. 2. Create some random custom profile fields. 3. Create a course, and enrol a student into the course. 4. Create an activity and restrict the activity using all the custom profile fields, and user fields in the drop down (make sure you use all the types of operators as well (equal, contains, is empty etc)) 5. Restrict a whole topic section as well 6. Log in as the student and visit the course. 7. Ensure the message explaining that the items being restricted makes sense. 8. One by one fulfill all the requirements that you have put in place on the restriction for that particular user and check to see if the restriction disappears in the message. 9. Once all have been done, make sure you can access the activity/section. 10. Backup and restore the course! Just a note, we have a large client that has been using this code heavily for 8 months with no issues.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-29538_usercond
    • Rank:
      19015

      Description

      I have developed conditional activities based on user profile fields and custom user profile fields. This means it is possible to create a new activity and restrict it to only a certain group of individuals. You are able to specify whether a field "is empty", "contains", "does not contain", "is equal to", "starts with" or "ends with" a given value.

      Example: restrict an activity to user who's -

      Email ends with "moodle.com"
      Department does not contain "Temporary Staff"
      City/town is equal to "Perth"

      Please note, I copied the coding style of existing code conditionlib so that it was consistent but am happy to clean it up or for someone else to clean it up if people would rather it followed Moodle coding guidelines.

      1. code review.txt
        8 kB
        Sam Marshall
      1. courseview.jpg
        38 kB
      2. restrictaccess.jpg
        151 kB

        Issue Links

          Activity

            People

            • Votes:
              26 Vote for this issue
              Watchers:
              26 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: