本文整理汇总了PHP中EfrontUser::isStudentRole方法的典型用法代码示例。如果您正苦于以下问题:PHP EfrontUser::isStudentRole方法的具体用法?PHP EfrontUser::isStudentRole怎么用?PHP EfrontUser::isStudentRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EfrontUser
的用法示例。
在下文中一共展示了EfrontUser::isStudentRole方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
//.........这里部分代码省略.........
示例2: checkUserAccessToLessonBasedOnDuration
private function checkUserAccessToLessonBasedOnDuration($lesson)
{
//pr($lesson);
if ($lesson->lesson['duration'] && $lesson->lesson['active_in_lesson']) {
$lesson->lesson['remaining'] = $lesson->lesson['active_in_lesson'] + $lesson->lesson['duration'] * 3600 * 24 - time();
} else {
$lesson->lesson['remaining'] = null;
}
//Check whether the lesson registration is expired. If so, set $value['from_timestamp'] to false, so that the effect is to appear disabled
if (EfrontUser::isStudentRole($lesson->lesson['user_type']) && $lesson->lesson['duration'] && $lesson->lesson['active_in_lesson'] && $lesson->lesson['duration'] * 3600 * 24 + $lesson->lesson['active_in_lesson'] < time()) {
$lesson->archiveLessonUsers($lesson->lesson['users_LOGIN']);
}
return $lesson;
}
示例3: addUsersToLesson
/**
* Add the user in the lesson having the specified role
*
* @param string $user The user's login
* @param mixed $roleInLesson the user's role in the lesson
* @since 3.6.1
* @access protected
*/
private function addUsersToLesson($usersData)
{
$autoAssignedProjects = $this->getAutoAssignProjects();
$archivedLessonUsers = $this->getArchivedUsers();
$newUsers = array();
$options = unserialize($this->lesson['options']);
$positions = $options['default_positions'];
foreach ($usersData as $value) {
if (in_array($value['login'], $archivedLessonUsers)) {
//Update only fields not related to progress
$updateFields = array('active' => 1, 'archive' => 0, 'from_timestamp' => $value['confirmed'] ? time() : 0, 'user_type' => $value['role'], 'access_counter' => 0);
eF_updateTableData("users_to_lessons", $updateFields, "users_LOGIN='" . $value['login'] . "' and lessons_ID=" . $this->lesson['id']);
} else {
$newUsers[] = $value['login'];
$fields[] = array('users_LOGIN' => $value['login'], 'lessons_ID' => $this->lesson['id'], 'active' => 1, 'archive' => 0, 'from_timestamp' => $value['confirmed'] ? time() : 0, 'user_type' => $value['role'], 'positions' => '', 'done_content' => '', 'current_unit' => 0, 'completed' => 0, 'score' => 0, 'comments' => '', 'positions' => $positions, 'to_timestamp' => 0);
}
}
if (!empty($newUsers)) {
eF_insertTableDataMultiple("users_to_lessons", $fields);
foreach ($autoAssignedProjects as $project) {
$project->addUsers($newUsers);
}
}
if (!defined(_DISABLE_EVENTS) || _DISABLE_EVENTS !== true) {
foreach ($usersData as $value) {
$event = array("type" => EfrontUser::isStudentRole($value['role']) ? EfrontEvent::LESSON_ACQUISITION_AS_STUDENT : EfrontEvent::LESSON_ACQUISITION_AS_PROFESSOR, "users_LOGIN" => $value['login'], "lessons_ID" => $this->lesson['id'], "lessons_name" => $this->lesson['name']);
EfrontEvent::triggerEvent($event);
if (EfrontUser::isStudentRole($value['role'])) {
$event = array("type" => -1 * EfrontEvent::LESSON_COMPLETION, "users_LOGIN" => $value['login'], "lessons_ID" => $this->lesson['id'], "lessons_name" => $this->lesson['name'], "replace" => true, "create_negative" => false);
EfrontEvent::triggerEvent($event);
}
}
}
}