moodle增加用户,建立课程,选课(注册)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了moodle增加用户,建立课程,选课(注册)相关的知识,希望对你有一定的参考价值。
添加用户:$user参数是对象类型的的参数
user_create_user($user)
moodle自带的添加用户的函数在:user/lib.php
完整的代码
require_once(‘../config.php‘);
require_once(‘../user/lib.php‘);
$user = new stdClass();
$user->auth = ‘manual‘;
$user->confirmed = 1;
$user->mnethostid = 1;
$user->lastlogin = time();
$user->currentlogin = time();
$user->username = "lichihua6";
$user->firstname = "李四6";
$user->lastname = "老师";
$user->email="[email protected]";
//$user->password = hash_internal_user_password(‘123‘);自带的函数不需要加上这个加密函数了,自己写sql的话还是需要的
$user->password = "A0205#lg";
$person->city = "sf";
$person->country = "US";
$person->lang = "en";
//执行添加任务
user_create_user($user);
建课程:create_course($data, $editoroptions=null)
在 course/lib.php下定义的
require_once(‘../config.php‘);
require_once(‘../course/lib.php‘);
//create_course($data, $editoroptions=null);
$data=new stdClass();
$data->category=3;
$data->shortorder=‘30002‘;
$data->fullname="平面设计";
$data->shortname="12345";
$data->idnumber="12345";
$data->summary="这是课程简介";
$data->summaryformat= 1;
$data->format="topics";
$data->showgrades=1;
$data->newsitems=5;
$data->startdate=time();
$data->maxbytes=2097152;
$data->visible=1;
$data->visibleold=1;
$data->timecreated=time();
$data->timemodified=time();
$data->enablecompletion=1;
$data->cacherev=time();
create_course($data);
moodle 密码的加密的两种办法
方法1:
$password = “new password”;
$moodle_password = md5($password.$CFG->passwordsaltmain);
方法2:
$moodle_password = hash_internal_user_password($password);
以上是关于moodle增加用户,建立课程,选课(注册)的主要内容,如果未能解决你的问题,请参考以下文章