Keep a count of a response to this question sub part that falls within this class.

@param string     $actualresponse
@param float|null $fraction
@param int        $try
@return \core_question\statistics\responses\analysis_for_actual_response
322760
public function count_response($actualresponse, $fraction, $try) {
        if (!isset($this->actualresponses[$actualresponse])) {
            if ($fraction === null) {
                $fraction = $this->fraction;
            }
            $this->add_response($actualresponse, $fraction);
        }
        $this->get_response($actualresponse)->increment_count($try);
    }
1365502
public function execute(Request $req = null, Response $res = null)
    {
        $auto = false;
        if (!isset($req)) {
            $auto = true;
            $req  = (new Request())->fromGlobals();
            $res  = (new Response($req));
        } else if (!isset($res)) {
            throw new App\Exception('You must pass a Response object when passing a Request object');
        }

        $this->param('req', $req)
             ->param('res', $res);
        try {
            $this->preExecute($req, $res);
            foreach ($this->_executables as $executable) {
                if ($executable instanceof Executable && !$executable instanceof App) {
                    $executable->preExecute($req, $res);
                }
            }
            $result = null;
            foreach ($this->_executables as $executable) {
                $result = call_user_func($executable instanceof Executable
                    ? [$executable, 'execute']
                    : $executable, $req, $res);
                if (isset($result)) {
                    break;
                }
            }
            if (!$result && !$this->_isSubapp) {
                if (isset($this->_failureHandler)) {
                    $result = call_user_func($this->_failureHandler, $req, $res);
                } else {
                    throw new App\Exception('Nothing successfully handled the request');
                }
            }
            foreach ($this->_executables as $executable) {
                if ($executable instanceof Executable && !$executable instanceof App) {
                    $executable->postExecute($req, $res);
                }
            }
            $this->postExecute($req, $res);
        } catch (\Exception $e) {
            if (isset($this->_errorHandler)) {
                $result = call_user_func($this->_errorHandler, $req, $res, $e);
            } else {
                throw $e;
            }
        }
        $this->param('req', null)
             ->param('res', null);
        
        if ($auto) {
            $res->toGlobals();
        } else {
            return $result;
        }
    }
394717
public function getResponse($printResponse = true)
    {
        $this->setStatusInfo();
        if ($printResponse) {
            header('Content-Type: application/json');
            echo $this->ResponseData;
        } else {
            return $this->ResponseData;
        }
        return null;
    }
325719
private function populateResponse($resp, $basePeriodId, $baseCalcId, $depPeriodId, $depCalcId, $err = null)
    {
        if (!$err) {
            $resp->setErrorCode(AResponse::ERR_NO_ERROR);
            $basePeriodData = $this->daoPeriod->getById($basePeriodId);
            $baseCalcData = $this->daoCalc->getById($baseCalcId);
            $depPeriodData = $this->daoPeriod->getById($depPeriodId);
            $depCalcData = $this->daoCalc->getById($depCalcId);
            $resp->setBasePeriodData($basePeriodData);
            $resp->setBaseCalcData($baseCalcData);
            $resp->setDepPeriodData($depPeriodData);
            $resp->setDepCalcData($depCalcData);
        } else {
            $resp->setErrorCode(AResponse::ERR_ADD_NEW_PERIOD);
        }
    }
