2021-04-25 21:28:58 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace Nexus\Exam;
|
|
|
|
|
|
|
2021-04-28 19:44:48 +08:00
|
|
|
|
use App\Models\ExamUser;
|
2021-04-25 21:28:58 +08:00
|
|
|
|
use App\Repositories\ExamRepository;
|
|
|
|
|
|
|
|
|
|
|
|
class Exam
|
|
|
|
|
|
{
|
|
|
|
|
|
public function render($uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
$examRep = new ExamRepository();
|
2021-06-14 01:54:19 +08:00
|
|
|
|
$userExam = $examRep->getUserExamProgress($uid, ExamUser::STATUS_NORMAL);
|
2021-04-26 20:37:17 +08:00
|
|
|
|
if (empty($userExam)) {
|
2021-04-25 21:28:58 +08:00
|
|
|
|
return '';
|
|
|
|
|
|
}
|
2021-04-26 20:37:17 +08:00
|
|
|
|
$exam = $userExam->exam;
|
|
|
|
|
|
$row = [];
|
2021-04-28 19:44:48 +08:00
|
|
|
|
$row[] = sprintf('%s:%s', nexus_trans('exam.name'), $exam->name);
|
|
|
|
|
|
$row[] = sprintf('%s:%s ~ %s', nexus_trans('exam.time_range'), $userExam->begin, $userExam->end);
|
|
|
|
|
|
foreach ($userExam->progress_formatted as $key => $index) {
|
2021-04-26 20:37:17 +08:00
|
|
|
|
if (isset($index['checked']) && $index['checked']) {
|
|
|
|
|
|
$row[] = sprintf(
|
2021-04-28 19:44:48 +08:00
|
|
|
|
'%s:%s, %s:%s, %s:%s, %s:%s',
|
|
|
|
|
|
nexus_trans('exam.index') . ($key + 1), nexus_trans('exam.index_text_' . $index['index']),
|
|
|
|
|
|
nexus_trans('exam.require_value'), $index['require_value_formatted'],
|
|
|
|
|
|
nexus_trans('exam.current_value'), $index['current_value_formatted'],
|
|
|
|
|
|
nexus_trans('exam.result'),
|
|
|
|
|
|
$index['passed'] ? nexus_trans('exam.result_pass') : nexus_trans('exam.result_not_pass')
|
2021-04-26 20:37:17 +08:00
|
|
|
|
);
|
2021-04-25 21:28:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-21 19:09:32 +08:00
|
|
|
|
if ($exam->description) {
|
|
|
|
|
|
$row[] = "\n" . $exam->description;
|
|
|
|
|
|
}
|
2021-04-26 20:37:17 +08:00
|
|
|
|
return nl2br(implode("\n", $row));
|
2021-04-25 21:28:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|