Return all complete samples data from sample ids.

@param int[] $sampleids
@return array
967740
public function get_samples($sampleids) {
        global $DB;

        list($sql, $params) = $DB->get_in_or_equal($sampleids, SQL_PARAMS_NAMED);
        $courses = $DB->get_records_select('course', "id $sql", $params);

        $courseids = array_keys($courses);
        $sampleids = array_combine($courseids, $courseids);

        $courses = array_map(function($course) {
            return array('course' => $course, 'context' => \context_course::instance($course->id));
        }, $courses);

        // No related data attached.
        return array($sampleids, $courses);
    }
1212869
protected function checkUserIds(array $userIds)
    {
        $checkedUserIds = array();
        foreach ($userIds as $userId) {
            if (true === is_numeric($userId) && false === in_array($userId, $checkedUserIds)) {
                $checkedUserIds[] = (int)$userId;
            }
        }
        return $checkedUserIds;
    }
443664
public function itemsGet($ids) {
		if ((!is_array($ids)) || (empty($ids))) {
			BLog::addToLog('[BItems.' . $this->tableName . '] itemsGet() $ids empty=' . var_export($ids, true) . ')', LL_ERROR);
			return array();
		}
		if (DEBUG_LOG_BITEMS) {
			BLog::addToLog('[BItems.' . $this->tableName . '] itemsGet(' . implode(',', $ids) . ')');
		}
		$items = array();
		//-------------------------------------------------
		//Trying to get items from internal cache
		//-------------------------------------------------
		$ids_c = array(); //IDs as integer
		$ids_k = array(); //IDs as external cache key
		foreach ($ids as $id) {
			$idd = is_array($id) ? implode(':', $id) : $id;
			if (isset($this->cacheItems[$idd])) {
				$items[$idd] = $this->cacheItems[$idd];
			} else {
				if (!empty($idd)) {
					$items[$idd] = NULL;
					$ids_c[$idd] = $id;
					$ids_k[$idd] = $this->tableName . ':itemid:' . $idd;
				}
			}
		}
		if (empty($ids_c)) {
			return $items;
		}

		//-------------------------------------------------
		//Trying to get left items from external cache
		//-------------------------------------------------
		$cache = BFactory::getCache();
		if (!empty($cache)) {
			$ids_m = array();
			$ids_q = array();
			$items_c = $cache->mget($ids_k);
			foreach ($ids_c as $id) {
				$idd = is_array($id) ? implode(':', $id) : $id;
				$key = $this->tableName . ':itemid:' . $idd;
				if ((isset($items_c[$key])) && (!empty($items_c[$key]))) {
					$classname = $this->itemClassName;
					$items[$idd] = new $classname();
					$items[$idd]->load($items_c[$key]);
					$this->cacheItems[$idd] = $items[$idd];
				} else {
					array_push($ids_m, $id);
					array_push($ids_q, $id);
				}
			}
		} else {
			$ids_m = $ids_c;
			$ids_q = $ids_c;
		}
		if (empty($ids_m)) {
			return $items;
		}
		//-------------------------------------------------
		// Trying to get left items from database
		//-------------------------------------------------
		$db = BFactory::getDBO();
		if (empty($db)) {
			return $items;
		}
		if (is_array($this->primaryKeyName)) {
			$whi = array();
			foreach ($ids_q as $id) {
				$s = array();
				foreach ($id as $idk => $idv) {
					$s[] = '(`' . $idk . '`=' . $db->escapeString($idv) . ')';
				}
				$whi[] = '(' . implode(' AND ', $s) . ')';
			}
			$wh = implode(' OR ', $whi);
			$qr = 'SELECT * from `' . $this->tableName . '` WHERE (' . $wh . ')';
		} else {
			$qr = 'SELECT * from `' . $this->tableName . '` WHERE (`' . $this->primaryKeyName . '` in (' . implode(',', $ids_q) . '))';
		}
		$q = $db->Query($qr);
		if (empty($q)) {
			BLog::addToLog('[items]: itemsGet(): Could not execute query! MySQL error: ' . $db->lasterror(), LL_ERROR);
			return $items;
		}
		$tocache = array();
		$item_obj = array();
		while ($l = $db->fetch($q)) {
			if (is_array($this->primaryKeyName)) {
				$id = array();
				foreach ($this->primaryKeyName as $pk) {
					$id[$pk] = $l[$pk];
				}
				$idd = implode(':', $id);
				$item_obj[$idd] = $l;
			} else {
				$idd = (int)$l[$this->primaryKeyName];
				$item_obj[$idd] = $l;
			}
			foreach ($this->linkedTables as $tbl) {
				$item_obj[$idd][$tbl['field']] = array();
			}
		}
		//-------------------------------------------------
		// Loading data from external tables...
		//-------------------------------------------------
		if (DEBUG_LOG_BITEMS) {
			BLog::addToLog('[BItems.' . $this->tableName . '] itemsGet() Loading data from external tables...');
		}
		foreach ($this->linkedTables as $tbl) {
			$wh = array();
			$wh[] = '(`' . $tbl['extkey'] . '` in (' . implode(',', $ids_q) . '))';
			if (!empty($tbl['filter'])) {
				$wh[] = $tbl['filter'];
			}
			$qrl = 'SELECT * from `' . $tbl['name'] . '` WHERE (' . implode(' AND ', $wh) . ')';
			$ql = $db->Query($qrl);
			if (empty($ql)) {
				BLog::addToLog('[items]: itemsGet(): Could not execute external tables query! MySQL error: ' . $db->lasterror(), LL_ERROR);
				return false;
			}
			$datal = array();
			while ($ll = $db->fetch($ql)) {
				$itemid = (int)$ll[$tbl['extkey']];
				$item_obj[$itemid][$tbl['field']][] = $ll;
			}
		}
		//-------------------------------------------------
		// Creating item object...
		//-------------------------------------------------
		if (DEBUG_LOG_BITEMS) {
			BLog::addToLog('[BItems.' . $this->tableName . '] itemsGet() Creating item objects...');
		}
		foreach ($item_obj as $k => $l) {
			$classname = $this->itemClassName;
			if (!class_exists($classname)) {
				$msg = 'Class "' . $classname . '" does not exist!';
				BLog::addToLog($msg, LL_ERROR);
				die($msg);
			}
			$items[$k] = new $classname();
			$items[$k]->load($l);
			$this->cacheItems[$k] = $items[$k];
			if (CACHE_TYPE) {
				$tocache[$this->tableName . ':itemid:' . $k] = $l;
			}
		}
		//-------------------------------------------------
		// Cache storing, if necessary.
		//-------------------------------------------------
		if ((!empty($cache)) && (count($tocache) != 0)) {
			$cache->mset($tocache, $this->cacheTime);//1 hour
		}
		if (DEBUG_LOG_BITEMS) {
			BLog::addToLog('[BItems.' . $this->tableName . '] itemsGet() All done! Returning items.');
		}
		return $items;
	}
