├── README.md ├── lang └── en │ └── auth_kahoodle.php ├── version.php └── auth.php /README.md: -------------------------------------------------------------------------------- 1 | Please do not use! This is for demo only and very temporary 2 | -------------------------------------------------------------------------------- /lang/en/auth_kahoodle.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * English language pack for Kahoodle quick auth 19 | * 20 | * @package auth_kahoodle 21 | * @category string 22 | * @copyright Marina Glancy 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | defined('MOODLE_INTERNAL') || die(); 27 | 28 | $string['pluginname'] = 'Kahoodle quick auth'; 29 | -------------------------------------------------------------------------------- /version.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Version information for Kahoodle quick auth 19 | * 20 | * @package auth_kahoodle 21 | * @copyright Marina Glancy 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die(); 26 | 27 | $plugin->component = 'auth_kahoodle'; 28 | $plugin->release = '1.0'; 29 | $plugin->version = 2025090300; 30 | $plugin->requires = 2024100700; 31 | $plugin->supported = [405, 500]; 32 | $plugin->maturity = MATURITY_STABLE; 33 | -------------------------------------------------------------------------------- /auth.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Main class for the Kahoodle quick auth authentication plugin 19 | * 20 | * Documentation: {@link https://docs.moodle.org/dev/Authentication_plugins} 21 | * 22 | * @package auth_kahoodle 23 | * @copyright Marina Glancy 24 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 | */ 26 | 27 | defined('MOODLE_INTERNAL') || die(); 28 | 29 | require_once($CFG->libdir . '/authlib.php'); 30 | 31 | /** 32 | * Authentication plugin auth_kahoodle 33 | * 34 | * @package auth_kahoodle 35 | * @copyright Marina Glancy 36 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 | */ 38 | class auth_plugin_kahoodle extends auth_plugin_base { 39 | 40 | /** 41 | * Constructor. 42 | */ 43 | public function __construct() { 44 | $this->authtype = 'kahoodle'; 45 | } 46 | 47 | public function create_fake_user(string $name) { 48 | global $CFG, $DB; 49 | require_once("$CFG->dirroot/user/lib.php"); 50 | $user = new stdClass(); 51 | $user->email = $this->generate_random_email(); 52 | $user->username = $this->generate_random_username(); 53 | $user->firstname = $name; 54 | $user->lastname = '.'; 55 | $user->confirmed = 1; 56 | $user->auth = $this->authtype; 57 | $user->mnethostid = $CFG->mnet_localhost_id; 58 | $userid = user_create_user($user, false, true); 59 | $newuser = $DB->get_record('user', ['id' => $userid]); 60 | complete_user_login($newuser); 61 | } 62 | 63 | protected function generate_random_username() { 64 | return strtolower('kahoodle_'.random_string(20)); 65 | // TODO check unique 66 | } 67 | 68 | protected function generate_random_email() { 69 | return 'kahoodle_'.random_string(20).'@example.invalid'; 70 | // TODO check unique 71 | } 72 | } 73 | --------------------------------------------------------------------------------