936403
public function onKernelView(GetResponseForControllerResultEvent $event) :? Response
    {
        $request = $event->getRequest();
        $result = $event->getControllerResult();

        // If the event already has a response, do not override it.
        if ($event->hasResponse()) {
            return $event->getResponse();
        }

        // If the request format is not supported, nothing more can be done
        // without the serializer throwing an exception.
        if (!$this->encoder->supportsEncoding($request->getRequestFormat())) {
            return null;
        }

        if (is_iterable($result)) {
            $data = $result;

            // Convert objects to arrays.
            if ($result instanceof \Traversable) {
                $data = iterator_to_array($result);
            }

            // Determine if array is a collection or just a standard array.
            $bad = array_filter($data, function ($item) use ($request) {
                if (!is_object($item)) {
                    return true;
                }

                if (!$this->normalizer->supportsNormalization($item, $request->getRequestFormat())) {
                    return true;
                }

                return false;
            });

            // If array is a collection and everything can be normalized,
            // normalize each item before serialization.
            if (!count($bad)) {
                $result = array_map(function ($item) use ($request) {
                    return $this->normalizer->normalize($item, $request->getRequestFormat(), [
                        'groups' => $this->groupResolver->resolve($request, $item),
                        'enable_max_depth' => true,
                    ]);
                }, $data);
            }
        }

        // If the normalizer cannot normalize the result, then there is nothing
        // more than can be done without the serializer throwing an exception.
        if (is_object($result) && !$this->normalizer->supportsNormalization($result, $request->getRequestFormat())) {
            return null;
        }

        $status = Response::HTTP_OK;
        switch ($request->getMethod()) {
            case Request::METHOD_POST:
                $status = Response::HTTP_CREATED;
                break;
            case Request::METHOD_DELETE:
                $status = Response::HTTP_NO_CONTENT;
                break;
        }

        $groups = null;
        if (is_object($result)) {
            $groups = $this->groupResolver->resolve($request, $result);
        }

        $serializeEvent = new SerializeEvent(
            $result,
            $request->getRequestFormat(),
            [
                'groups' => $groups,
                'enable_max_depth' => true,
            ],
            $request
        );

        $this->eventDispatcher->dispatch(SerializeEvent::NAME, $serializeEvent);

        $response = new Response(
            $this->serializer->serialize(
                $serializeEvent->getData(),
                $serializeEvent->getFormat(),
                $serializeEvent->getContext()
            ),
            $status
        );
        $event->setResponse($response);

        return $response;
    }
772063
function hasException()
    {
        // Check exception from raw response
        // Server Response Status is 200 but Logical Error May Happen And Returned in Response Body
        if (! $this->exception ) {
            $res = $this->expected();
            if ($res instanceof DataEntity) {
                // Response Body Can parsed To Data Structure
                if ( $exception = $res->get('error') ) {
                    // TODO handle token revoke exceptions; OAuth Exceptions
                    $this->exception = new exTokenMismatch(
                        $res->get('error_description')
                        .' '
                        .$res->get('hint')

                        , 401
                    );
                }
            }
        } else if ($this->exception instanceof exHttpResponse) {
            // Determine Known Errors ...
            $expected = $this->expected();
            if ($expected && $err = $expected->get('error') ) {

                if ( is_string($err) )
                {
                    switch ($err) {
                        case 'access_denied':
                        case 'invalid_grant':
                            $description = $expected->get('error_description');
                            $this->exception = new exOAuthAccessDenied($description);
                            break;
                        case 'invalid_request':
                            $description = $expected->get('error_description');
                            $this->exception = new exInvalidRequest($description);
                            break;
                    }

                } elseif (isset($err['state']))
                {
                    switch (@$err['state']) {
                        case 'exUserNotFound':
                            $this->exception = new exUserNotFound($err['message'], (int)$err['code']);
                            break;
                        case 'exOAuthAccessDenied':
                            $this->exception = new exTokenMismatch($err['message'], (int)$err['code']);
                            break;
                        case 'exIdentifierExists':
                            $this->exception = new exIdentifierExists($err['message'], (int)$err['code']);
                            break;
                        case 'exPasswordNotMatch':
                            $this->exception = new exPasswordNotMatch($err['message'], (int)$err['code']);
                            break;
                        case 'exUnexpectedValue':
                            $this->exception = new exUnexpectedValue($err['message'], (int)$err['code']);
                            break;
                        case 'exMessageMalformed':
                            $this->exception = new exUnexpectedValue($err['message'], (int)$err['code']);
                            break;
                    }
                }
            }
        }


        return $this->exception;
    }
717760
public static long count(nitro_service service) throws Exception
	{
		sms_server obj = new sms_server();
		options option = new options();
		option.set_count(true);
		sms_server[] response = (sms_server[])obj.get_resources(service, option);
		if (response != null && response.length > 0)
			return response[0].__count;
		return 0;
	}
