Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistency in Value für Division of Int in Formula Question #4611

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,11 @@ public function editQuestion($checkonly = false)
$intPrecision = $form->getItemByPostVar('intprecision_' . $variable->getVariable());
$decimal_spots = $form->getItemByPostVar('precision_' . $variable->getVariable());
if ($decimal_spots->getValue() == 0) {
if ($intPrecision->getValue() > $max_range->getValue()) {
if (!$variable->isIntPrecisionValid(
$intPrecision->getValue(),
$min_range->getValue(),
$max_range->getValue()
)) {
$intPrecision->setAlert($this->lng->txt('err_division'));
$custom_errors = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public function getRandomValue()

// @todo check this
if ($this->getPrecision() == 0) {
if ($this->getIntprecision() > $this->getRangeMax()) {
if (!$this->isIntPrecisionValid(
$this->getIntprecision(),
$this->getRangeMin(),
$this->getRangeMax()
)) {
global $DIC;
$lng = $DIC['lng'];
ilUtil::sendFailure($lng->txt('err_divider_too_big'));
Expand Down Expand Up @@ -90,6 +94,17 @@ public function setRandomValue()
{
$this->setValue($this->getRandomValue());
}

public function isIntPrecisionValid($int_precision, $min_range, $max_range)
{
$min_abs = abs($min_range);
$max_abs = abs($max_range);
$bigger_abs = $max_abs > $min_abs ? $max_abs : $min_abs;
if ($int_precision > $bigger_abs) {
return false;
}
return true;
}

/************************************
* Getter and Setter
Expand Down
2 changes: 1 addition & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -11687,7 +11687,7 @@ assessment#:#tolerance#:#Toleranz (%)
assessment#:#result_units#:#Auswählbare Einheiten
assessment#:#precision#:#Präzision
assessment#:#err_range#:#Die obere Grenze muss größer als die untere Grenze sein.
assessment#:#err_division#:#Dieser Wert muss kleiner als das Maximum sein.
assessment#:#err_division#:#Der von Ihnen gesetzte Wert macht es unmöglich einen gültigen Wert für die Variable zu generieren.
assessment#:#err_divider_too_big#:#Der Teiler einer der Variablen in dieser Frage ist zu gross.
assessment#:#err_no_formula#:#Bitte geben Sie eine Formel zur Berechnung des Ergebnisses an.
assessment#:#err_wrong_rating_advanced#:#Bitte stellen Sie sicher, dass die Summe der erweiterten Bewertungsoptionen genau 100 Prozent ergibt.
Expand Down
2 changes: 1 addition & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -11736,7 +11736,7 @@ assessment#:#tolerance#:#Tolerance (%)
assessment#:#result_units#:#Available Units
assessment#:#precision#:#Precision
assessment#:#err_range#:#The maximum range must be greater than the minimum range
assessment#:#err_division#:#This value has to be smaller than the maximum range.
assessment#:#err_division#:#The value you chose would make it impossible to generate a valid value for the variable.
assessment#:#err_divider_too_big#:#The divider of one of the variables in this question is too big.
assessment#:#err_no_formula#:#You must enter a formula
assessment#:#err_wrong_rating_advanced#:#Please make sure that the addition of the advanced rating settings equals to 100 percent
Expand Down