Commit 139ff413 authored by Jan Dillenberger's avatar Jan Dillenberger

Fix Bug: negative weight was not applied

parent 1e63ab0f
Pipeline #21895 failed with stage
in 110 minutes and 38 seconds
......@@ -59,7 +59,7 @@ abstract class Answer extends Model
public function __get($key)
{
if (in_array($key, ['formId', 'fieldId', 'subQuestion', 'weight', 'type'])) {
if (in_array($key, ['formId', 'fieldId', 'subQuestion', 'type'])) {
return $this->getEvaluable()->first()->{$key};
} elseif (in_array($key, ['value'])) {
return $this->getValue();
......@@ -72,4 +72,4 @@ abstract class Answer extends Model
$typeClass = str_replace('Answer', '', (new \ReflectionClass(get_called_class()))->getShortName());
return $this->belongsTo(__NAMESPACE__ . "\\$typeClass", 'evaluableId')->getResults();
}
}
\ No newline at end of file
}
......@@ -37,12 +37,12 @@ class Likert extends Evaluable
public function getMinScore(): int
{
return $this->getMinValue() * $this->weight;
return $this->getMinValue();
}
public function getMaxScore(): int
{
return $this->getMaxValue() * $this->weight;
return $this->getMaxValue();
}
protected function getAnswer($answerEntry, $gfField)
......@@ -50,7 +50,8 @@ class Likert extends Evaluable
return new LikertAnswer([
'evaluableId' => $this->id,
'gfEntry' => $answerEntry,
'gfField' => $gfField
'gfField' => $gfField,
'weight' => $this->weight,
]);
}
}
\ No newline at end of file
}
......@@ -16,6 +16,7 @@ class LikertAnswer extends Answer
$this->evaluableId = $attributes['evaluableId'];
$this->gfEntry = $attributes['gfEntry'];
$this->gfField = $attributes['gfField'];
$this->weight = $attributes['weight'];
parent::__construct($attributes);
}
......@@ -39,4 +40,4 @@ class LikertAnswer extends Answer
return null;
}
}
\ No newline at end of file
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment