exam user show is_done

This commit is contained in:
xiaomlove
2021-05-15 02:13:33 +08:00
parent a0bb422a58
commit dea20254bf
25 changed files with 32 additions and 20 deletions

View File

@@ -30,6 +30,8 @@ class ExamUserResource extends JsonResource
'end' => format_datetime($this->end),
'uid' => $this->uid,
'exam_id' => $this->exam_id,
'is_done' => $this->is_done,
'is_done_text' => $this->is_done_text,
'user' => new UserResource($this->whenLoaded('user')),
'exam' => new ExamResource($this->whenLoaded('exam')),
];

View File

@@ -19,6 +19,11 @@ class ExamUser extends NexusModel
const IS_DONE_YES = 1;
const IS_DONE_NO = 0;
public static $isDoneInfo = [
self::IS_DONE_YES => ['text' => 'Yes'],
self::IS_DONE_NO => ['text' => 'No'],
];
protected $casts = [
'progress' => 'json'
@@ -29,6 +34,11 @@ class ExamUser extends NexusModel
return self::$status[$this->status]['text'] ?? '';
}
public function getIsDoneTextAttribute(): string
{
return self::$isDoneInfo[$this->is_done]['text'] ?? '';
}
public function getBeginAttribute()
{
$begin = $this->getRawOriginal('begin');