Return all stats for variants of randomly selected questions for one slot $slot.

@param int $slot The slot no.
@return calculated[] The instances storing the calculated stats.
4611
protected function all_subq_variants_for_one_slot($slot) {
        $toreturn = array();
        $displayorder = 1;
        foreach ($this->for_slot($slot)->get_sub_question_ids() as $subqid) {
            if ($variants = $this->for_subq($subqid)->get_variants()) {
                foreach ($variants as $variant) {
                    $toreturn[] = $this->make_new_subq_stat_for($displayorder, $slot, $subqid, $variant);
                }
            }
            $displayorder++;
        }
        return $toreturn;
    }
1137349
protected function populate_missing_questions($slots) {
        // Address missing question types.
        foreach ($slots as $slot) {
            if ($slot->qtype === null) {
                // If the questiontype is missing change the question type.
                $slot->id = $slot->questionid;
                $slot->category = 0;
                $slot->qtype = 'missingtype';
                $slot->name = get_string('missingquestion', 'quiz');
                $slot->slot = $slot->slot;
                $slot->maxmark = 0;
                $slot->requireprevious = 0;
                $slot->questiontext = ' ';
                $slot->questiontextformat = FORMAT_HTML;
                $slot->length = 1;

            } else if (!\question_bank::qtype_exists($slot->qtype)) {
                $slot->qtype = 'missingtype';
            }
        }

        return $slots;
    }
819905
public function repaginate_the_rest($quizslots, $slotfrom, $type, $dbupdate = true) {
        global $DB;
        if (!$quizslots) {
            return null;
        }
        $newslots = array();
        foreach ($quizslots as $slot) {
            if ($type == self::LINK) {
                if ($slot->slot <= $slotfrom) {
                    continue;
                }
                $slot->page = $slot->page - 1;
            } else if ($type == self::UNLINK) {
                if ($slot->slot <= $slotfrom - 1) {
                    continue;
                }
                $slot->page = $slot->page + 1;
            }
            // Update DB.
            if ($dbupdate) {
                $DB->update_record('quiz_slots', $slot);
            }
            $newslots[$slot->id] = $slot;
        }
        return $newslots;
    }
239288
private function get_slot() {
		for ($i = 0; $i < $this->max_processes; $i++) {
			if ($this->processes[$i] == -1) {
				return $i;
			}
		}
		return -1;
	}
622113
protected function createSlotManager(Slot $slot)
    {
        $slotName = $slot->getSlotName();
        $blocks = array();
        if (null !== $this->pageBlocks) {
            $blocks = $this->pageBlocks->getSlotBlocks($slotName);
        }
        $slotManager = new SlotManager($slot, $this->blockRepository, $this->blockManagerFactory);
        $slotManager->setUpBlockManagers($blocks);

        return $slotManager;
    }
448476
protected function indexedParameters(Slot $slot, array $named)
    {
        $definition = $slot->parameters;
        $names = isset($definition[0]) ? $definition : array_keys($definition);

        $indexed = [];
        foreach ($names as $i=>$name) {
            $indexed[$i] = isset($named[$name]) ? $named[$name] : null;
        }

        return $indexed;
    }
1215166
private function blocksToArray(array $slotBlocks)
    {
        foreach ($slotBlocks as $block) {
            $aBlock = $block->toArray();
            unset($aBlock["Id"]);

            $this->arrayBlocks[] = $aBlock;
        }
    }
189832
protected function guessNode($slot)
    {
        if (isset($this->slotsMap[$slot])) {
            return $this->slotsMap[$slot];
        }

        $count = \count($this->hosts);
        $index = \min((int) ($slot / (int) (16384 / $count)), $count - 1);
        $nodes = \array_values($this->hosts);

        return $nodes[$index];
    }
31076
public function get_summary_after_try($tablerow, $slot) {
        $qa = $this->get_question_attempt($tablerow->usageid, $slot);
        if (!($qa->get_question() instanceof question_manually_gradable)) {
            // No responses, and we cannot call summarise_response below.
            return null;
        }
        $submissionsteps = $qa->get_steps_with_submitted_response_iterator();
        $step = $submissionsteps[$tablerow->try];
        if ($step === null) {
            return null;
        }
        $qtdata = $step->get_qt_data();
        return $qa->get_question()->summarise_response($qtdata);
    }
386312
public function getTableIndexes( $table )
    {
        $query = "SELECT * FROM information_schema.statistics WHERE table_schema =
                 ? AND table_name = ?";

        $params = [ $this->name, $table ];

        $statement = $this->database->prepare( $query );
        $statement->execute( $params );

        $results = $statement->fetchAll();

        $indexes = [ ];

        if ( !empty( $results ) )
        {
            $name = NULL;

            $i = 0;

            foreach ( $results as $result )
            {
                if ( !in_array( $result[ 'INDEX_NAME' ], $indexes ) )
                {
                    $indexes[ ] = $result[ 'INDEX_NAME' ];
                }
            }
        }

        return $indexes;
    }
1209037
public function repaginate_n_question_per_page($slots, $number) {
        $slots = $this->get_slots_by_slot_number($slots);
        $newslots = array();
        $count = 0;
        $page = 1;
        foreach ($slots as $key => $slot) {
            for ($page + $count; $page < ($number + $count + 1); $page++) {
                if ($slot->slot >= $page) {
                    $slot->page = $page;
                    $count++;
                }
            }
            $newslots[$slot->id] = $slot;
        }
        return $newslots;
    }
30016
public function can_question_be_redone_now($slot) {
        return $this->get_quiz()->canredoquestions && !$this->is_finished() &&
                $this->get_question_state($slot)->is_finished();
    }
1059801
public function render_question_for_commenting($slot) {
        $options = $this->get_display_options(true);
        $options->hide_all_feedback();
        $options->manualcomment = question_display_options::EDITABLE;
        return $this->quba->render_question($slot, $options,
                $this->get_question_number($slot));
    }
829535
public function process($slot)
    {
        $tasks = $this->getTasksForSlot($slot);
        while ($tasks->valid()) {
            $task = $tasks->current();
            $this->log->info('Processing task: '.$task->getName());
            try {
                $task->process($this);
            } catch (Exception $e) {
                var_dump($e);
            }

            /*
             * The Post-Process continues on failure

            if ($slot != Slot::POST_PROCESS) {
                if ($this->getStatus() != BuildInterface::PASSED) {
                    $tasks->rewind();
                    break;
                }
            }
            */
            $tasks->next();
        }
        $tasks->rewind();
    }
145930
def get_analyses_at(self, slot):
        

        # ensure we have an integer
        slot = to_int(slot)

        if slot < 1:
            return list()

        analyses = list()
        layout = self.getLayout()

        for pos in layout:
            layout_slot = to_int(pos['position'])
            uid = pos['analysis_uid']
            if layout_slot != slot or not uid:
                continue
            analyses.append(api.get_object_by_uid(uid))

        return analyses
879442
public function getRandomQuestion(SessionConfigurationInterface $configuration)
    {
        /** @var QuestionRepository $questionRepository */
        $questionRepository = $this->manager->getRepository('QcmPublicBundle:Question');
        $maxQuestions = $configuration->getMaxQuestions() - $configuration->getQuestions()->count();

        $averagePerCategory = $maxQuestions;
        if ($maxQuestions >= $configuration->getCategories()->count()) {
            $averagePerCategory = floor($maxQuestions/$configuration->getCategories()->count());
        }

        $questionsId = array_map(function($question) {
            return $question->getId();
        }, $configuration->getQuestions()->toArray());

        foreach ($configuration->getCategories() as $category) {
            if ($configuration->getMaxQuestions() - $configuration->getQuestions()->count() > 0) {
                $questions = $questionRepository->getRandomQuestions(
                    $category->getId(),
                    $averagePerCategory,
                    $configuration->getQuestionsLevel(),
                    $questionsId
                );

                /** @var QuestionInterface $question */
                foreach ($questions as $question) {
                    foreach ($question->getAnswers() as $answer) {
                        $question->addAnswer($answer);
                    }
                    $configuration->addQuestion($question);
                }
            }
        }

        return $this;
    }
579025
protected function guessNode($slot)
    {
        if (!$this->pool) {
            throw new ClientException('No connections available in the pool');
        }

        if (!isset($this->slotsMap)) {
            $this->buildSlotsMap();
        }

        if (isset($this->slotsMap[$slot])) {
            return $this->slotsMap[$slot];
        }

        $count = count($this->pool);
        $index = min((int) ($slot / (int) (16384 / $count)), $count - 1);
        $nodes = array_keys($this->pool);

        return $nodes[$index];
    }