Reads data for an event.
@param [String => Mixed] $opts
@return [String => Mixed]
@override AttemtStarted
195696
public function read(array $opts) {
        if(isset($opts['attempt']->timefinish)){
            $seconds = $opts['attempt']->timefinish - $opts['attempt']->timestart;
            $duration = "PT".(string) $seconds."S";
        }
        else{
            $duration = "PT0S";
        }

        $scoreRaw = isset($opts['attempt']->sumgrades) ? $opts['attempt']->sumgrades : 0;
        $scoreMin = (float) ($opts['grade_items']->grademin ?: 0);
        $scoreMax = (float) ($opts['grade_items']->grademax ?: 0);
        $scorePass = (float) ($opts['grade_items']->gradepass ?: null);
        $success = false;
        // If there is no passing score then success is unknown.
        if ($scorePass == null) {
            $success = null;
        }
        elseif ($scoreRaw >= $scorePass) {
            $success = true;
        }

        // It's possible to configure Moodle quizzes such that you can score higher than the maximum grade. 
        // This is not allowed by xAPI, so cap the raw at the min/max. 
        if ($scoreRaw > $scoreMax) {
            $scoreRaw = $scoreMax;
        }
        if ($scoreRaw < $scoreMin) {
            $scoreRaw = $scoreMin;
        }

        // Calculate scaled score as the distance from zero towards the max (or min for negative scores).
        if ($scoreRaw >= 0) {
            $scoreScaled = $scoreRaw / $scoreMax;
        }
        else {
            $scoreScaled = $scoreRaw / $scoreMin;
        }

        //Determine if the attempt was marked finished
        if(isset($opts['attempt']->state)){
            $completedState = $opts['attempt']->state === 'finished';
        }
        else{
            $completedState = false;
        }

        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'attempt_completed',
            'attempt_score_raw' => $scoreRaw,
            'attempt_score_min' => $scoreMin,
            'attempt_score_max' => $scoreMax,
            'attempt_score_scaled' => $scoreScaled,
            'attempt_success' => $success,
            'attempt_completed' => $completedState,
            'attempt_duration' => $duration,
        ])];
    }
362603
public static function all($params, $opts = null)
    {
        $list = parent::all($params, $opts);
        $ntList = new NotificationCollection();
        $ntList->install($list->values, $list->opts);
        return $ntList;
    }
308282
protected function createClient(array $opts=[])
  {
    if ( !$this->guzzleClient ) {
      $this->guzzleClient = new \GuzzleHttp\Client();
      $this->cookieJar = new \GuzzleHttp\Cookie\CookieJar();
    }

    return $this->guzzleClient;
  }
