prediction_actions

@param \core_analytics\prediction $prediction
@param bool $includedetailsaction
@param bool $isinsightuser
@return \core_analytics\prediction_action[]
558999
public function prediction_actions(\core_analytics\prediction $prediction, $includedetailsaction = false,
            $isinsightuser = false) {
        global $USER;

        $actions = array();

        $sampledata = $prediction->get_sample_data();
        $studentid = $sampledata['user']->id;

        $attrs = array('target' => '_blank');

        // Send a message.
        $url = new \moodle_url('/message/index.php', array('user' => $USER->id, 'id' => $studentid));
        $pix = new \pix_icon('t/message', get_string('sendmessage', 'message'));
        $actions[] = new \core_analytics\prediction_action('studentmessage', $prediction, $url, $pix,
                get_string('sendmessage', 'message'), false, $attrs);

        // View outline report.
        $url = new \moodle_url('/report/outline/user.php', array('id' => $studentid, 'course' => $sampledata['course']->id,
                'mode' => 'outline'));
        $pix = new \pix_icon('i/report', get_string('outlinereport'));
        $actions[] = new \core_analytics\prediction_action('viewoutlinereport', $prediction, $url, $pix,
                get_string('outlinereport'), false, $attrs);

        return array_merge($actions, parent::prediction_actions($prediction, $includedetailsaction));
    }
795102
public function include($includes)
	{
		$model = $this;

		(function() use ($includes, $model): void
		{
			$this->including($includes)->loadIncludes([$model]);
		})->bindTo($this->builder(), Query::class)();

		return $this;
	}
1258430
public function introspectController($controllerPath)
    {
        $content = file_get_contents($controllerPath);
        preg_match_all('/public\s+function\s+\&?\s*([^(]+)/', $content, $methods);

        $guardableActions = [];
        foreach ($methods[1] as $m) {
            if (in_array($m, ['__construct', 'initialize', 'isAuthorized', 'setRequest', 'invokeAction', 'beforeFilter', 'beforeRender', 'beforeRedirect', 'afterFilter'])) {
                continue;
            }
            $guardableActions[] = $m;
        }

        return $guardableActions;
    }
1086608
public function generate_insight_notifications($modelid, $samplecontexts, array $predictions = []) {
        // Delegate the processing of insights to the insights_generator.
        $insightsgenerator = new \core_analytics\insights_generator($modelid, $this);
        $insightsgenerator->generate($samplecontexts, $predictions);
    }
1363049
public function getCustomWitnesses($filterIsDue = false)
    {
        $list = collect();

        foreach (config('eyewitness.custom_witnesses', []) as $witness) {
            if ($this->isValidWitness($witness)) {
                $instance = app($witness);
                if ($filterIsDue) {
                    if ($instance->isDue()) {
                        $list->push($instance);
                    }
                } else {
                    $list->push($instance);
                }
            }
        }

        return $list;
    }
316834
public static function enrichVisitorArrayWithActions($visitorDetailsArray, $actionDetails = array())
    {
        $actionsLimit = (int)Config::getInstance()->General['visitor_log_maximum_actions_per_visit'];
        $visitorDetailsManipulators = self::getAllVisitorDetailsInstances();

        foreach ($visitorDetailsManipulators as $instance) {
            $instance->provideActionsForVisit($actionDetails, $visitorDetailsArray);
        }

        foreach ($visitorDetailsManipulators as $instance) {
            $instance->filterActions($actionDetails, $visitorDetailsArray);
        }

        usort($actionDetails, array('static', 'sortByServerTime'));

        $actionDetails = array_values($actionDetails);

        // limit actions
        if ($actionsLimit < count($actionDetails)) {
            $visitorDetailsArray['truncatedActionsCount'] = count($actionDetails) - $actionsLimit;
            $actionDetails = array_slice($actionDetails, 0, $actionsLimit);
        }

        foreach ($actionDetails as $actionIdx => &$actionDetail) {
            $actionDetail =& $actionDetails[$actionIdx];
            $nextAction = isset($actionDetails[$actionIdx+1]) ? $actionDetails[$actionIdx+1] : null;

            foreach ($visitorDetailsManipulators as $instance) {
                $instance->extendActionDetails($actionDetail, $nextAction, $visitorDetailsArray);
            }
        }

        $visitorDetailsArray['actionDetails'] = $actionDetails;

        return $visitorDetailsArray;
    }
