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

Allow enrol keys to conform to a template

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Waiting for peer review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: Future Dev
    • Fix Version/s: None
    • Component/s: Enrolments
    • Testing Instructions:
      Hide

      1) Setup. Run thee commands in a terminal from the main moodle directory:

      php admin/cli/cfg.php --name='enrol_plugins_enabled' --set='self'

      php admin/cli/cfg.php --name='coursekeytemplate' --component='enrol_self' --set=''

      php admin/cli/cfg.php --name='randomkeylen' --component='enrol_self' --set='10'
      

      php admin/cli/cfg.php --name='regenerate' --component='enrol_self' --set='2'

      php admin/cli/cfg.php --name='regenerateonrestore' --component='enrol_self' --set='0'

      php admin/cli/cfg.php --name='requirepassword' --component='enrol_self' --set='1'

      2) Test enrol key with no template config:

      • Create a new course, and fill the required fields with dummy data.
      • Navigate to Course > Users > Enrolment methods > Self enrolment (Student)
      • Click on the ‘Reveal’ option to see the generated key.
      • The enrol key should be a random string of length 10.
      • A new ‘Generate’ option should be displayed next to the ‘Reveal’ option.
      • Click on the new ‘Generate’ option to generate a new random key.
      • Verify the generated key is in format {10randomchars} e.g. 'NObe,Q9012'

      3) Test enrol key with template config:

      php admin/cli/cfg.php --name='coursekeytemplate' --component='enrol_self' --set='idnumber'
      

      * Edit the course previously created.

      • Set the ‘Course ID number’ field to 'test' and save.
      • Navigate to Course > Users > Enrolment methods > Self enrolment (Student).
      • Click on the ‘Reveal’ option to see the generated key.
      • The enrol key should have the following format: test-{10randomchars}.
      • A new ‘Generate’ option should be displayed next to the ‘Reveal’ option.
      • Click on the new ‘Generate’ option to generate a new random key. Verify the generated key is in format test-{10randomchars} e.g. test-40xjh!_9tF

      4) Test enrol key with template config and regenerate key config = ‘Never’**

      php admin/cli/cfg.php --name='keytemplate' --component='enrol_self' --set='idnumber,random

      php admin/cli/cfg.php --name='regenerate' --component='enrol_self' --set='0'
      

      * Edit the course again.

      • Update the ‘Course ID number’ field to 'test2' and save.
      • Navigate to Course > Users > Enrolment methods > Self enrolment (Student)
      • Click on the ‘Reveal’ option to see the generated key.
      • The key should be exactly the same as in step 3 and will be in format: test-{10randomchars}.

      5) Test enrol key with template config and regenerate key config = ‘If key has not been used’

      php admin/cli/cfg.php --name='regenerate' --component='enrol_self' --set='1'

      * Edit the course again.

      • Update the ‘Course ID number’ field to 'test3' and save.
      • Navigate to Course > Users > Enrolment methods > Self enrolment (Student)
      • Click on the ‘Reveal’ option to see the generated key.
      • The enrol key will be updated reflecting the new ‘Course ID number’ value.
      • Verify the enrolment key is in format: test3-{10randomchars}.
      • Create a test user.
      • As the test user, enrol into the test course using the self enrolment method, with the key from above - 'test3-{10randomchars}'.
      • Log back into the admin account, and edit the test course details again.
      • Update the 'Course ID Number' field to 'test4' and save.
      • Navigate to Course > Users > Enrolment methods > Self enrolment (Student)
      • Click on the ‘Reveal’ option to see the generated key.
      • Verify that the enrol key is not updated, and is still in format 'test3-{10randomchars}'.

       6) Test course backup using the same key.

      php admin/cli/cfg.php --name='backupregenerate' --component='enrol_self' --set='0'
      

      • Create a backup of the test course:
      • go to /backup/backup.php?id={courseid}
      • Click on 'Jump to final step'.
      • Go to /backup/restorefile.php
      • Click on 'Restore' for the backup just created.
      • Select a category under the ‘Restore as a new course’ and click ‘Continue’.
      • Make sure that you select ‘Yes, always’ for the ‘Include enrolment methods’.
      • Click ‘Next’ and then ‘Perform restore’.
      • Navigate to RestoredCourse > Users > Enrolment methods > Self enrolment (Student)
      • Click on the ‘Reveal’ option to see the generated key.
      • The enrolkey should be identical to the one created in the original test course, from the above step.
      • Verify that the enrolkey is in format 'test3-{10randomchars}'.

       7) Test course backup using a different key.

      php admin/cli/cfg.php --name='backupregenerate' --component='enrol_self' --set='1'
       

      * Create a backup of the test course:

      • go to /backup/backup.php?id={originalcourseid}
      • Click on 'Jump to final step'.
      • Go to /backup/restorefile.php
      • Click on 'Restore' for the backup just created.
      • Select a category under the ‘Restore as a new course’ and click ‘Continue’.
      • Make sure that you select ‘Yes, always’ for the ‘Include enrolment methods’.
      • Click ‘Next’ and then ‘Perform restore’.
      • Navigate to Restored Course 2 > Users > Enrolment methods > Self enrolment (Student)
      • Click on the ‘Reveal’ option to see the generated key.
      • Verify that the key is in format 'test4-{10randomchars}'.

      8) Test Group Enrolment keys:

      • Navigate to Restored Course > Users > Groups > Create Group
      • A new 'Generate' option should be displayed next to the 'Reveal' option for the enrolment key field.
      • Click on the new ‘Generate’ option to get a new enrolment key value.
      • Click on the ‘Reveal’ option to see the generated key.
      • The new enrolment key value will be in format: {10randomchars}.
      • Update the ‘Group ID number’ field and save.

      9) Test Edit Group:

      • Navigate to Restored Course > Users > Groups
      • Select the created group and click on ‘Edit group settings’.
      • Click on the ‘Reveal’ option to see the key.
      • Click on the ‘Generate’ option to update the enrolment key value.
      • The enrolment key should be updated reflecting the new ‘Course ID number’ and the ‘Group ID number’ value.
      • It should be in format: {course-idnumber}- {group-idnumber}- {10randomchars}.
      Show
      1) Setup. Run thee commands in a terminal from the main moodle directory: php admin/cli/cfg.php --name= 'enrol_plugins_enabled' --set= 'self' php admin/cli/cfg.php --name= 'coursekeytemplate' --component= 'enrol_self' --set= '' php admin/cli/cfg.php --name= 'randomkeylen' --component= 'enrol_self' --set= '10' php admin/cli/cfg.php --name= 'regenerate' --component= 'enrol_self' --set= '2' php admin/cli/cfg.php --name= 'regenerateonrestore' --component= 'enrol_self' --set= '0' php admin/cli/cfg.php --name= 'requirepassword' --component= 'enrol_self' --set= '1' 2) Test enrol key with no template config: Create a new course, and fill the required fields with dummy data. Navigate to Course > Users > Enrolment methods > Self enrolment (Student) Click on the ‘Reveal’ option to see the generated key. The enrol key should be a random string of length 10. A new ‘Generate’ option should be displayed next to the ‘Reveal’ option. Click on the new ‘Generate’ option to generate a new random key. Verify the generated key is in format {10randomchars} e.g. 'NObe,Q9012' 3) Test enrol key with template config : php admin/cli/cfg.php --name= 'coursekeytemplate' --component= 'enrol_self' --set= 'idnumber' * Edit the course previously created. Set the ‘Course ID number’ field to 'test' and save. Navigate to Course > Users > Enrolment methods > Self enrolment (Student). Click on the ‘Reveal’ option to see the generated key. The enrol key should have the following format: test-{10randomchars}. A new ‘Generate’ option should be displayed next to the ‘Reveal’ option. Click on the new ‘Generate’ option to generate a new random key. Verify the generated key is in format test-{10randomchars} e.g. test-40xjh!_9tF 4) Test enrol key with template config and regenerate key config = ‘Never’ ** php admin/cli/cfg.php --name= 'keytemplate' --component= 'enrol_self' --set='idnumber,random php admin/cli/cfg.php --name= 'regenerate' --component= 'enrol_self' --set= '0' * Edit the course again. Update the ‘Course ID number’ field to 'test2' and save. Navigate to Course > Users > Enrolment methods > Self enrolment (Student) Click on the ‘Reveal’ option to see the generated key. The key should be exactly the same as in step 3 and will be in format: test-{10randomchars}. 5) Test enrol key with template config and regenerate key config = ‘If key has not been used’ php admin/cli/cfg.php --name= 'regenerate' --component= 'enrol_self' --set= '1' * Edit the course again. Update the ‘Course ID number’ field to 'test3' and save. Navigate to Course > Users > Enrolment methods > Self enrolment (Student) Click on the ‘Reveal’ option to see the generated key. The enrol key will be updated reflecting the new ‘Course ID number’ value. Verify the enrolment key is in format: test3-{10randomchars}. Create a test user. As the test user, enrol into the test course using the self enrolment method, with the key from above - 'test3-{10randomchars}'. Log back into the admin account, and edit the test course details again. Update the 'Course ID Number' field to 'test4' and save. Navigate to Course > Users > Enrolment methods > Self enrolment (Student) Click on the ‘Reveal’ option to see the generated key. Verify that the enrol key is not updated, and is still in format 'test3-{10randomchars}'.  6) Test course backup using the same key. php admin/cli/cfg.php --name= 'backupregenerate' --component= 'enrol_self' --set= '0' Create a backup of the test course: go to /backup/backup.php?id={courseid} Click on 'Jump to final step'. Go to /backup/restorefile.php Click on 'Restore' for the backup just created. Select a category under the ‘Restore as a new course’ and click ‘Continue’. Make sure that you select ‘Yes, always’ for the ‘Include enrolment methods’. Click ‘Next’ and then ‘Perform restore’. Navigate to RestoredCourse > Users > Enrolment methods > Self enrolment (Student) Click on the ‘Reveal’ option to see the generated key. The enrolkey should be identical to the one created in the original test course, from the above step. Verify that the enrolkey is in format 'test3-{10randomchars}'.  7) Test course backup using a different key. php admin/cli/cfg.php --name= 'backupregenerate' --component= 'enrol_self' --set= '1'   * Create a backup of the test course: go to /backup/backup.php?id={originalcourseid} Click on 'Jump to final step'. Go to /backup/restorefile.php Click on 'Restore' for the backup just created. Select a category under the ‘Restore as a new course’ and click ‘Continue’. Make sure that you select ‘Yes, always’ for the ‘Include enrolment methods’. Click ‘Next’ and then ‘Perform restore’. Navigate to Restored Course 2 > Users > Enrolment methods > Self enrolment (Student) Click on the ‘Reveal’ option to see the generated key. Verify that the key is in format 'test4-{10randomchars}'. 8) Test Group Enrolment keys: Navigate to Restored Course > Users > Groups > Create Group A new 'Generate' option should be displayed next to the 'Reveal' option for the enrolment key field. Click on the new ‘Generate’ option to get a new enrolment key value. Click on the ‘Reveal’ option to see the generated key. The new enrolment key value will be in format: {10randomchars}. Update the ‘Group ID number’ field and save. 9) Test Edit Group: Navigate to Restored Course > Users > Groups Select the created group and click on ‘Edit group settings’. Click on the ‘Reveal’ option to see the key. Click on the ‘Generate’ option to update the enrolment key value. The enrolment key should be updated reflecting the new ‘Course ID number’ and the ‘Group ID number’ value. It should be in format: {course-idnumber}- {group-idnumber}- {10randomchars}.
    • Pull Master Branch:

      Description

      When creating lots of courses which all use enrol keys, we want the ability to define an enrol key template which could have some random parts and some fixed strings. This mean when you look at an enrolment key you can easily see what it is for.

      The defaults template might be something like:

       

      {random-number:10

      But you could change it to something like:

       

      {course-idnumber}-{random-number:10}
      

      And then if you clone the course or restore if then you'll get a fresh set of keys which could look like:

      COMP100SEM1-4578354143 

      There should probably be some ability to have templates for group enrol keys too

      {course-idnumber}-{group-idnumber}{random-number:10}
      

      COMP100SEM1-INTERNAL-4578354143 

       

       

        Attachments

          Activity

            People

            Assignee:
            peterburnett Peter Burnett
            Reporter:
            brendanheywood Brendan Heywood
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: