Giter Club home page Giter Club logo

moodle-auth_enrolkey's Introduction

Moodle Enrolment key based self-registration

GitHub Workflow Status (branch)

This auth plugin combines the best of both email based signup and self enrolment keys into a streamlined process making it much faster for students to get into a course. For the student it saves around 9-10 clicks and avoids context switching between a browser and their email client where they can become easily become disengaged or run into issues if their email is unavailable.

This is mostly a clone of the Email-based self-registration plugin that also enrols a user into available courses based on a token supplied. When a user enters a valid token it will automatically enrol them into the course that token was specified for, and then take them directly to that course. Also an optional bonus setting: because they have demonstrated knowledge of a secret code we know they are a real human so we let them straight in without forcing them to confirm their email. For some use cases where they may login and complete their course in a single session we may not ever care about their email being valid.

Courses that provide self enrolment can restrict access to them with a key. If the signup token matches any course enrolment key then the new user will be enrolled into those courses.

Found in the Moodle plugins directory at https://moodle.org/plugins/auth_enrolkey

This also has a companion block plugin:

https://github.com/catalyst/moodle-block_enrolkey

https://moodle.org/plugins/block_enrolkey

Branches

Moodle version Branch PHP
Moodle 3.5 to 3.11 master 7.1+

Installation

Add the plugin to /auth/enrolkey/

Run the Moodle upgrade.

Setup

First enable the Enrolment key based self-registration plugin for use.

Site administration > Plugins > Authentication > Manage Authentication

On the same page that you manage authentication options, scroll down to the common settings and select Enrolment key based self-registration in the Self Registration drop down list for registerauth.

Enable the Self enrolment plugin.

Site administration > Plugins > Enrolments > Manage enrol plugins

Settings

It is possible to force the the enrolment key as a required element for signing up.

Users can be forced to confirm their account via email even when entering a valid token.

Admin Usage

Course enrolment keys

Enable a new Self enrolment method in the course required.

Course administration > Users > Enrolment methods > Add method > Self enrolment

The Enrolment key field that is visible will be used for the automatic enrolment on signup.

When creating new Self enrolment method, provide a custom instance name that is descriptive enough to determine how and when this specific instance will be used for enrolling.

Please add additional Self enrolment methods for the course that you require automatic enrolment access for.

Group enrolment keys

If you select Use group enrolment keys: Yes during creating of a new Self enrolment method, it enables a functionality of automatic adding self enrolled students to the groups created in the course.

In order for that to work, create a group in the course and specify Enrolment key.

Please note, that this key must be different from the course enrollment key which you set in the course Self enrolment method.

As a result, students will be able to subscribe using the group enrolment key. That will enrol them to the course where the group was created and also will add them to that group.

Client Usage

When a user tries to log in they are given the option to create an account.

The user can enter a token into the field name Enrolment key.

There is an optional setting that can force this field to be required.

If the token matches any valid instance of self enrolment, then the user will be enrolled to those courses.

TODO

Add option to bypass view.php, this may not be required if only enroling into one course.

Support

For any issue with the plugin, please log the in the github repository here:

https://github.com/catalyst/moodle-auth_enrolkey/issues

Please note our time is limited, so if you need urgent support or want to sponsor a new feature then please contact Catalyst IT Australia:

https://www.catalyst-au.net/contact-us

This plugin was developed by Catalyst IT Australia:

https://www.catalyst-au.net/

Catalyst IT

moodle-auth_enrolkey's People

Contributors

anupamatd avatar brendanheywood avatar gleimermora avatar jasonliancatalyst avatar jwalits avatar keevan avatar kiklop74 avatar lkavicky avatar matthewhilton avatar nhoobin avatar peterburnett avatar suankan avatar yao9394 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moodle-auth_enrolkey's Issues

Implement privacy provider to cover new DB tables

1) provider_testcase::test_table_coverage
The following tables with user fields must be covered with metadata providers: 
  - auth_enrolkey_redirect (usermodified)
  - auth_enrolkey_profile (usermodified)
  - auth_enrolkey_cohort (usermodified)

/var/www/site/privacy/tests/provider_test.php:327
/var/www/site/lib/phpunit/classes/advanced_testcase.php:80

To re-run:
 vendor/bin/phpunit "provider_testcase" privacy/tests/provider_test.php

Recommend using https://github.com/moodle/moodle/blob/master/auth/oauth2/classes/privacy/provider.php as an example.

suggestions for enrollment token option for existing users

Wondering if there is a method to use enrollment token for existing users. Once logged in as an existing user the individual would visit a page where they would enter an existing enrollment token which would enroll them in the right course.

Blank screen after using no enrolment key

Originally submitted by Bert van der Hooft in https://moodle.org/plugins/auth_enrolkey

Using it on moodle 2.8.7.:

Leaving enrolment key open (not required): I end up in a blanc screen. On refreshment I see that I'm logged in. Account remains unconfirmed (that should be the case)

Using the enrolment key: I end up with a nice message that I'm enrolled in the course, but without role! So I do not see the learning activities (e.q. questionnaire).

I do like this plugin, but I uninstalled it, waiting for a slution for the abovemented two issues

New Release

Simple question: There has been some improvement in git compared to the latest release available on moodle.org/plugins/.
I could download a zip and install it manually. Sadly I don't have git available on the server to do it automatically. For that reason I use the moodle.org/plugin repository for installs and updates.

Could you make a new release?

Thanks.

Location(city) & Organization(institution) Not Updateable

Hi Brendan,

I just noticed it is not possible for me or my students to alter their locations or institutions which they first signed up with. The data is saved okay on sign up, but not update-able on edit pages afterwards.

Do you think this could be something like what was happening with the passwords not updating last year?

Reset Password

On moodle 3.1, the reset of passwords doesn't work with this magnificent authentication plugin. I also can't change the password of an user too.I need to change the authentication method for a certain user in order to change and reset passwords.

Can this be changed?

Bert

Group keys

Hi
Great plugin - but I have 1 issue.
It does not work with group enrolment keys.
Course enrollment keys works great.

I dont know if its an actual issue - but it would be a nice feature :)

Thnx for the great work u've done with the plugin.

Kindly
Quxen / Qurinius

Notice: Undefined property: stdClass::$email in /var/www/vhosts/azubi49.de/httpdocs/auth/enrolkey/auth.php on line 264

image

Hello getting following error. Sign Up is still working. Moodle 3.9.1., Nginx, Linux 18.04. Maria DB 10.3.

Issue Message:

Notice: Undefined property: stdClass::$email in /var/www/vhosts/azubi49.de/httpdocs/auth/enrolkey/auth.php on line 264
Um sicherzugehen, dass sich niemand unberechtigt über die von Ihnen angegebene E-Mail anmeldet, wird eine automatische Benachrichtigung an diese Adresse {$a} gesendet.

Die Benachrichtigung enthält eine Anleitung, wie Sie Ihre Registrierung bestätigen. Danach sind Sie auf dieser Moodle-Seite registriert und können sofort loslegen.

Bei Problemen wenden Sie sich bitte an die Administrator/innen der Website.

Instructions can't be customized. It shows the default

Hi,

Thank you for providing this plugin to the moodle community.

I'm trying to customized the login instructions with your plugin. It works fine if I use Email-based self-registration, but when I switched to Enrolment key based self-registration the login instructions are always the default. It doesn't matter if I change it on the instructions box.

image
image
image

I have purged all the catches and not success...

Thank you for your help

Calling variable globally

Hello Brendan Heywood
I was talking about auth_enrolkey/auth.php, calling a value " $enrolplugin->id " from user_signup( )

$enrolplugins = $DB->get_records('enrol', array('password' => $user->signup_token));
$availableenrolids = [];