740623
public function iGetAResponseWithAStatusCodeOf($code)
    {
        $actual = $this->getGuzzleResponse()->getStatusCode();

        if ($actual != $code) {
            throw new ClientErrorResponseException(
                'Actual status code ' . $actual . ' does not match expected ' .
                'status code ' . $code . ' with message: ' .
                $this->getGuzzleResponse()->getMessage()
            );
        }
    }
327400
public static function checkResponse($transactionId, $responseCode, $responseText, $item)
    {
        $e = self::getException($transactionId, $responseCode, $responseText, $item);

        if ($e != null) {
            throw $e;
        }
    }
213464
public function on_after_write_attempt($attempt, $result) {
        global $PAGE;

        if ($formdata = $result->postdata) {
            // Save any linked files if we are using an editor.
            $editoroptions = array(
                'maxbytes' => $PAGE->course->maxbytes,
                'context' => context_module::instance($PAGE->cm->id),
                'noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES,
                'enable_filemanagement' => false,
            );

            $formdata = file_postupdate_standard_editor($formdata, 'answer', $editoroptions,
                $editoroptions['context'], 'mod_lesson', 'essay_answers', $attempt->id);

            // Update the student response to have the modified link.
            $useranswer = unserialize($attempt->useranswer);
            $useranswer->answer = $formdata->answer;
            $useranswer->answerformat = $formdata->answerformat;
            $attempt->useranswer = serialize($useranswer);

            $result->studentanswer = $formdata->answer;
            $result->studentanswerformat = $formdata->answerformat;
            return [$attempt, $result];
        }

        return parent::on_after_write_attempt($attempt, $result);
    }
365390
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $startTime = $request->server->get('REQUEST_TIME_FLOAT', $request->server->get('REQUEST_TIME'));

        $time = \microtime(true) - $startTime;
        $time = \round($time * 1000);

        $statData = $this->getStatsdDataFactory()->timing($this->getStatsDataKey(), $time);
        $this->addStatsData($statData);

        return true;
    }
365613
public static function assertEquals($actual, $expected, Throwable $exception)
    {
        static::makeAssertion($actual === $expected, $exception);
        return $actual;
    }
994802
public FragmentResponseMessage processFragmentTask(SiteProcedureConnection siteConnection)
    {
        final FragmentResponseMessage currentFragResponse =
            new FragmentResponseMessage(m_fragmentMsg, m_initiator.getHSId());
        currentFragResponse.setStatus(FragmentResponseMessage.SUCCESS, null);

        for (int frag = 0; frag < m_fragmentMsg.getFragmentCount(); frag++)
        {
            final long fragmentId = VoltSystemProcedure.hashToFragId(m_fragmentMsg.getPlanHash(frag));
            // equivalent to dep.depId:
            // final int outputDepId = m_fragmentMsg.getOutputDepId(frag);

            final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPSITE);
            if (traceLog != null) {
                traceLog.add(() -> VoltTrace.beginDuration("runfragmenttask",
                                                           "txnId", TxnEgo.txnIdToString(getTxnId()),
                                                           "partition", Integer.toString(siteConnection.getCorrespondingPartitionId()),
                                                           "fragmentId", String.valueOf(fragmentId)));
            }

            ParameterSet params = m_fragmentMsg.getParameterSetForFragment(frag);

            try {
                // run the overloaded sysproc planfragment. pass an empty dependency
                // set since remote (non-aggregator) fragments don't receive dependencies.
                final DependencyPair dep
                    = siteConnection.executeSysProcPlanFragment(m_txnState,
                                                         m_inputDeps,
                                                         fragmentId,
                                                         params);
                // @Shutdown returns null, handle it here
                if (dep != null) {
                    currentFragResponse.addDependency(dep);
                }
            } catch (final EEException | SQLException | ReplicatedTableException e) {
                hostLog.l7dlog(Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(),
                        new Object[] { Encoder.hexEncode(m_fragmentMsg.getFragmentPlan(frag)) }, e);
                currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
                addDependencyToFragment(currentFragResponse);
                break;
            } catch (final SerializableException e) {
                // Note that with SerializableException, the error code here might get changed before
                // the client/user sees it. It really just needs to indicate failure.
                //
                // Key point here vs the next catch block for VAE is to not wrap the subclass of
                // SerializableException here to preserve it during the serialization.
                //
                currentFragResponse.setStatus( FragmentResponseMessage.USER_ERROR, e);
                addDependencyToFragment(currentFragResponse);
                break;
            } catch (final VoltAbortException e) {
                currentFragResponse.setStatus( FragmentResponseMessage.USER_ERROR, new SerializableException(CoreUtils.throwableToString(e)));
                addDependencyToFragment(currentFragResponse);
                break;
            }

            if (traceLog != null) {
                traceLog.add(VoltTrace::endDuration);
            }
        }

        // we should never rollback DR buffer for MP sysprocs because we don't report the DR buffer size and therefore don't know if it is empty or not.
        currentFragResponse.setDrBufferSize(1);
        return currentFragResponse;
    }