457342
private function powerSet(array $sample): array
    {
        $results = [[]];
        foreach ($sample as $item) {
            foreach ($results as $combination) {
                $results[] = array_merge([$item], $combination);
            }
        }

        return $results;
    }
973615
protected static function get_item_ids_from_course_ids($courseids) {
        global $DB;
        if (empty($courseids)) {
            return [];
        }
        list($insql, $inparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
        return $DB->get_fieldset_select('grade_items', 'id', "courseid $insql", $inparams);
    }
971423
public function findDomainRecordsByRootPagesIds(array $rootPageIds = [])
    {
        $resultTmp = $this->getDomainRecordsByRootPageIds($rootPageIds);

        $result = [];
        foreach ($resultTmp as $key => $row) {
            $result[$row['pid']] = $row;
        }
        return $result;
    }
213059
public function getChildren($id): array
    {
        $result = [];
        $childrenIds = (array)($this->childrenIds[$id] ?? []);
        foreach ($childrenIds as $childId) {
            if ($child = $this->getItem($childId)) {
                $result[$childId] = $child;
            }
        }
        return $result;
    }
998992
protected function getIDList() : array
    {
        //Get element ID list from cache
        $arElementIDList = $this->getIDListFromCache();
        if (!empty($arElementIDList) && is_array($arElementIDList)) {
            return $arElementIDList;
        }

        $arElementIDList = $this->getIDListFromDB();
        $this->saveIDList($arElementIDList);

        return $arElementIDList;
    }
779001
public function getSessionData($storeId, $sessionIds)
    {
        $data = [];
        $searchRequest  = $this->getSearchRequest($storeId, $sessionIds);
        $searchResponse = $this->searchEngine->search($searchRequest);

        foreach ($searchResponse->getAggregations()->getBucket('session_id')->getValues() as $sessionValue) {
            $sessionData = $this->processSessionData($sessionValue);
            $sessionData['store_id'] = $storeId;
            unset($sessionData['count']);

            $data[] = array_filter($sessionData);
        }

        return $data;
    }
431369
public List<Sample> getSamples(String studyId) {
        VariantStudyMetadata variantStudyMetadata = getVariantStudyMetadata(studyId);
        if (variantStudyMetadata == null) {
            logger.error("Study not found. Check your study ID: '{}'", studyId);
            return null;
        }

        List<Sample> samples = new ArrayList<>();
        if (variantStudyMetadata.getIndividuals() != null) {
            for (org.opencb.biodata.models.metadata.Individual individual : variantStudyMetadata.getIndividuals()) {
                for (Sample sample : individual.getSamples()) {
                    if (sample.getAnnotations() == null) {
                        sample.setAnnotations(new HashMap<>());
                    }
                    samples.add(sample);
                }
            }
        }
        return samples;
    }
713729
public function getIds()
    {
        $res = array();
        $array = wincache_ucache_info();
        $records = $array['ucache_entries'];
        foreach ($records as $record) {
            $res[] = $record['key_name'];
        }
        return $res;
    }
854391
public function getByIds(array $ids): array
    {

        $entities = $this->getRepository()->findByIds($ids);

        $this->prepareEntitesForGet($entities);

        return $entities;
    }
456887
private function getAllChildRoleIds($parentIds)
    {
        $allChildIds = [];

        while (count($parentIds) > 0) {
            $parentIds = $this->getChildIds($parentIds);
            $allChildIds = ArrayHelper::merge($allChildIds, $parentIds);
        };

        return $allChildIds;
    }
80983
protected function findOrphanedIds(): array
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('cc.id AS id')
                     ->from(CraftingCategory::class, 'cc')
                     ->leftJoin('cc.machines', 'm')
                     ->leftJoin('cc.recipes', 'r')
                     ->andWhere('m.id IS NULL')
                     ->andWhere('r.id IS NULL');

        $result = [];
        foreach ($queryBuilder->getQuery()->getResult() as $data) {
            $result[] = (int) $data['id'];
        }
        return $result;
    }
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;
    }
847100
protected function getPages($ids)
    {
        // Check empty set
        if (empty($ids)) {
            return new ArrayList();
        }

        $recordClass = $this->recordClass;

        // Bypass translatable filter
        if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) {
            Translatable::disable_locale_filter();
        }

        // Bypass versioned filter
        if ($recordClass::has_extension(Versioned::class)) {
            // Workaround for get_including_deleted not supporting byIDs filter very well
            // Ensure we select both stage / live records
            $pages = Versioned::get_including_deleted($recordClass)->byIDs($ids);
        } else {
            $pages = DataObject::get($recordClass)->byIDs($ids);
        }

        if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) {
            Translatable::enable_locale_filter();
        }

        return $pages;
    }
344077
public function getExcludedIds()
    {
        $excludedIdsString = $this->getRequest()->get('excludedIds');

        return (null !== $excludedIdsString) ? array_filter(explode(',', $excludedIdsString)) : [];
    }