getCollectorsForSurvey

@param int $surveyId
@param array $filters - Available filters: page, per_page, sort_by, sort_order, name, start_date, end_date, include

@return @see Client::sendRequest
19866
public function getCollectorsForSurvey($surveyId, array $filters = [])
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('surveys/%s/collectors', $surveyId), [ 
				'query' => $filters 
			])
		);
	}
278895
public function search_payment($filters, $offset = 0, $limit = 0) {
        $filters["offset"] = $offset;
        $filters["limit"] = $limit;

        $uri_prefix = $this->sandbox ? "/sandbox" : "";

        $request = array(
            "uri" => "/v1/payments/search",
            "params" => array_merge ($filters, array(
                "access_token" => $this->get_access_token()
            ))
        );

        $collection_result = MPRestClient::get($request);
        return $collection_result;
    }
630908
public function getSurveyResponse($surveyId, $responseId, $detailed = false, array $filters = [])
	{
		if ($detailed) {
			return $this->sendRequest(
				$this->createRequest('GET', sprintf('surveys/%s/responses/%s/details', $surveyId, $responseId), [ 
					'query' => $filters 
				])
			);
		} else {
			return $this->sendRequest(
				$this->createRequest('GET', sprintf('surveys/%s/responses/%s', $surveyId, $responseId), [ 
					'query' => $filters 
				])
			);
		}
	}
1187698
public Stream<LsQuestionGroup> getGroups(int surveyId) throws LimesurveyRCException {
        JsonElement result = callRC(new LsApiBody("list_groups", getParamsWithKey(surveyId)));
        List<LsQuestionGroup> questionGroups = gson.fromJson(result, new TypeToken<List<LsQuestionGroup>>() {
        }.getType());

        return questionGroups.stream().sorted(Comparator.comparing(LsQuestionGroup::getOrder));
    }
1109527
public function analyzeSurveyQuestions($benchmarkBundleId, array $questionids, array $filters = [])
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('benchmark_bundles/%d/analyze', $benchmarkBundleId). [
				'query' => array_merge($filters, [
					'question_ids' => implode(',', $questionIds)
				])
			])
		);
	}
821049
public function getMedia(string $collectionName = 'default', $filters = []): Collection
    {
        return $this->getMediaRepository()->getFilteredCollection($collectionName, $filters);
    }
383239
public function fetch($class, array $filters = [], array $sortBy = null, $page = 0, $limit = -1, $count = false)
    {
        try {
            return $this->get($class)->find($filters, $sortBy, $page, $limit, $count);
        } catch (FinderException $e) {
            $data = $this->om->getRepository($class)->findBy($filters, null, 0 < $limit ? $limit : null, $page);

            return $count ? count($data) : $data;
        }
    }
650175
public function getQuestionBenchmarkResult($surveyId, $pageId, $questionId, array $filters = [])
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('surveys/%d/pages/%d/questions/%d/benchmark', $surveyId, $pageId, $questionId), [ 
				'query' => $filters 
			])
		);
	}
778793
public function deleteSurveyPage($surveyId, $pageId)
	{
		return $this->sendRequest(
			$this->createRequest('DELETE', sprintf('surveys/%d/pages/%d', $surveyId, $pageId))
		);
	}
1205680
public function execute($sourceId = null, $sourceSurveyId = null, $surveyId = null)
    {
        $batch = $this->getBatch();

        if ($surveyId) {
            $survey = $this->loader->getTracker()->getSurvey($surveyId);
        } else {
            $survey = $this->loader->getTracker()->getSurveyBySourceId($sourceSurveyId, $sourceId);
        }

        if (! $survey->isActive()) {
            return;
        }

        // Now save the questions
        $answerModel = $survey->getAnswerModel('en');
        
        $hash = $survey->calculateHash();
        
        if ($survey->getHash() === $hash) {
            return;
        }
        
        $survey->setHash($hash, $this->loader->getCurrentUser()->getUserId());

        foreach ($answerModel->getItemsOrdered() as $order => $name) {
            if (true === $answerModel->get($name, 'survey_question')) {
                $batch->addTask('Tracker_RefreshQuestion', $surveyId, $name, $order);
            }
        }

        // If we have a response database, create a view on the answers
        if ($this->project->hasResponseDatabase()) {
            $this->replaceCreateView($survey, $answerModel);
        }
    }
