Helper method used by both {@link start_attempt()} and
{@link apply_attempt_state()}.
@param array $choiceorder the choices, in order.
517310
protected function set_choiceorder($choiceorder) {
        $this->choiceorder = array();
        foreach ($choiceorder as $key => $choiceid) {
            $this->choiceorder[$key + 1] = $choiceid;
        }
    }
76686
public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
    {
        return $this->output->choice($question, $choices, $default, $attempts, $multiple);
    }
471891
private function resolveChoiceViewValue($selectedValue)
    {
        foreach ($this->choiceViews as $choiceView) {
            if (in_array($selectedValue, [$choiceView->data, $choiceView->value, $choiceView->label])) {
                return $choiceView->value;
            }
        }

        throw new \InvalidArgumentException(sprintf($this->_errorMessage, $selectedValue));
    }
739483
public function addChoice($choiceIdent, $choice)
    {
        $choice = $this->parseChoice($choice, strval($choiceIdent));
        $choiceIdent = $choice['value'];

        $this->choices[$choiceIdent] = $choice;

        return $this;
    }
1065921
public function choose($string, array $choices, $useChoiceKeysAsSelector = true) {
        $this->output->writeLine("<question>$string</question>");

        $choicesMap = [];

        foreach ($choices as $subject => $message) {
            if ($useChoiceKeysAsSelector) {
                $index = $subject;
            } else {
                $index = count($choicesMap) + 1;
            }

            $choicesMap[$index] = [
                'subject' => $subject,
                'message' => $message,
            ];
        }

        foreach ($choicesMap as $index => $choice) {
            $message = array_get($choice, 'message');

            $this->output->writeLineIndented("[<yellow>$index</yellow>] $message");
        }

        $choice = null;

        while (true) {
            $this->output->writeIndented('Choice: ');
            $input = $this->input->readLine();

            if (array_has($choicesMap, $input)) {
                $choice = array_get(array_get($choicesMap, $input), 'subject');
                break;
            }

            if ( ! empty($input)) {
                $this->output->writeLineIndented('<yellow>Invalid choice</yellow>');
            }
        }

        return $choice;
    }
366242
protected function ensureSortOrder(
        array $sortOrderCondition = [],
        string $sortOrderAttribute = 'sortOrder'
    ) {
        if ($this->getAttribute($sortOrderAttribute) === null) {
            $this->setAttribute(
                $sortOrderAttribute,
                $this->nextSortOrder(
                    $sortOrderCondition,
                    $sortOrderAttribute
                )
            );
        }
    }
725190
def set_choice_order(self, choice_ids, inline_region):
        
        reordered_choices = []
        current_choice_ids = [c['id'] for c in self.my_osid_object_form._my_map['choices'][inline_region]]
        if set(choice_ids) != set(current_choice_ids):
            raise IllegalState('missing choices for choice order')

        for choice_id in choice_ids:
            for current_choice in self.my_osid_object_form._my_map['choices'][inline_region]:
                if choice_id == current_choice['id']:
                    reordered_choices.append(current_choice)
                    break

        self.my_osid_object_form._my_map['choices'][inline_region] = reordered_choices
961061
public static function assertValidChoice(string $value): void
    {
        if (!isset(static::$choices[$value])) {
            throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM type "%s".', $value, static::class));
        }
    }
131145
public void setGroupOrder(int inputNum, Ordering order) {
		if (inputNum == 0) {
			this.groupOrder1 = order;
		} else if (inputNum == 1) {
			this.groupOrder2 = order;
		} else {
			throw new IndexOutOfBoundsException();
		}
	}
1034298
public function search(SearchCondition\SearchConditionInterface $filter, SelectOrder\SelectOrderInterface $order = null)
	{
		if ( ! ($filter instanceof SearchCondition\ArraySearchCondition)) {
			throw new Exception\WrongInstance($filter, 'SearchCondition\ArraySearchCondition');
		}
		$filterClosure = $filter->getSearchClosure();

		$orderClosure = null;
		if ( ! \is_null($order)) {
			if ( ! ($order instanceof SelectOrder\ArraySelectOrder)) {
				throw new Exception\WrongInstance($order, 'SelectOrder\ArraySelectOrder');
			}
			$orderClosure = $order->getOrderClosure();
		}

		$result = $this->searchByClosure($filterClosure, $orderClosure);
		
		return $result;
	}
51949
@Override
    public void setOrder(char order) {
        Preconditions.checkArgument(order == 'c' || order == 'f', "Order specified must be either c or f: got %s", String.valueOf(order));
        this.order = order;
    }
406065
private function configureWindow(SelectQuery $query, array $orderBy, int $limit = 0)
    {
        if (!empty($orderBy)) {
            $decorator = new AliasDecorator($query, 'where', $this->getAlias());
            $decorator->orderBy($orderBy);
        }

        if ($limit !== 0) {
            $query->limit($limit);
        }
    }
729583
public function addOrder(Order $order)
    {
        if (count($this->orders)+1 >= self::MAX_NUM_ORDERS)
        {
            throw new Exception('Cannot have more than '.self::MAX_NUM_ORDERS.' Orders in a single Order Collection');
        }

        $this->orders[] = $order;
        $order->setCollection($this);
    }
1112000
protected function applyOrderConditions(ISelectBuilder $selectBuilder)
    {
        foreach ($this->orderConditions as $collectionInfo) {
            /**
             * @var IField $field
             */
            list ($field, $fieldSourceAlias, $direction) = $collectionInfo;
            $alias = $fieldSourceAlias . self::FIELD_SEPARATOR . $field->getColumnName();
            $selectBuilder->orderBy($alias, $direction);
        }
    }
376693
public void setStatusOrder(Status... statusOrder) {
		String[] order = new String[statusOrder.length];
		for (int i = 0; i < statusOrder.length; i++) {
			order[i] = statusOrder[i].getCode();
		}
		setStatusOrder(Arrays.asList(order));
	}
1161897
protected function applySorting(QueryBuilder $queryBuilder, array $sorting = null)
    {
        if (null === $sorting) {
            return;
        }

        foreach ($sorting as $property => $order) {
            if (!empty($order)) {
                $queryBuilder->orderBy($this->getPropertyName($property), $order);
            }
        }
    }
566309
private function executeChoice(SymfonyStyle $helper, $choice)
    {
        if (self::ACTION_DATABASE_IMPORT === $choice) {
            return $this->actionDatabaseImport($helper);
        }

        throw new \RuntimeException(sprintf('Unknown choice %s', $choice));
    }