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

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

Loading…
Cancel
Save