function scorm_get_tincan_launch_params($scorm, $sco, $launchUrl)
{
    global $CFG, $USER;
    require_once $CFG->dirroot . '/local/tcapi/locallib.php';
    // verify tcapi plugin exists, if not, return nothing
    if (!file_exists($CFG->dirroot . '/local/tcapi/locallib.php')) {
        return '';
    }
    // Call the TCAPI local webservice locallib for token and endpoint.
    $token = local_tcapi_get_user_token();
    // Generate activity_id as unique using URI method (also provides LRS with metadata path)
    $activity_id = str_ireplace($sco->launch, 'tincan.xml', $launchUrl);
    // Determine connector for launch params.
    $connector = stripos($sco->launch, '?') !== false ? '&' : '?';
    // build a registration (not used for anything at this time)
    $registration = md5($USER->id . $sco->id);
    // add version (not used for anything at this time)
    $revision = $scorm->revision;
    // gather all the launch params
    $launch_params = array('endpoint' => TCAPI_ENDPOINT, 'auth' => $token->token, 'moodle_mod' => 'scorm', 'moodle_mod_id' => $sco->id, 'revision' => $revision, 'registration' => $registration, 'activity_id' => $activity_id);
    // Webservice content address for content endpoint (Articulate Mobile Player)
    // Only provide if using the pluginfile.php method for delivery.
    if ($pos = strpos($launchUrl, '/pluginfile.php')) {
        $wscontenturl = substr($launchUrl, $pos, strlen($sco->launch) * -1);
        $wscontenturl = str_ireplace('/pluginfile.php', '/', $wscontenturl);
        $launch_params['content_endpoint'] = TCAPI_CONTENT_ENDPOINT . $wscontenturl;
        $launch_params['content_token'] = $token->token;
    }
    $params_encoded = array();
    foreach ($launch_params as $lk => $lv) {
        array_push($params_encoded, $lk . '=' . rawurlencode($lv));
    }
    // Build and return content launch string
    return $connector . implode("&", $params_encoded);
}
	function getXml () {
		global $CFG;
		$search = "$CFG->wwwroot/pluginfile.php/";
		if (substr($this->xmlUrl,0,strlen($search)) == $search) {
			$url = str_replace('pluginfile.php', 'webservice/pluginfile.php', clean_param($this->xmlUrl, PARAM_LOCALURL));
			// Determine connector for launch params.
			$connector = (stripos($url, '?') !== false) ? '&' : '?';
			if ($token = local_tcapi_get_user_token())
				return file_get_contents($url.$connector.'token='.$token->token);
		}
		else
			return file_get_contents($this->xmlUrl);
		array_push($this->errors,'User token required but not valid/found.');
		return '';
	}