849287
public static function get_questions($surveyid) {
        global $DB, $USER;

        $params = self::validate_parameters(self::get_questions_parameters(),
                                            array(
                                                'surveyid' => $surveyid
                                            ));
        $warnings = array();

        // Request and permission validation.
        $survey = $DB->get_record('survey', array('id' => $params['surveyid']), '*', MUST_EXIST);
        list($course, $cm) = get_course_and_cm_from_instance($survey, 'survey');

        $context = context_module::instance($cm->id);
        self::validate_context($context);
        require_capability('mod/survey:participate', $context);

        $mainquestions = survey_get_questions($survey);

        foreach ($mainquestions as $question) {
            if ($question->type >= 0) {
                // Parent is used in subquestions.
                $question->parent = 0;
                $questions[] = survey_translate_question($question);

                // Check if the question has subquestions.
                if ($question->multi) {
                    $subquestions = survey_get_subquestions($question);
                    foreach ($subquestions as $sq) {
                        $sq->parent = $question->id;
                        $questions[] = survey_translate_question($sq);
                    }
                }
            }
        }

        $result = array();
        $result['questions'] = $questions;
        $result['warnings'] = $warnings;
        return $result;
    }
171009
public function getRawTokenAnswerRowsSelect(array $filter, $surveyId, $sourceSurveyId = null) {
        if (null === $sourceSurveyId) {
            $sourceSurveyId = $this->_getSid($surveyId);
        }

        $lsDb = $this->getSourceDatabase();
        $lsSurveyTable = $this->_getSurveyTableName($sourceSurveyId);
        $lsTokenTable  = $this->_getTokenTableName($sourceSurveyId);
        $tokenField    = $lsSurveyTable . '.token';

        $quotedTokenTable  = $lsDb->quoteIdentifier($lsTokenTable . '.token');
        $quotedSurveyTable = $lsDb->quoteIdentifier($lsSurveyTable . '.token');

        $select = $lsDb->select();
        $select->from($lsTokenTable, $this->_attributeMap)
               ->join($lsSurveyTable, $quotedTokenTable . ' = ' . $quotedSurveyTable);

        //Now process the filters
        if (is_array($filter)) {
            //first preprocess the tokens
            if (isset($filter['token'])) {
                foreach ((array) $filter['token'] as $key => $tokenId) {
                    $token = $this->_getToken($tokenId);

                    $filter[$tokenField][$key] = $token;
                }
                unset($filter['token']);
            }

            // now map the attributes to the right fields
            foreach ($this->_attributeMap as $name => $field) {
                if (isset($filter[$name])) {
                    $filter[$field] = $filter[$name];
                    unset($filter[$name]);
                }
            }
        }

        // Add limit / offset to select and remove from filter
        $this->filterLimitOffset($filter, $select);

        foreach ($filter as $field => $values) {
            $field = $lsDb->quoteIdentifier($field);
            if (is_array($values)) {
                $select->where("$field IN (?)", array_values($values));
            } else {
                $select->where("$field = ?", $values);
            }
        }

        if (\Gems_Tracker::$verbose) {
            \MUtil_Echo::r($select->__toString(), 'Select');
        }

        return $select;
    }
