LTI fix role_score_mentor param - refs BT#13469

pull/2731/head
Angel Fernando Quiroz Campos 7 years ago
parent 787eceee8c
commit 8628fa6fce
  1. 32
      plugin/ims_lti/ImsLtiPlugin.php
  2. 4
      plugin/ims_lti/form.php

@ -298,18 +298,22 @@ class ImsLtiPlugin extends Plugin
*/ */
public static function getUserRoles(User $user) public static function getUserRoles(User $user)
{ {
if (DRH === $user->getStatus()) {
return 'urn:lti:role:ims/lis/Mentor';
}
if ($user->getStatus() === INVITEE) { if ($user->getStatus() === INVITEE) {
return 'Learner/GuestLearner,Learner'; return 'Learner,urn:lti:role:ims/lis/Learner/GuestLearner';
} }
if (!api_is_allowed_to_edit(false, true)) { if (!api_is_allowed_to_edit(false, true)) {
return 'Learner,Learner/Learner'; return 'Learner';
} }
$roles = ['Instructor']; $roles = ['Instructor'];
if (api_is_platform_admin_by_id($user->getId())) { if (api_is_platform_admin_by_id($user->getId())) {
$roles[] = 'Administrator/SystemAdministrator'; $roles[] = 'urn:lti:role:ims/lis/Administrator';
} }
return implode(',', $roles); return implode(',', $roles);
@ -331,24 +335,22 @@ class ImsLtiPlugin extends Plugin
} }
/** /**
* @param Course $course * @param User $currentUser
* @param Session|null $session
* *
* @return string * @return string
*/ */
public static function getRoleScopeMentor(Course $course, Session $session = null) public static function getRoleScopeMentor(User $currentUser)
{ {
$scope = []; if (DRH !== $currentUser->getStatus()) {
return '';
if ($session) {
$students = $session->getUserCourseSubscriptionsByStatus($course, Session::STUDENT);
} else {
$students = $course->getStudents();
} }
/** @var SessionRelCourseRelUser|CourseRelUser $subscription */ $followedUsers = UserManager::get_users_followed_by_drh($currentUser->getId());
foreach ($students as $subscription) {
$scope[] = self::generateToolUserId($subscription->getUser()->getId()); $scope = [];
foreach ($followedUsers as $userInfo) {
$scope[] = self::generateToolUserId($userInfo['user_id']);
} }
return implode(',', $scope); return implode(',', $scope);

@ -89,8 +89,8 @@ if ($tool->isSharingEmail()) {
$params['lis_person_contact_email_primary'] = $user->getEmail(); $params['lis_person_contact_email_primary'] = $user->getEmail();
} }
if (api_is_allowed_to_edit(false, true)) { if (DRH === $user->getStatus()) {
$scopeMentor = ImsLtiPlugin::getRoleScopeMentor($course, $session); $scopeMentor = ImsLtiPlugin::getRoleScopeMentor($user);
if (!empty($scopeMentor)) { if (!empty($scopeMentor)) {
$params['role_scope_mentor'] = $scopeMentor; $params['role_scope_mentor'] = $scopeMentor;

Loading…
Cancel
Save