793977
public function checkAnswer(string $remoteip, string $challenge = null, string $response = null) : Response
    {
        if (empty($remoteip)) {
            throw new Exception('For security reasons, you must pass the remote ip to solvemedia');
        }

        //discard spam submissions
        if (empty($challenge) || empty($response)) {
            return new Response(false, 'incorrect-solution');
        }

        $httpResponse = $this->_client->request(
            'POST',
            self::ADCOPY_VERIFY_SERVER,
            [
                'headers' => ['User-Agent' => 'solvemedia/PHP'],
                'form_params' => [
                    'privatekey' => $this->_privkey,
                    'remoteip' => $remoteip,
                    'challenge' => $challenge,
                    'response' => $response,
                ],
            ]
        );

        if ($httpResponse->getStatusCode() !== 200) {
            return new Response(false, $httpResponse->getReasonPhrase());
        }

        $answers = explode("\n", (string)$httpResponse->getBody());

        if (!empty($this->_hashkey)) {
            // validate message authenticator
            $hash = sha1($answers[0] . $challenge . $this->_hashkey);

            if ($hash !== $answers[2]) {
                return new Response(false, 'hash-fail');
            }
        }

        if (trim($answers[0]) !== 'true') {
            return new Response(false, $answers[1]);
        }

        return new Response(true);
    }
995242
def get_survey_response_count
      url = ApiRequest.base_path("questionpro.survey.responseCount")
      result = self.class.get(url, body: self.options)
      
      self.full_response = result
      self.status = result['status']

      response_count = SurveyResponseCount.new(result['response'])

      return response_count
    end
594630
@Override
	public OperationResult<R> tryOperation(Operation<CL, R> operation) throws ConnectionException {
	    Operation<CL, R> filteredOperation = config.getOperationFilterFactory().attachFilter(operation);
	    
        while (true) {
            attemptCounter++;
            
            try {
                connection = borrowConnection(filteredOperation);
                startTime = System.currentTimeMillis();
                OperationResult<R> result = connection.execute(filteredOperation);
                result.setAttemptsCount(attemptCounter);
                monitor.incOperationSuccess(getCurrentHost(), result.getLatency());
                return result;
            }
            catch (Exception e) {
                ConnectionException ce = (e instanceof ConnectionException) ? (ConnectionException) e
                        : new UnknownException(e);
            	try {
            		informException(ce);
                    monitor.incFailover(ce.getHost(), ce);
            	}
            	catch (ConnectionException ex) {
                    monitor.incOperationFailure(getCurrentHost(), ex);
                    throw ex;
            	}
            }
            finally {
            	releaseConnection();
            }
        }
    }
1338324
public function get($timeout = 10, $interval = 0.5)
    {
        $intervalUs = (int)($interval * 1000000);
        $iterationLimit = (int)($timeout / $interval);

        for ($i = 0; $i < $iterationLimit; $i++) {
            if ($this->ready()) {
                break;
            }
            usleep($intervalUs);
        }

        if (!$this->ready()) {
            throw new \Rhubarb\Exception\TimeoutException(
                sprintf(
                    'Task %s(%s) did not return after %s seconds',
                    $this->getId(),
                    (string)$this,
                    $timeout
                )
            );
        }
        return $this->responseBody->result;
    }