exam user detail

This commit is contained in:
xiaomlove
2025-02-25 02:05:49 +08:00
parent 7b3e74b47e
commit ac5f733edb
8 changed files with 74 additions and 25 deletions

View File

@@ -10,4 +10,9 @@ class Permission
{
return user_can(PermissionEnum::UPLOAD_TO_SPECIAL_SECTION->value);
}
public static function canBeAnonymous(): bool
{
return user_can(PermissionEnum::BE_ANONYMOUS->value);
}
}

View File

@@ -4,4 +4,5 @@ namespace App\Enums;
enum PermissionEnum: string {
case UPLOAD_TO_SPECIAL_SECTION = 'uploadspecial';
case BE_ANONYMOUS = 'beanonymous';
}

View File

@@ -11,6 +11,7 @@ use App\Repositories\HitAndRunRepository;
use Carbon\Carbon;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Infolists\Components\ViewEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Tables\Table;
@@ -179,25 +180,9 @@ class ExamUserResource extends Resource
->columns(2)
,
Components\Group::make([
Components\Grid::make(3) // 3 列的网格
->schema([
Infolists\Components\TextEntry::make('header1')->label('Header 1'),
Infolists\Components\TextEntry::make('header2')->label('Header 2'),
Infolists\Components\TextEntry::make('header3')->label('Header 3'),
]),
Components\Grid::make(3) // 数据行
->schema([
Infolists\Components\TextEntry::make('data1')->getStateUsing(fn ($record) => $record->data1),
Infolists\Components\TextEntry::make('data2')->getStateUsing(fn ($record) => $record->data2),
Infolists\Components\TextEntry::make('data3')->getStateUsing(fn ($record) => $record->data3),
]),
// 更多数据行...
Components\Grid::make(3) // 数据行
->schema([
Infolists\Components\TextEntry::make('data1')->getStateUsing(fn ($record) => $record->data4),
Infolists\Components\TextEntry::make('data2')->getStateUsing(fn ($record) => $record->data5),
Infolists\Components\TextEntry::make('data3')->getStateUsing(fn ($record) => $record->data6),
]),
ViewEntry::make('progressFormatted')
->label('进度')
->view('filament.resources.user.exam-user-resource.pages.detail-v3')
])->columnSpan(1),
]),
]);

View File

@@ -283,8 +283,15 @@ class SearchBox extends NexusModel
foreach (self::$taxonomies as $name => $info) {
$relationName = "taxonomy_" . $name;
$show = "show" . $name;
if ($this->{$show}) {
$this->setRelation($relationName, $this->{$relationName}()->orWhere('mode', 0)->get());
if ($this->{$show} && isset(self::$taxonomies[$name])) {
$modelName = self::$taxonomies[$name]['model'];
$this->setRelation(
$relationName,
$modelName::query()->whereIn('mode', [$this->getKey(), 0])
->orderBy('sort_index')
->orderBy('id')
->get()
);
}
}
}
@@ -296,7 +303,7 @@ class SearchBox extends NexusModel
public function loadTags(): void
{
$this->setRelation("tags", TagRepository::listAll($this->id));
$this->setRelation("tags", TagRepository::listAll($this->getKey()));
}
public static function getDefaultSearchMode()

View File

@@ -867,6 +867,7 @@ class ExamRepository extends BaseRepository
$index['current_value'] = $currentValue;
$index['current_value_formatted'] = $currentValueFormatted;
$index['passed'] = $currentValue >= $requireValueAtomic;
$index['index_result'] = $index['passed'] ? nexus_trans($exam->getPassResultTransKey('pass')) : nexus_trans($exam->getPassResultTransKey('not_pass'));
$result[] = $index;
}
return $result;

View File

@@ -47,7 +47,7 @@ class TagRepository extends BaseRepository
public static function createBasicQuery()
{
return Tag::query()->orderBy('priority', 'desc')->orderBy('id', 'desc');
return Tag::query()->orderBy('priority', 'asc')->orderBy('id', 'asc');
}
public function renderCheckbox(int $searchBoxId, array $checked = [], $ignorePermission = false): string

View File

@@ -21,11 +21,15 @@ class UploadRepository extends BaseRepository
'name' => 'required',
];
$request->validate($rules);
$category = Category::query()->firstOrFail($request->type);
$category = Category::query()->findOrFail($request->type);
$mode = $category->mode;
$searchBox = SearchBox::query()->findOrFail($mode);
$searchBox->loadSubCategories();
$searchBox->loadTags();
$anonymous = "no";
$uploaderUsername = $user->username;
if ($request->uplver == 'yes' && user_can('beanonymous')) {
if ($request->uplver == 'yes' && Permission::canBeAnonymous()) {
$anonymous = "yes";
$uploaderUsername = "Anonymous";
}

View File

@@ -0,0 +1,46 @@
<div class="fi-ta-content relative divide-y divide-gray-200 overflow-x-auto dark:divide-white/10 dark:border-t-white/10">
<table class="fi-ta-table w-full table-auto divide-y divide-gray-200 text-start dark:divide-white/5">
<thead class="divide-y divide-gray-200 dark:divide-white/5">
<tr class="bg-gray-50 dark:bg-white/5">
<th class="fi-ta-header-cell px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6 fi-table-header-cell-id">
<span class="group flex w-full items-center gap-x-1 whitespace-nowrap justify-start">
<span class="fi-ta-header-cell-label text-sm font-semibold text-gray-950 dark:text-white">
{{ __('label.exam.index_required_label') }}
</span>
</span>
</th>
<th class="fi-ta-header-cell px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6 fi-table-header-cell-id">
<span class="group flex w-full items-center gap-x-1 whitespace-nowrap justify-start">
<span class="fi-ta-header-cell-label text-sm font-semibold text-gray-950 dark:text-white">
{{ __('label.exam.index_required_value') }}
</span>
</span>
</th>
<th class="fi-ta-header-cell px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6 fi-table-header-cell-id">
<span class="group flex w-full items-center gap-x-1 whitespace-nowrap justify-start">
<span class="fi-ta-header-cell-label text-sm font-semibold text-gray-950 dark:text-white">
{{ __('label.exam.index_current_value') }}
</span>
</span>
</th>
<th class="fi-ta-header-cell px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6 fi-table-header-cell-id">
<span class="group flex w-full items-center gap-x-1 whitespace-nowrap justify-start">
<span class="fi-ta-header-cell-label text-sm font-semibold text-gray-950 dark:text-white">
{{ __('label.exam.index_result') }}
</span>
</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 whitespace-nowrap dark:divide-white/5">
@foreach ($getState() as $index)
<tr class="dark:bg-gray-800">
<td class="fi-ta-cell p-0 first-of-type:ps-1 last-of-type:pe-1 sm:first-of-type:ps-3 sm:last-of-type:pe-3 fi-table-cell-id">{{ $index['index_formatted'] }}</td>
<td class="fi-ta-cell p-0 first-of-type:ps-1 last-of-type:pe-1 sm:first-of-type:ps-3 sm:last-of-type:pe-3 fi-table-cell-id">{{ $index['require_value_formatted'] }}</td>
<td class="fi-ta-cell p-0 first-of-type:ps-1 last-of-type:pe-1 sm:first-of-type:ps-3 sm:last-of-type:pe-3 fi-table-cell-id">{{ $index['current_value_formatted'] }}</td>
<td class="fi-ta-cell p-0 first-of-type:ps-1 last-of-type:pe-1 sm:first-of-type:ps-3 sm:last-of-type:pe-3 fi-table-cell-id">{!! $index['index_result'] !!}</td>
</tr>
@endforeach
</tbody>
</table>
</div>