private function tryGivePoints(GivePointsContext $ctxt, $testingId) { if ($ctxt->hasPoints($testingId)) { return; //--- } $testResult = TestingBean::inst()->getTestingResult($testingId, $ctxt->getUserId()); if ($testResult && $testResult->getPercent() >= self::PASS_THRESHOLD_PCNT) { $ctxt->givePoints(5, $testingId); } }
public function givePointsImpl(GivePointsContext $ctxt, $modeHodes = null) { if ($ctxt->hasPoints()) { return; //--- } $check = array('m0R' => 8, 'm0K' => 16, 'm0B' => 14, 'm0N' => 32, 'm0Q' => 8, 'm1R' => 8, 'm1K' => 9, 'm1B' => 8, 'm1N' => 12, 'm1Q' => 5); $valid = false; if (is_array($modeHodes) && count($modeHodes) == 2) { foreach ($modeHodes as $mode => $hodes) { foreach ($hodes as $fig => $hod) { $key = $mode . $fig; $valid = array_key_exists($key, $check) && is_numeric($check[$key]) && strlen($hod) == $check[$key] * 2; if (!$valid) { return; //Невалидный ответ --- } } } } if ($valid) { $ctxt->givePoints(10); } }