Whether predictions exist for this context.

@param \context $context
@return bool
770481
public function predictions_exist(\context $context) {
        global $DB;

        // Filters out previous predictions keeping only the last time range one.
        $select = "modelid = :modelid AND contextid = :contextid";
        $params = array('modelid' => $this->model->id, 'contextid' => $context->id);
        return $DB->record_exists_select('analytics_predictions', $select, $params);
    }
14987
public function executeRules(Context $context)
    {
        foreach ($this->rules as $rule) {
            $rule->execute($context);
        }
    }
1329299
protected static function hasScope(ContextInterface $context, string $scope): bool
    {
        $result = false;

        if (static::ctxHasCurrentAccount($context) === true) {
            /** @var PassportAccountInterface $account */
            $account = self::ctxGetCurrentAccount($context);
            $result  = $account->hasScope($scope);
        }

        return $result;
    }
989071
public function initializeContext(Context $context)
    {
        if (! $context instanceof WordpressAwareInterface) {
            return;
        }

        $context->setWordpress($this->wordpress);
        $context->setWordpressParameters($this->parameters);
    }
747486
public function setContext(Context $context)
    {
        $this->context = $context;

        if (empty($this->parameters['secret'])) {
            $this->parameters['secret'] = $context->getSecret();
        }

        return $this;
    }
1171164
private function initializeInstance(Context $context)
    {
        foreach ($this->contextInitializers as $initializer) {
            $initializer->initializeContext($context);
        }
    }
406173
private function expoundContext(&$context)
    {
        foreach ($context as $key => &$value) {
            if (is_array($value) || is_object($value)) {
                $this->expoundContext($value);
            }
            $t    = &$context;
            $keys = explode('.', $key);
            if (count($keys) > 1) {
                foreach ($keys as $subKey) {
                    if (!isset($t[$subKey])) {
                        $t[$subKey] = [];
                    }
                    $t = &$t[$subKey];
                }
                $t = $value;
                unset($context[$key]);
            }
        }
    }
405563
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        //check if the query is retrieving a unique entity
        //if yes check if we already have the entity in the
        //repository or not
        $key = $context->query->getKey();
        if ($key) {
            $context->data = $this->find($key, false);
            if ($context->data) {
                return false;
            }
        }
    }
662367
public function is($context, $original = '')
    {
        return (($this->context === $context) && ($this->original === $original)) ? true : false;
    }
1054353
public final List<Pair<String, Double>> predict(Collection<String> context)
    {
        return predict(context.toArray(new String[0]));
    }
520377
public function isValid($value, $context = null)
    {
        $this->_setValue((string) $value);

        if (($context !== null) && isset($context) && array_key_exists($this->getToken(), $context)) {
            $token = $context[$this->getToken()];
        } else {
            $token = $this->getToken();
        }

        if ($token === null) {
            $this->_error(self::MISSING_TOKEN);
            return false;
        }

        $strict = $this->getStrict();
        if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) {
            $this->_error(self::NOT_SAME);
            return false;
        }

        return true;
    }
116369
public function canCreate($member = null, $context = [])
    {
        $extended = $this->extend('canCreate', $member);
        if ($extended && $extended !== null) {
            return $extended;
        }

        return true;
    }
839918
public function canEvaluate($context) {
        return (isset($context[0]) && ($context[0] instanceof NodeInterface)) || (is_array($context) && count($context) === 0);
    }
188511
public function activeFor(Context $context)
    {
        switch ($this->status) {
            case self::ALWAYS_ACTIVE:
                return true;
            case self::INACTIVE:
                return false;
            case self::CONDITIONALLY_ACTIVE:
                return $this->executeCondition($context);
        }
        return false;
    }
77239
public function appliesToContext(ContextInterface $context): bool
    {
        if (!$context instanceof TypeContext && !$context instanceof PropertyContext) {
            return false;
        }

        $type = $context->getType();
        $typeExists = array_key_exists($type->getName(), $this->typeMap);
        // The default rule will be used here:
        if (!$typeExists) {
            return $this->defaultRule->appliesToContext($context);
        }

        // It's possible to define a null rule, which means that no code will be generated.
        $rule = $this->typeMap[$type->getName()];
        if ($rule  === null) {
            return false;
        }

        return $rule->appliesToContext($context);
    }
431183
public function check($value, array $context = [])
    {
        if ($this->checkContainerType($value, $context) === false) {
            return false;
        }

        foreach ($value as $item) {
            if ($this->valueConstraint->check($item, $context) === false) {
                return false;
            }
        }

        return true;
    }
766448
public function loadContext($context)
    {

        $ok = false;
        if (!empty($context->getRecordId())) {
            $sql = sprintf('SELECT context_pk, consumer_pk, lti_context_id, type, settings, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::CONTEXT_TABLE_NAME . ' ' .
                           'WHERE (context_pk = %d)',
                           $context->getRecordId());
        } else {
            $sql = sprintf('SELECT context_pk, consumer_pk, lti_context_id, type, settings, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::CONTEXT_TABLE_NAME . ' ' .
                           'WHERE (consumer_pk = %d) AND (lti_context_id = %s)',
                           $context->getConsumer()->getRecordId(), DataConnector::quoted($context->ltiContextId));
        }
        $rs_context = mysql_query($sql);
        if ($rs_context) {
            $row = mysql_fetch_object($rs_context);
            if ($row) {
                $context->setRecordId(intval($row->context_pk));
                $context->setConsumerId(intval($row->consumer_pk));
                $context->ltiContextId = $row->lti_context_id;
                $context->type = $row->type;
                $settings = unserialize($row->settings);
                if (!is_array($settings)) {
                    $settings = array();
                }
                $context->setSettings($settings);
                $context->created = strtotime($row->created);
                $context->updated = strtotime($row->updated);
                $ok = true;
            }
        }

        return $ok;

    }