659697
public function phar($opts = ['neuralyzer-version' => 'dev'])
    {
        if ((int)ini_get('phar.readonly') === 1) {
            throw new \RuntimeException(
                'You must have phar.readonly = 1 or run' . PHP_EOL .
                'php -d phar.readonly=0 vendor/bin/robo (phar|release)'
            );
        }
        // Create a collection builder to hold the temporary
        // directory until the pack phar task runs.Call to undefined method RoboFile::startProgressIndicator()
        $collection = $this->collectionBuilder();
        $workDir = $collection->tmpDir();
        $buildDir = "$workDir/neuralyzer";

        $prepTasks = $this->collectionBuilder();
        $preparationResult = $prepTasks
            ->taskFilesystemStack()
                ->mkdir($workDir)
                ->taskCopyDir([__DIR__ . '/src' => $buildDir . '/src'])
            ->taskFilesystemStack()
                ->copy(__DIR__ . '/bin/neuralyzer', $buildDir . '/bin/neuralyzer')
                ->copy(__DIR__ . '/composer.json', $buildDir . '/composer.json')
                ->copy(__DIR__ . '/composer.lock', $buildDir . '/composer.lock')
                ->copy(__DIR__ . '/LICENSE', $buildDir . '/LICENSE')
                ->copy(__DIR__ . '/README.md', $buildDir . '/README.md')

            ->taskComposerInstall()
                ->dir($buildDir)
                ->noDev()
                ->noScripts()
                ->printOutput(true)
                ->optimizeAutoloader()
                ->run();

        // Exit if the preparation step failed
        if (!$preparationResult->wasSuccessful()) {
            return $preparationResult;
        }

        $currentVersion = \Edyan\Neuralyzer\Console\Application::VERSION;
        $this->say("Setting version number to {$opts['neuralyzer-version']}");
        $this->taskReplaceInFile($buildDir . '/src/Console/Application.php')
             ->from("const VERSION = '$currentVersion';")
             ->to("const VERSION = '{$opts['neuralyzer-version']}';")
             ->run();

        $this->say("Force Robo to compress up to 1500 files in a phar");
        $this->taskReplaceInFile(__DIR__ . '/vendor/consolidation/robo/src/Task/Development/PackPhar.php')
             ->from('if (count($this->files) > 1000)')
             ->to('if (count($this->files) > 1500)')
             ->run();


        // Decide which files we're going to pack
        $files = \Symfony\Component\Finder\Finder::create()
            ->ignoreVCS(true)
            ->files()
            ->name('*.php')
            ->name('*.exe') // for symfony/console/Resources/bin/hiddeninput.exe
            ->path('src')
            ->path('vendor')
            ->notPath('docs')
            ->notPath('/vendor\/.*\/[Tt]est/')
            // incomplete and need to reduce for phar compression
            //->notPath('ro_MD')
            //->notPath('sr_Cyrl_RS')
            //->notPath('sr_Latn_RS')
            ->in(is_dir($buildDir) ? $buildDir : __DIR__);

        $fakerLang = \Symfony\Component\Finder\Finder::create()
            ->ignoreVCS(true)
            ->files()
            ->name('*')
            ->path('src/Faker/Dictionary')
            ->in(is_dir($buildDir) ? $buildDir : __DIR__);

        // Build the phar
        return $collection
            ->taskPackPhar('neuralyzer.phar')
                ->compress()
                ->addFile('bin/neuralyzer', 'bin/neuralyzer')
                ->addFile('config/services.yml', 'config/services.yml')
                ->addFiles($files)
                ->addFiles($fakerLang)
                ->executable('bin/neuralyzer')
            ->taskFilesystemStack()
                ->chmod(__DIR__ . '/neuralyzer.phar', 0755)
            ->run();
    }
348910
public function read(array $opts) {

        $sessionName = 'Session '.$opts['session']->id.' of '.$opts['module']->name;
        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'training_session_enrol',
            'session_url' => $opts['session']->url,
            'session_name' => $sessionName,
            'session_description' => $sessionName,
            'session_type' => 'http://activitystrea.ms/schema/1.0/event',
        ])];
    }
727852
function _Options($opts)
	{
		if (!is_array($opts)) return array();
		$newopts = array();
		foreach($opts as $k => $v) {
			if (is_numeric($k)) $newopts[strtoupper($v)] = $v;
			else $newopts[strtoupper($k)] = $v;
		}
		return $newopts;
	}
1169439
public function read(array $opts) {

        $feedback = $this->parseFeedback($opts);

        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'attempt_completed',
            'attempt_url' => $opts['attempt']->url,
            'attempt_type' => static::$xapiType.$opts['attempt']->type,
            'attempt_ext' => $opts['attempt'],
            'attempt_ext_key' => 'http://lrs.learninglocker.net/define/extensions/moodle_feedback_attempt',
            'attempt_name' => $opts['attempt']->name,
            'attempt_score_raw' => $feedback->score->raw,
            'attempt_score_min' => $feedback->score->min,
            'attempt_score_max' => $feedback->score->max,
            'attempt_score_scaled' => $feedback->score->scaled,
            'attempt_success' => null,
            'attempt_completed' => true,
            'attempt_duration' => null,
            'time' => date('c', $opts['attempt']->timemodified)
        ])];
    }
792315
public function createData($path, $body = "", array $opts = array())
    {
        $headers = array('Content-Type' => 'application/json');
        return empty($body)
            ? $this->_processResponse($this->http->post($this->_getApiPath($opts) . $path, $headers))
            : $this->_processResponse(
                $this->http->post(
                    $this->_getApiPath($opts) . $path,
                    $headers,
                    $body
                )
            );
    }
5847
public function read(array $opts) {
        return array_merge(parent::read($opts), [
            'object' => $this->readModule($opts),
            'context' => [
                'contextActivities' => [
                    'grouping' => [
                        $this->readCourse($opts),
                        $this->readScormScoes($opts),
                    ],
                ],
            ],
        ]);
    }
507850
public function envSsh($opts = ['service' => null])
    {
        $this->executeCommandHook(__FUNCTION__, 'before');
        $this->engineInstance()->ssh($opts['service']);
        $this->executeCommandHook(__FUNCTION__, 'after');

        return $this;
    }
