<?php
 namespace Module\Paper\Util; use ModStart\Core\Input\Response; use ModStart\Core\Util\HtmlUtil; class PaperExamUtil { public static function isEnable() { return modstart_config('modulePaperExamEnable', false); } public static function disabledResponse() { return Response::generateError('考试功能未开启'); } public static function isCorrect($options, $answer) { $correctAnswer = []; foreach ($options as $index => $option) { if ($option['isAnswer']) { $correctAnswer[] = $index; } } return json_encode($answer) == json_encode($correctAnswer); } public static function isTextCorrect($correctAnswer, $answer) { return trim(HtmlUtil::text($correctAnswer)) == trim($answer); } public static function optionToAnswerLabel($answer) { $labelAnswers = []; foreach ($answer as $item) { $labelAnswers[] = chr(ord('A') + $item); } return join(', ', $labelAnswers); } }