示例#1
0
 /**
  *
  *
  * @param \LTI_Tool_Provider $toolProvider
  * @return bool|string
  */
 public function doLaunch($toolProvider)
 {
     tklog('---> doLaunch() ');
     // Check the user has an appropriate role
     if ($toolProvider->user->isLearner() || $toolProvider->user->isStaff() || $toolProvider->user->isAdmin()) {
         // Initialise the user/Lti session
         $permissions = array();
         if ($toolProvider->user->isLearner()) {
             $permissions[] = 'student';
         }
         if ($toolProvider->user->isStaff()) {
             $permissions[] = 'staff';
         }
         if ($toolProvider->user->isAdmin()) {
             $permissions[] = 'admin';
         }
         $ldapUser = null;
         if (isset($_POST['lis_person_contact_email_primary'])) {
             // Enable if using LDAP for extra data
             //                $ldapUser = $this->getLdapUser($_POST['lis_person_contact_email_primary']);
         }
         $data = array('consumerKey' => $toolProvider->consumer->getKey(), 'resourceId' => $toolProvider->resource_link->getId(), 'userConsumerKey' => $toolProvider->user->getResourceLink()->getConsumer()->getKey(), 'userId' => $toolProvider->user->getId(), 'permissions' => $permissions, 'ldapUser' => $ldapUser, 'launchRequest' => array_merge($_POST, $_GET));
         \Ext\LtiSession::getInstance($data);
         \Tk\Url::create('/lti/index.html')->redirect();
     }
     $toolProvider->reason = 'Invalid role.';
     return false;
 }
示例#2
0
 /**
  * Get the current lti session data if it exists.
  * Returns null if not lti session exists
  *
  * @param null $data
  * @return \Ext\LtiSession
  */
 public function getLtiSession($data = null)
 {
     if (!$this->exists('res.lti.session')) {
         $this->set('res.lti.session', \Ext\LtiSession::getInstance($data));
     }
     return $this->get('res.lti.session');
 }