本文整理汇总了PHP中EfrontUser::isProfessorRole方法的典型用法代码示例。如果您正苦于以下问题:PHP EfrontUser::isProfessorRole方法的具体用法?PHP EfrontUser::isProfessorRole怎么用?PHP EfrontUser::isProfessorRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EfrontUser
的用法示例。
在下文中一共展示了EfrontUser::isProfessorRole方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addUsers
/**
* Add users to course
*
* This function is used to register one or more users to the current course. A single login
* or an array of logins may be specified
* <br/>Example:
* <code>
* $course -> addUsers('joe', 'professor'); //Add the user with login 'joe' as a professor to this course
* $users = array('joe', 'mary', 'mike');
* $types = array('student', 'student', 'professor');
* $course -> addUsers($users, $types); //Add the users in the array $users with roles $types
* </code>
*
* @param mixed $login The user login name
* @param mixed $role The user role for this course, defaults to 'student'
* @param boolean $confirmed If false, then the registration is set to 'pending' mode and the administration must confirm it
* @since 3.5.0
* @access public
* @todo deprecated
*/
public function addUsers($users, $userRoles = 'student', $confirmed = true)
{
if ($this->course['supervisor_LOGIN']) {
$confirmed = false;
}
$roles = EfrontUser::getRoles();
$users = EfrontUser::verifyUsersList($users);
$userRoles = EfrontUser::verifyRolesList($userRoles, sizeof($users));
foreach ($userRoles as $key => $value) {
if (!EfrontUser::isStudentRole($value) && !EfrontUser::isProfessorRole($value)) {
unset($userRoles[$key]);
unset($users[$key]);
}
}
if (empty($users)) {
return false;
}
//For a single user, don't retrieve the full list of course users; that can be indefinitely big
if (sizeof($users) == 1) {
$result = eF_getTableData("users_to_courses uc, users u", "uc.users_LOGIN, uc.archive, uc.user_type, uc.to_timestamp, u.archive as user_archive, uc.completed", "u.login = '{$users[0]}' and u.login=uc.users_LOGIN and uc.courses_ID=" . $this->course['id']);
} else {
$result = eF_getTableData("users_to_courses uc, users u", "uc.users_LOGIN, uc.archive, uc.user_type, uc.to_timestamp, u.archive as user_archive, uc.completed", "u.login=uc.users_LOGIN and uc.courses_ID=" . $this->course['id']);
}
$courseUsers = array();
$courseRoles = $this->getPossibleCourseRoles();
$courseStudents = 0;
foreach ($result as $value) {
$courseUsers[$value['users_LOGIN']] = $value;
if (!$value['user_archive'] && !$value['archive'] && EfrontUser::isStudentRole($value['user_type'])) {
$courseStudents++;
}
}
/*This query returns an array like:
+------------+------------+-------------+-----------+----------------+---------+
| courses_ID | lessons_ID | users_login | user_type | from_timestamp | archive |
+------------+------------+-------------+-----------+----------------+---------+
| 1 | 3 | professor | professor | 1233140503 | 0 |
| 1 | 3 | elpapath | professor | 1233140503 | 0 |
| 1 | 19 | periklis3 | student | 1280488977 | 0 |
| 1 | 20 | NULL | NULL | NULL | NULL |
+------------+------------+-------------+-----------+----------------+---------+
So that it contains all the course's lessons and NULL for any lesson that does not have a user assigned
*/
$result = eF_getTableData("lessons_to_courses lc left outer join users_to_lessons ul on lc.lessons_ID=ul.lessons_ID", "lc.lessons_ID, ul.users_LOGIN, ul.user_type, ul.from_timestamp, ul.archive, ul.to_timestamp, ul.completed", "courses_ID = " . $this->course['id']);
$courseLessonsToUsers = array();
foreach ($result as $value) {
if (!is_null($value['users_LOGIN'])) {
$courseLessonsToUsers[$value['lessons_ID']][$value['users_LOGIN']] = $value;
} else {
$courseLessonsToUsers[$value['lessons_ID']] = array();
}
}
$courseLessons = array_unique(array_keys($courseLessonsToUsers));
$result = eF_getTableData("projects", "id, lessons_ID", "auto_assign=1 and deadline >= " . time() . " and lessons_ID in (select lessons_ID from lessons_to_courses where courses_ID=" . $this->course['id'] . ")");
$newProjectAssignments = $courseLessonsAutoAssignProjects = $assignedProjectsToUsers = array();
foreach ($result as $value) {
$courseLessonsAutoAssignProjects[$value['lessons_ID']][] = $value['id'];
}
$result = eF_getTableData("users_to_projects up, projects p", "up.users_LOGIN, up.projects_ID", "up.projects_ID=p.id and p.auto_assign=1 and p.deadline >= " . time() . " and p.lessons_ID in (select lessons_ID from lessons_to_courses where courses_ID=" . $this->course['id'] . ")");
foreach ($result as $value) {
$assignedProjectsToUsers[$value['users_LOGIN']][$value['projects_ID']] = $value['projects_ID'];
}
$newUsers = array();
$existingUsers = array();
foreach ($users as $key => $user) {
$roleInCourse = $userRoles[$key];
$roles[$roleInCourse] == 'student' ? $isStudentRoleInCourse = true : ($isStudentRoleInCourse = false);
if ($this->course['max_users'] && $isStudentRoleInCourse && $this->course['max_users'] <= $courseStudents++) {
throw new EfrontCourseException(str_replace(array("%x", "%y", "%z"), array($this->course['name'], $this->course['max_users'], $GLOBALS['configuration']['system_email']), _MAXSEATSDEPLEATED), EfrontCourseException::MAX_USERS_LIMIT);
}
if (!isset($courseUsers[$user])) {
$newUsers[] = array('users_LOGIN' => $user, 'courses_ID' => $this->course['id'], 'active' => 1, 'archive' => 0, 'from_timestamp' => $confirmed ? time() : 0, 'user_type' => $roleInCourse, 'completed' => 0, 'score' => 0, 'issued_certificate' => '', 'comments' => '', 'to_timestamp' => 0);
} elseif ($roleInCourse != $courseUsers[$user]['user_type'] || $courseUsers[$user]['archive']) {
//update from_timestamp value when user reassigned to a course (only if it is not completed)
if ($courseUsers[$user]['completed']) {
$fields = array('archive' => 0, 'user_type' => $roleInCourse);
} else {
$fields = array('archive' => 0, 'user_type' => $roleInCourse, 'from_timestamp' => time());
}
//!$courseUsers[$user]['archive'] OR $fields['to_timestamp'] = 0;
//.........这里部分代码省略.........