src/Biz/Question/Type/Fill.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Question\Type;
use Biz\Question\QuestionException;
class Fill extends BaseQuestion implements TypeInterface
{
public function create($fields)
{
}
public function update($id, $fields)
{
}
public function delete($id)
{
}
public function get($id)
{
}
public function judge($question, $answer)
{
$questionAnswers = array_values($question['answer']);
$answer = array_values($answer);
if (count($answer) != count($questionAnswers)) {
return array('status' => 'wrong', 'score' => 0);
}
$userAnswerIndex = $this->getAnswerIndex($questionAnswers, $answer);
$rightCount = count($userAnswerIndex);
if (0 == $rightCount) {
return array('status' => 'wrong', 'score' => 0);
} elseif ($rightCount < count($questionAnswers)) {
$percentage = intval($rightCount / count($questionAnswers) * 100);
$score = ($question['score'] * $percentage) / 100;
$score = number_format($score, 1, '.', '');
return array('status' => 'partRight', 'percentage' => $percentage, 'score' => $score);
} else {
return array('status' => 'right', 'score' => $question['score']);
}
}
public function filter(array $fields)
{
$fields = parent::filter($fields);
preg_match_all("/\[\[(.+?)\]\]/", $fields['stem'], $answer, PREG_PATTERN_ORDER);
if (empty($answer[1])) {
throw QuestionException::UNEXPECTED_ANSWER();
}
$fields['answer'] = array();
foreach ($answer[1] as $value) {
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。