42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
require_once "LogicTaskBase.php";
|
|
|
|
class TruthTableTask extends LogicTaskBase
|
|
{
|
|
private float $bad_line_score; // points for a bad line in the truth table
|
|
public function __construct(array $a = null)
|
|
{
|
|
parent::__construct("truthtable", $a);
|
|
|
|
$this->bad_line_score = $a["bad_line_score"] ?? -1.0;
|
|
}
|
|
|
|
function setBadLineScore(float $bad_line_score): void {
|
|
$this->bad_line_score = $bad_line_score;
|
|
}
|
|
|
|
function getBadLineScore(): float {
|
|
return $this->bad_line_score;
|
|
}
|
|
|
|
public function staticCheck(): void
|
|
{
|
|
$errs = $this->getTTDiffCntToCA($this->player_answer ?? "");
|
|
$mark = $this->getMaxMark() + $errs * $this->getBadLineScore();
|
|
$this->setMark($mark);
|
|
}
|
|
|
|
public function toArray(string $mode = "all"): array
|
|
{
|
|
$a = parent::toArray($mode);
|
|
|
|
if ($mode === "all") {
|
|
$a["bad_line_score"] = $this->bad_line_score;
|
|
}
|
|
|
|
$a["correct_answer"] = $this->getLogicFunction()->getTruthTable();
|
|
|
|
return $a;
|
|
}
|
|
} |