97374
public function updateData($path, $body = "", array $opts = array())
    {
        $headers = array('Content-Type' => 'application/json');
        return empty($params)
            ? $this->_processResponse($this->http->put($this->_getApiPath($opts) . $path, $headers))
            : $this->_processResponse(
                $this->http->put(
                    $this->_getApiPath($opts) . $path,
                    $headers,
                    $body
                )
            );
    }
549156
protected static function all($params, $opts)
    {
        $url = self::classUrl();
        list($resp, $usedOpts) = self::request(self::METHOD_GET, $url, $params, $opts);
        $resp = Util\Util::arrayToObject($resp, $usedOpts);
        // Check the class name of the result because all feature must get the instance of Collection class.
        if (!is_a($resp, 'RpayLite\\Collection')) {
            $class = get_class($resp);
            $msg =  "'RpayLite\\Collection' is expected but '$class' is returned.";
            throw new Error\Api($msg);
        }
        return $resp;
    }
1330209
public function getChoices($opts = [])
    {
        $include_blank_dash = (array_key_exists('include_blank', $opts)) ?
            false == $opts['include_blank'] : true;

        $first_choice = [];
        if ($include_blank_dash) {
            $first_choice = self::BLANK_CHOICE_DASH;
        }

        if (!empty($this->choices)) {
            return array_merge($first_choice, $this->choices);
        }

        // load from relationships todo
    }
1118045
public static function parse($str, $opts = array())
	{
		$params = array();
		$opts = \array_merge(
			array(
				'conv_dot'		=> false,
				'conv_space'	=> true,
			),
			$opts
		);
		if (( $opts['conv_dot'] || \strpos($str, '.') === false )
			&& ( $opts['conv_space'] || \strpos($str, ' ') === false )
		) {
			// just use parse_str
			\parse_str($str, $params);
		} else {
			$pairs = \explode('&', $str);
			foreach ($pairs as $pair) {
				$ptr = &$params;
				$pair = \array_map('urldecode', \explode('=', $pair));
				$path = $pair[0];
				$v = isset($pair[1])
					? $pair[1]
					: '';
				$i = 0;
				$re = '/^([^\[]*)/';
				while (\preg_match($re, $path, $matches)) {
					$k = $matches[1];
					$a = \preg_match('/^\s?$/', $k);		// 0 or 1 whitepace = append
					if ($i == 0) {
						// ltrim spaces as parse_str() does
						$k = \ltrim($k, ' ');
						if (\strlen($k) == 0) {
							break;
						}
						if ($opts['conv_space']) {
							$k = \str_replace(' ', '_', $k);
						}
						$re = '/^\[([^\]]*?)\](\s*)/';	// change regex
					} elseif (!empty($matches[2])) {
						$path = '';	// space on the end... this is the end of the path
					}
					$path = \substr($path, \strlen($matches[0]));	// remaining path
					if ($path !== false) {
						if ($a) {
							$ptr[] = array();
							\end($ptr);
							$k = \key($ptr);
						} elseif (!isset($ptr[ $k ]) || \is_string($ptr[ $k ])) {
							$ptr[ $k ] = array();
						}
						$ptr = &$ptr[$k];
					} else {
						if ($a) {
							$ptr[] = $v;
						} else {
							$ptr[ $k ] = $v;
						}
						break;
					}
					$i++;
				}
				if (!empty($path)) {
					// still have remaining path... there were unmatched brackets
					$ptr = $v;
				}
			}
		}
		return $params;
	}
393687
public function getInfo($opt = null)
    {
        if (null === $opt) {
            return curl_getinfo($this->connection);
        }

        return curl_getinfo($this->connection, $opt);
    }
951765
public function read(array $opts) {
        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'discussion_viewed',
            'discussion_url' => $opts['discussion']->url,
            'discussion_name' => $opts['discussion']->name,
            'discussion_description' => 'A Moodle discussion.',
            'discussion_type' => static::$xapiType.$opts['discussion']->type,
            'discussion_ext' => $opts['discussion'],
            'discussion_ext_key' => 'http://lrs.learninglocker.net/define/extensions/moodle_discussion',
        ])];
    }
113489
public static function retrieve($id = null, $opts = null)
    {
        if (!$opts && is_string($id) && substr($id, 0, 3) === 'sk_') {
            $opts = $id;
            $id = null;
        }
        return self::_retrieve($id, $opts);
    }