Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-45469

Conditional availability: Restrict by text area field doesn't work

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      0. Enable availability at site level if required.
      1. Create one custom user field of each available type (in Site administration / Users / Accounts / User profile fields):
      a. Type 'text input', short name 'frogname', name 'Frog name'
      b. Type 'text area', short name 'frogdesc', name 'Frog description'
      2. Go to a course and add a new Page activity (no need to fill in the form).
      3. Expand 'Restrict access'
      4.
      Moodle 2.7: Click 'Add restriction' and then 'Profile'. Click on the profile field dropdown and look at the values.
      Moodle <=2.6: Under 'User field', expand the first '(None)' dropdown and look at the values.

      EXPECTED: 'Frog name' should be included in the values (M2.7: at end; M2.6; sorted in with standard fields). 'Frog description' should not be.

      Show
      0. Enable availability at site level if required. 1. Create one custom user field of each available type (in Site administration / Users / Accounts / User profile fields): a. Type 'text input', short name 'frogname', name 'Frog name' b. Type 'text area', short name 'frogdesc', name 'Frog description' 2. Go to a course and add a new Page activity (no need to fill in the form). 3. Expand 'Restrict access' 4. Moodle 2.7: Click 'Add restriction' and then 'Profile'. Click on the profile field dropdown and look at the values. Moodle <=2.6: Under 'User field', expand the first '(None)' dropdown and look at the values. EXPECTED: 'Frog name' should be included in the values (M2.7: at end; M2.6; sorted in with standard fields). 'Frog description' should not be.
    • Workaround:
      Hide

      Don't try to set user profile conditions on textarea fields.

      Show
      Don't try to set user profile conditions on textarea fields.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull Master Branch:
      MDL-45469-master

      Description

      FULL STEPS

      1. Ensure conditional access is turned on at site level.
      2. Create a NEW User profile fields:
        • Text area - Short name: yearofenrolment - Name: Year of Enrolment
      3. Create a new Student account "ABC" with the yearofenrolment field 2014
      4. Create a new activity on a course. Under Restrict access, add an additional user field conditions:
        • User field: Year of Enrolment contain 2014
        • While access is prevented: Hide activity entirely...
      5. Save and display settings.
      6. Log in as Student ABC
      7. Open the activity settings again

      WHAT YOU EXPECTED
      Student ABC should be able to see the allowed activity as his user profile yearofenrolment is 2014.

      WHAT ACTUALLY HAPPENS - Moodle 2.6+
      In lib\conditionlib.php the get_cached_user_profile_field function is not able to get the value from yearofenrolment from the $USER global variable.
      Under this code:

      if (!isset($USER->profile)) {
      ...
      }
      else if (array_key_exists($field, $USER->profile)){
      ...
      }
      

      It fails at array_key_exists($field, $USER->profile)!!! weird!!!

      Seems like a problem with $USER. But not sure about whether 2.7 is affected due to the overhaul yet.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Jul/14