From aeee5b527553e5557f21faa07c32c2b02d56e396 Mon Sep 17 00:00:00 2001 From: Epagris Date: Tue, 14 Oct 2025 15:06:23 +0200 Subject: [PATCH] - ... --- class/LogicUtils.php | 3 +++ class/Tasks/LogicFunctionTask.php | 6 +++++- class/Tasks/LogicTaskBase.php | 4 ---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/class/LogicUtils.php b/class/LogicUtils.php index ab7420e..068adf5 100644 --- a/class/LogicUtils.php +++ b/class/LogicUtils.php @@ -48,6 +48,9 @@ class LogicUtils } } else { $numa_str = self::extend($numa_str, $base, $digits, false); + if (($rep === "c") && ($numa_str[0] >= ($base / 2))) { + $numa_str = str_pad($numa_str, 1, "0", STR_PAD_LEFT); + } } return $numa_str; } diff --git a/class/Tasks/LogicFunctionTask.php b/class/Tasks/LogicFunctionTask.php index 701a16c..11fa95f 100644 --- a/class/Tasks/LogicFunctionTask.php +++ b/class/Tasks/LogicFunctionTask.php @@ -14,7 +14,11 @@ class LogicFunctionTask extends LogicTaskBase if (!$this->hasFlag("dnf")) { $this->setCorrectAnswer($this->getLogicFunction()->getExpression()); } else { - $this->setCorrectAnswer($this->getLogicFunction()->toDNF()); + $dnf = $this->getLogicFunction()->toDNF(); + if ($dnf === "") { + $dnf = "0"; + } + $this->setCorrectAnswer($dnf); } } diff --git a/class/Tasks/LogicTaskBase.php b/class/Tasks/LogicTaskBase.php index 3317a4a..d1d945c 100644 --- a/class/Tasks/LogicTaskBase.php +++ b/class/Tasks/LogicTaskBase.php @@ -89,10 +89,6 @@ class LogicTaskBase extends PicturedTask $this->lf = LogicFunction::genRandomDNF(LuaUtils::l2pA($input_vars)); } - public function getFunctionAsDNF(): string { - return $this->lf->toDNF(); - } - public function setLogicFunctionExpr(string $expr, array $input_vars = []): void { $this->lf = new LogicFunction($expr, LuaUtils::l2pA($input_vars)); }