foreach ($enrolplugins as $enrolplugin) {          
                $data = new stdClass();
                $data->enrolpassword = $enrolplugin->password;
                $availableenrolids[] = $enrolplugin->id;            
 }      

I want to pass $enrolplugin->id value to user_confirm( ). Is this is possible:

Many Thanks!

There was an error enrolling in course

Hi all,

After installing and setting up the plugin, everything seems to work ok BUT a message shows up just right up when the user finish the registration procedure: There was an error enrolling in course. The error message is: enrolling inactive

What could be happening? Thanks in advance.

Best regards

V3.8 - Sorry, the requested file could not be found

Hi,

I have just installed this in an attempt to make authentication an enrolment into and specifically a group within a course, but hit an issue. As soon as this is unhidden as an enrolment method, then "Self registration" is set to "Enrolment key based self-registration", when I then click the "New Account" link on the login page, I see:

Notice: Undefined property: stdClass::$loginhttps in /opt/bitnami/apps/moodle/htdocs/auth/enrolkey/enrolkey_signup_form.php on line 48

Notice: Undefined property: stdClass::$loginhttps in /opt/bitnami/apps/moodle/htdocs/auth/enrolkey/enrolkey_signup_form.php on line 62

Sorry, the requested file could not be found
More information about this error

Debug info: core/enrolkey_signup_form
Error code: filenotfound


Stack trace:

    line 123 of /lib/classes/output/mustache_template_finder.php: moodle_exception thrown
    line 54 of /lib/classes/output/mustache_filesystem_loader.php: call to core\output\mustache_template_finder::get_template_filepath()
    line 99 of /lib/mustache/src/Mustache/Loader/FilesystemLoader.php: call to core\output\mustache_filesystem_loader->getFileName()
    line 82 of /lib/mustache/src/Mustache/Loader/FilesystemLoader.php: call to Mustache_Loader_FilesystemLoader->loadFile()
    line 657 of /lib/mustache/src/Mustache/Engine.php: call to Mustache_Loader_FilesystemLoader->load()
    line 188 of /lib/outputrenderers.php: call to Mustache_Engine->loadTemplate()
    line 239 of /lib/outputrenderers.php: call to renderer_base->render_from_template()
    line 117 of /login/signup.php: call to renderer_base->render()

Password Reset Functionality Disabled

If enrollment key authentication is set on a student's profile, they are unable to change their password. The pass reset feature "appears" to work for them and admins. But the system refuses to accept any password beyond the pass used during registration. System admins also cannot alter passwords for these students.

I have discovered there must be additional script written into the auth.php file. By adding a new command to the existing code, I was able to restore the functionality for my students who are enrolled with enrollment key authentication. Here is that script addendum:

function user_login($username, $password) {
        global $CFG, $DB;
        if ($user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id))) {
            return validate_internal_user_password($user, $password);
        }

        return false;
    }

    function user_update_password($user, $newpassword) {
        $user = get_complete_user_data('id', $user->id);
        return update_internal_user_password($user, $newpassword);
    }

    function can_signup() {
        return true;
    }

    function can_change_password() {
        return true;
    }

    function can_reset_password() {
        return true;
    }

I fixed ours, happily. I'm sure you guys know what to do with this to fix your's. Hope this help!

Users being Deleted on completion of course

My users are enrolling into Groups using the enrol key authorisation, with Group Enrolment Keys.
This is working successfully, and the Enrolment duration is set to 300 days.
Unenrol inactive is set to "Never"

However, it appears that users are being deleted from the system (with no trace) once they complete the course.

My local tech support has diagnosed the following:
_"The user account is tied to the enrolment on the course (Their authentication type is set to enrolkey) so when the enrolment ends their account is removed. You will ned to use a different authentication type for your users (manual or email based probably) which removes the connection from the user's account to the enrolment of the course."

"Unless there is an option causing the user to be unenrolled on course completion that would trigger the deletion of the user I'm not sure what the issue would be."_

Can anyone help please?

Add support for email confirmation

Perhaps make this a config item. Once logging in directly re-using the token is implemented then in theory you don't need an email address at all.

Some social fields have been removed in Totara 13+

In particular from TL-24339.

As such they should be optionally added only if the field is supported.

This affects this page auth/enrolkey/edit_profile.php?id=2 which is for Manage enrolkey cohort rules

Login page broken in 3.2

HI Brendan,

Great pluggin!
Tested it for 3.2 but after visiting: /login/signup.php? i get the error
Can not render widget, renderer method (render_enrolkey_signup_form) not found.
I know it is not supported yet for 3.2, any idea on when it will be?

Regards Rob

Add ability to lock fields

I would like to see the ability to lock fields from beeing edited, like I can do with manual or LDAP authentication.

Use Case: If you have both users who authenticate via LDAP, whose profile fields are partly filled with information by LDAP and users who use this plugin, you might want to lock the same fields (or a common set of fields).

Example: From LDAP you map the 'department' field with departments or grade-levels in your institution. Every member of your institution authenticates with LDAP. The field is locked.
To allow guests to register for special classes, you use this plugin. Those users dont need any value in the department field. But users can edit the field in their profile, although they should'nt.

Problem: If the information in a profile field has functional use (e.g. to automatically be added into a cohort) their is actually a security issue. If its just for information, then filtering by those fields might show 'guest' users in e.g. a search result, if they edited their profile accordingly.

Workaround: Use custom-profile-fields, which duplicate the original profile field. Those can be hidden. That way the orignial fields are used to display the informaiton to the user, the custom-fields for functional use only. Downside: Users who authenticate with this plugin can still write something in the profile fields, although it has no meaning for them.

The code can propably be copied from the LDAP authentication plugin, or the manual authentication.

Changed hardcoded URL to use moodle_url

Originally submitted by Rex Lorenzo in https://moodle.org/plugins/auth_enrolkey

The code is very clean. Tested PHPunit and manual testing, works. I did encounter a bug. On the confirmation page (view.php), the "Click here to view the course" URL assumes that the website is located at root.

See https://github.com/nhoobin/moodle-auth_enrolkey/blob/master/view.php#L59

This should be changed to use moodle_url. My test moodle instance is http://localhost:8888/moodle, but the link tries to go to http://localhost:8888/course/view.php?id=2

Some concerns:

  • The step up instruction "On the same page that you manage authentication options, scroll down to the common settings and select Enrolment key based self-registration in the Self Registration drop down list for registerauth." was a little confusing. I had to read it 3 times over to understand what I had to do next.
  • On large installs, the chance that two or more courses will inadvertently share an enrollment key is high. Maybe a warning to site admins before they install this plugin? Or a step after registration that confirms to the user what course they actually want to sign up for?

But works as advertised, the code is great, and should be okay to be released.

data protection policy shown twice before and after signup

With regular auth with e-mail-confirmation the policy is shown and has to be checked before the signup form appears. The the form, then the policy is never shown again.

With the auth_enrolkey it happens twice: the policy is shown and needs to be checked once more right after the form is submitted.

In both cases the policiy is set to be mandatory for authenticated users the exact same way.

Manage enrolkey cohort rules, edit fields: Invalid property requested: url

I have the Auto-cohort plugin installed which seems to be requisite to assign cohorts.

However I would like to use the edit fields feature but get the following error:

Coding error detected, it must be fixed by a programmer: Invalid property requested: url

More information about this error
Debug info:
Error code: codingerror
Stack trace:

line 848 of /lib/classes/user.php: coding_exception thrown
line 61 of /auth/enrolkey/classes/form/enrolkey_profile_form.php: call to core_user::get_property_type()
line 214 of /lib/formslib.php: call to auth_enrolkey\form\enrolkey_profile_form->definition()
line 45 of /auth/enrolkey/edit_profile.php: call to moodleform->__construct()