1044189
public function setAction($action,$isAjax = true){
        $this->action = $action;
       foreach($this->suggestCells as $cell){
               $cell->setAjaxElement($isAjax);
           $cell->setAction($action);
       }
    }
183985
def _get_predicted_embedding_addition(self,
                                          checklist_state: ChecklistStatelet,
                                          action_ids: List[int],
                                          action_embeddings: torch.Tensor) -> torch.Tensor:
        
        # Our basic approach here will be to figure out which actions we want to bias, by doing
        # some fancy indexing work, then multiply the action embeddings by a mask for those
        # actions, and return the sum of the result.

        # Shape: (num_terminal_actions, 1).  This is 1 if we still want to predict something on the
        # checklist, and 0 otherwise.
        checklist_balance = checklist_state.get_balance().clamp(min=0)

        # (num_terminal_actions, 1)
        actions_in_agenda = checklist_state.terminal_actions
        # (1, num_current_actions)
        action_id_tensor = checklist_balance.new(action_ids).long().unsqueeze(0)
        # Shape: (num_terminal_actions, num_current_actions).  Will have a value of 1 if the
        # terminal action i is our current action j, and a value of 0 otherwise.  Because both sets
        # of actions are free of duplicates, there will be at most one non-zero value per current
        # action, and per terminal action.
        current_agenda_actions = (actions_in_agenda == action_id_tensor).float()

        # Shape: (num_current_actions,).  With the inner multiplication, we remove any current
        # agenda actions that are not in our checklist balance, then we sum over the terminal
        # action dimension, which will have a sum of at most one.  So this will be a 0/1 tensor,
        # where a 1 means to encourage the current action in that position.
        actions_to_encourage = torch.sum(current_agenda_actions * checklist_balance, dim=0)

        # Shape: (action_embedding_dim,).  This is the sum of the action embeddings that we want
        # the model to prefer.
        embedding_addition = torch.sum(action_embeddings * actions_to_encourage.unsqueeze(1),
                                       dim=0,
                                       keepdim=False)

        if self._add_action_bias:
            # If we're adding an action bias, the last dimension of the action embedding is a bias
            # weight.  We don't want this addition to affect the bias (TODO(mattg): or do we?), so
            # we zero out that dimension here.
            embedding_addition[-1] = 0

        return embedding_addition
1319911
public static function get_users_in_context(userlist $userlist) {
        global $DB;

        $context = $userlist->get_context();
        $models = self::get_models_with_user_data();

        foreach ($models as $modelid => $model) {

            $analyser = $model->get_analyser(['notimesplitting' => true]);

            // Analytics predictions.
            $params = [
                'contextid' => $context->id,
                'modelid' => $modelid,
            ];
            $joinusersql = $analyser->join_sample_user('ap');
            $sql = "SELECT u.id AS userid
                      FROM {analytics_predictions} ap
                           {$joinusersql}
                     WHERE ap.contextid = :contextid
                       AND ap.modelid = :modelid";
            $userlist->add_from_sql('userid', $sql, $params);

            // Indicator calculations.
            $params = [
                'contextid' => $context->id,
                'analysersamplesorigin' => $analyser->get_samples_origin(),
            ];
            $joinusersql = $analyser->join_sample_user('aic');
            $sql = "SELECT u.id AS userid
                      FROM {analytics_indicator_calc} aic
                           {$joinusersql}
                     WHERE aic.contextid = :contextid
                       AND aic.sampleorigin = :analysersamplesorigin";
            $userlist->add_from_sql('userid', $sql, $params);
        }

        // We can leave this out of the loop as there is no analyser-dependent stuff.
        list($sql, $params) = self::analytics_prediction_actions_context_sql($context->id, array_keys($models));
        $sql = "SELECT apa.userid" . $sql;
        $userlist->add_from_sql('userid', $sql, $params);
    }
172782
public function get($assetReportToken, $includeInsights = false)
    {
        $data = [
            'asset_report_token' => $assetReportToken,
        ];

        if ($includeInsights) {
            $data['include_insights'] = $includeInsights;
        }

        return $this->client->post('/asset_report/get', $data);
    }