599869
public static function view_survey($surveyid) {
        global $DB, $USER;

        $params = self::validate_parameters(self::view_survey_parameters(),
                                            array(
                                                'surveyid' => $surveyid
                                            ));
        $warnings = array();

        // Request and permission validation.
        $survey = $DB->get_record('survey', array('id' => $params['surveyid']), '*', MUST_EXIST);
        list($course, $cm) = get_course_and_cm_from_instance($survey, 'survey');

        $context = context_module::instance($cm->id);
        self::validate_context($context);
        require_capability('mod/survey:participate', $context);

        $viewed = survey_already_done($survey->id, $USER->id) ? 'graph' : 'form';

        // Trigger course_module_viewed event and completion.
        survey_view($survey, $course, $cm, $context, $viewed);

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }
22376
public function list(
        CustomerFilters $customerFilters = null,
        CustomerRequest $customerRequest = null
    ): PagedCollection {
        $uri = '/v2/customers';
        if ($customerFilters) {
            $params = $customerFilters->getParams();
            if (!empty($params)) {
                $uri .= '?'.http_build_query($params);
            }
        }

        return $this->loadCustomers(
            $uri,
            $customerRequest ?: new CustomerRequest()
        );
    }
48496
public function createSurveyPage($surveyId, array $data = [])
	{
		return $this->sendRequest(
			$this->createRequest('POST', sprintf('surveys/%d/pages', $surveyId), [], $data)
		);
	}
1158084
public static function get_surveys_by_courses($courseids = array()) {
        global $CFG, $USER, $DB;

        $returnedsurveys = array();
        $warnings = array();

        $params = self::validate_parameters(self::get_surveys_by_courses_parameters(), array('courseids' => $courseids));

        $mycourses = array();
        if (empty($params['courseids'])) {
            $mycourses = enrol_get_my_courses();
            $params['courseids'] = array_keys($mycourses);
        }

        // Ensure there are courseids to loop through.
        if (!empty($params['courseids'])) {

            list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);

            // Get the surveys in this course, this function checks users visibility permissions.
            // We can avoid then additional validate_context calls.
            $surveys = get_all_instances_in_courses("survey", $courses);
            foreach ($surveys as $survey) {
                $context = context_module::instance($survey->coursemodule);
                // Entry to return.
                $surveydetails = array();
                // First, we return information that any user can see in the web interface.
                $surveydetails['id'] = $survey->id;
                $surveydetails['coursemodule']      = $survey->coursemodule;
                $surveydetails['course']            = $survey->course;
                $surveydetails['name']              = external_format_string($survey->name, $context->id);

                if (has_capability('mod/survey:participate', $context)) {
                    $trimmedintro = trim($survey->intro);
                    if (empty($trimmedintro)) {
                        $tempo = $DB->get_field("survey", "intro", array("id" => $survey->template));
                        $survey->intro = get_string($tempo, "survey");
                    }

                    // Format intro.
                    list($surveydetails['intro'], $surveydetails['introformat']) =
                        external_format_text($survey->intro, $survey->introformat, $context->id, 'mod_survey', 'intro', null);
                    $surveydetails['introfiles'] = external_util::get_area_files($context->id, 'mod_survey', 'intro', false,
                                                                                    false);

                    $surveydetails['template']  = $survey->template;
                    $surveydetails['days']      = $survey->days;
                    $surveydetails['questions'] = $survey->questions;
                    $surveydetails['surveydone'] = survey_already_done($survey->id, $USER->id) ? 1 : 0;

                }

                if (has_capability('moodle/course:manageactivities', $context)) {
                    $surveydetails['timecreated']   = $survey->timecreated;
                    $surveydetails['timemodified']  = $survey->timemodified;
                    $surveydetails['section']       = $survey->section;
                    $surveydetails['visible']       = $survey->visible;
                    $surveydetails['groupmode']     = $survey->groupmode;
                    $surveydetails['groupingid']    = $survey->groupingid;
                }
                $returnedsurveys[] = $surveydetails;
            }
        }
        $result = array();
        $result['surveys'] = $returnedsurveys;
        $result['warnings'] = $warnings;
        return $result;
    }
755908
public function retrieveAll(array $filters = array(), $limit = null, $offset = null)
    {
        $result = clone $this->entityCollection;
        if (!empty($filters)) {
            $result = $result->search($filters);
        }
        if ($offset) {
            $result = $result->cslice($offset, $limit);
        }
        if ($limit && !$offset) {
            $result = $result->chunk($limit);
        }

        return $result;
    }