Please let me know if there is an easy fix.

file could not be found

moodle version 3.10

After installing this plugin when I click Create new account button it gives following error
Sorry, the requested file could not be found

and browser address bar is showing www.domainname.com/login/signup.php

I am unable to uninstall also. While trying to uninstall it is showing 403 page.

any idea

When token not mandatory and none given, problems occur when there are courses with self-enrolment and empty tokens

I was just wondering if this is by design:

  • Have some courses with self-enrolment but WITHOUT tokens.
  • In the settings for enrolkey:
  • Set 'Require enrolment key for validation' to No
  • Set 'Require email confirmation' to Yes
  • Create a new user but keep the field for the token empty
  • Two "problems" now:
  • User is enrolled in the first course that has an empty token with self-enrolment.
  • For all other courses with empty token an error is shown (to the user)
  • Because of these errors, the email confirmation is not send AND the user is also automatically logged in (!)

I think it is more logical to ignore empty tokens.

A very dirty quick hack to show how to 'fix' it:

auth.txt

Can not find data record in database table course.

After clicking on "Create my new account" on the Sign Up screen, when leaving Enrollment Key blank, instead of getting the confirmation email, the following error is displayed: "Can not find data record in database table course." and the new user is logged in directly into Moodle.

Thanks!

In debugging mode:

Notice: Trying to get property of non-object in /var/www/ce_moodle/auth/enrolkey/view.php on line 43

Notice: Trying to get property of non-object in /var/www/ce_moodle/auth/enrolkey/view.php on line 45
Can not find data record in database table course.

More information about this error

×Debug info: SELECT id,category FROM {course} WHERE id IS NULL
[array (
)]
Error code: invalidrecord
×Stack trace:
line 1502 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
line 1478 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 6952 of /lib/accesslib.php: call to moodle_database->get_record()
line 45 of /auth/enrolkey/view.php: call to context_course::instance()

invalid key

Thanks for listening to the users.
I have tried to update the plugin, but when I want to log in as a user, I get this response:

The enrolment key you have entered is invalid

Do you have any idea how to solve it. I use Moodle 2.8.

Thanks
Arash

e-mail-confirmation setting to "no" not working

I am testing the plugin on a Moodle 3.5 Site. Everything is set up as described. When trying to sign up with an enrolment key, I get this error (with verbose debugging):

enrolmentkey-error01

The new user is created, but he still needs to confirm his E-Mail, though that is set to "no" in the plugin settings. Also the user is not enrolled in the course with the resp. enrolment key.

While there may also be a problem with our mailsettings, the plugin should not try to send any e-mail at all. Any idea, why the setting does not work?

Error code: coding error

Hi,
There seems to be kind of functionality issues when trying to create a new account. When I click on "New account" or "create new account" all I can see are some errors.

`Coding error detected, it must be fixed by a programmer: Can not render widget, renderer method (render_enrolkey_signup_form) not found.
Debug info:
Error code: codingerror

Stack trace:
line 212 of /lib/outputrenderers.php: coding_exception thrown
line 108 of /login/signup.php: call to renderer_base->render()`

enrolkey

I think it may be the version that I am using, this error occurred on 3.3

moodle-auth_enrolkey

I'd really like to use this with Moodle 3.11. I understand you are busy and resources are limited. My financial resources at the moment are limited as well but I do have some time to poke around in the code and try to help get this working on 3.11. I am, however, not a professional coder by any means...more of a wanna-be hacker.

I've installed this plugin on Moodle 3.11 without any errors and see that it runs without throwing any errors when debugging is enabled.

The plugin accurately tests for an empty enrollment key, when one is required and displays the subsequent error message.

It does not, however, correctly match enrollment keys and thus prevents new users even when they have supplied a correct (matching) enrollment key throwing the error:

"The enrolment key you have entered is invalid"

If you could point me in the correct direction, I will experiment and see what I can achieve...and, of course, share any progress.

Regards

Jason

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.