861770
public function findDesktopDisplayedToolsWithExclusionByUser(
        User $user,
        array $excludedTools,
        $orderedToolType = 0
    ) {
        $dql = "
            SELECT tool
            FROM Claroline\CoreBundle\Entity\Tool\Tool tool
            JOIN tool.orderedTools ot
            JOIN ot.user user
            LEFT JOIN tool.plugin p
            WHERE user.id = {$user->getId()}
            AND ot.type = :type
            AND ot.isVisibleInDesktop = true
            AND tool.isDisplayableInDesktop = true
            AND tool NOT IN (:excludedTools)
            AND (
                CONCAT(p.vendorName, p.bundleName) IN (:bundles)
                OR tool.plugin is NULL
            )
            ORDER BY ot.order
        ";
        $query = $this->_em->createQuery($dql);
        $query->setParameter('type', $orderedToolType);
        $query->setParameter('excludedTools', $excludedTools);
        $query->setParameter('bundles', $this->bundles);

        return $query->getResult();
    }
699714
public function build(array $userAgentsData, bool $isCore) : array
    {
        $useragents = [];

        foreach ($userAgentsData as $useragent) {
            $children = [];

            if (!$isCore) {
                $children = $useragent['children'];
            }

            $useragents[] = new UserAgent(
                $useragent['userAgent'],
                $useragent['properties'],
                $children,
                isset($useragent['platform']) ? $useragent['platform'] : null,
                isset($useragent['engine']) ? $useragent['engine'] : null,
                isset($useragent['device']) ? $useragent['device'] : null,
                isset($useragent['browser']) ? $useragent['browser'] : null
            );
        }

        return $useragents;
    }
1373395
public function getLinksArray($includeOnlyVisited = false){
        $links = $this->getLinks();
        
        if($includeOnlyVisited === true){
            $links = array_filter($links, function (Link $linkObj) {
                /*@var $linkObj Link */
                return $linkObj->isVisited() === true;
            });
        }
        
        return array_map(function(Link $link){
            return [
              'fullUrl' => $link->getAbsoluteUrl(),
              'uri' => $link->getPath(),
              'metaInfo' => $link->getMetaInfoArray(),
              'parentLink' => $link->getParentUrl(),
              'statusCode' => $link->getStatusCode(), 
              'status' => $link->getStatus(), 
              'contentType' => $link->getContentType(), 
              'errorInfo' => $link->getErrorInfo(),
              'crawlDepth' => $link->getCrawlDepth(),              
            ];
        },$links);
    }
562123
private function next($includeWhiteSpace = false)
    {
        for ($i = $this->tokenPos; $i < $this->tokensCount; $i++) {
            $this->tokenPos++;
            if (($includeWhiteSpace === false && $this->tokens[$i][0] === T_WHITESPACE) || $this->tokens[$i][0] === T_COMMENT) {
                continue;
            }

            return $this->tokens[$i];
        }

        return null;
    }
298055
public function including($includes)
	{
		if($includes === false)
		{
			$this->model->setIncludes([]);
		}
		else
		{
			$includes = (array) $includes;

			$currentIncludes = $this->model->getIncludes();

			if(!empty($currentIncludes))
			{
				$withCriterion = array_filter(array_keys($includes), 'is_string');

				if(!empty($withCriterion))
				{
					foreach($currentIncludes as $key => $value)
					{
						if(in_array($value, $withCriterion))
						{
							unset($currentIncludes[$key]); // Unset relations that have previously been set without a criterion closure
						}
					}
				}

				$includes = array_merge($currentIncludes, $includes);
			}

			$this->model->setIncludes(array_unique($includes, SORT_REGULAR));
		}

		return $this;
	}
362449
public function updateInputConcepts(array $conceptsArray, $action)
    {
        $data['inputs'] = [];

        foreach ($conceptsArray as $inputId => $inputConcepts) {
            $input = [];
            $input['id'] = (string)$inputId;
            $input['data'] = [];
            $input['data'] = $this->addImageConcepts($input['data'], $inputConcepts);

            $data['inputs'][] = $input;
        }
        $data['action'] = $action;

        $updateResult = $this->getRequest()->request(
            'PATCH',
            $this->getRequestUrl('inputs'),
            $data
        );

        return $this->getInputsFromResult($updateResult);
    }
385589
public function getAnswerDisplaySnippets(\Gems_Tracker_Token $token)
    {
        $snippets = parent::getAnswerDisplaySnippets($token);
        if (!is_array($snippets)) {
        	$snippets = array($snippets);
        }
        // Add the ScoreChartsSnippet
        $snippets[] = 'Survey_Display_ScoreChartsSnippet';
        return $snippets;
    }