question-management-simple.blade.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <x-filament-panels::page>
  2. <!-- 数学公式渲染组件 -->
  3. <x-math-render />
  4. <div class="space-y-6">
  5. @php
  6. $questionsData = $this->questions;
  7. $metaData = $this->meta;
  8. $statisticsData = $this->statistics;
  9. @endphp
  10. <div class="flex justify-end">
  11. <a
  12. href="{{ url('/admin/question-generation') }}"
  13. class="inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors"
  14. >
  15. <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  16. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
  17. </svg>
  18. 生成题目
  19. </a>
  20. </div>
  21. <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
  22. <div class="bg-white p-4 rounded-lg border">
  23. <div class="text-sm text-gray-500">题目总数</div>
  24. <div class="text-2xl font-bold text-primary-600">{{ $statisticsData['total'] ?? 0 }}</div>
  25. </div>
  26. <div class="bg-white p-4 rounded-lg border">
  27. <div class="text-sm text-gray-500">基础难度 (≤0.4)</div>
  28. <div class="text-2xl font-bold text-green-600">
  29. @php
  30. $basicCount = 0;
  31. foreach ($statisticsData['by_difficulty'] ?? [] as $key => $value) {
  32. if ((float)$key <= 0.4) {
  33. $basicCount += $value;
  34. }
  35. }
  36. echo $basicCount;
  37. @endphp
  38. </div>
  39. </div>
  40. <div class="bg-white p-4 rounded-lg border">
  41. <div class="text-sm text-gray-500">中等难度 (0.4-0.7)</div>
  42. <div class="text-2xl font-bold text-yellow-600">
  43. @php
  44. $mediumCount = 0;
  45. foreach ($statisticsData['by_difficulty'] ?? [] as $key => $value) {
  46. if ((float)$key > 0.4 && (float)$key <= 0.7) {
  47. $mediumCount += $value;
  48. }
  49. }
  50. echo $mediumCount;
  51. @endphp
  52. </div>
  53. </div>
  54. <div class="bg-white p-4 rounded-lg border">
  55. <div class="text-sm text-gray-500">拔高难度 (>0.7)</div>
  56. <div class="text-2xl font-bold text-red-600">
  57. @php
  58. $advancedCount = 0;
  59. foreach ($statisticsData['by_difficulty'] ?? [] as $key => $value) {
  60. if ((float)$key > 0.7) {
  61. $advancedCount += $value;
  62. }
  63. }
  64. echo $advancedCount;
  65. @endphp
  66. </div>
  67. </div>
  68. </div>
  69. <div class="bg-white p-4 rounded-lg border">
  70. <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
  71. <div>
  72. <label class="block text-sm font-medium text-gray-700 mb-2">搜索题目</label>
  73. <input type="text" wire:model.live.debounce.300ms="search" placeholder="输入关键词" class="w-full border rounded p-2">
  74. </div>
  75. <div>
  76. <label class="block text-sm font-medium text-gray-700 mb-2">知识点筛选</label>
  77. <input type="text" wire:model.live="selectedKpCode" placeholder="KP1001" class="w-full border rounded p-2">
  78. </div>
  79. <div>
  80. <label class="block text-sm font-medium text-gray-700 mb-2">难度筛选</label>
  81. <input type="text" wire:model.live="selectedDifficulty" placeholder="0.3/0.6/0.85" class="w-full border rounded p-2">
  82. </div>
  83. <div>
  84. <label class="block text-sm font-medium text-gray-700 mb-2">每页显示</label>
  85. <input type="number" wire:model.live="perPage" min="10" max="100" step="5" class="w-full border rounded p-2">
  86. </div>
  87. </div>
  88. </div>
  89. <div class="bg-white rounded-lg border overflow-hidden">
  90. <table class="min-w-full divide-y divide-gray-200">
  91. <thead class="bg-gray-50">
  92. <tr>
  93. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">题目编号</th>
  94. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">知识点</th>
  95. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">题干</th>
  96. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">难度</th>
  97. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">操作</th>
  98. </tr>
  99. </thead>
  100. <tbody class="bg-white divide-y divide-gray-200">
  101. @forelse($questionsData as $question)
  102. <tr class="hover:bg-gray-50">
  103. <td class="px-6 py-4 whitespace-nowrap">{{ $question['question_code'] ?? 'N/A' }}</td>
  104. <td class="px-6 py-4 whitespace-nowrap">{{ $question['kp_code'] ?? 'N/A' }}</td>
  105. <td class="px-6 py-4" style="word-wrap: break-word; white-space: normal; line-height: 1.8; max-width: 400px;">
  106. <span class="text-sm">
  107. @math($question['stem'] ?? 'N/A')
  108. </span>
  109. </td>
  110. <td class="px-6 py-4">
  111. @php
  112. $difficulty = $question['difficulty'] ?? null;
  113. $label = match (true) {
  114. !$difficulty => 'N/A',
  115. (float)$difficulty <= 0.4 => '基础',
  116. (float)$difficulty <= 0.7 => '中等',
  117. default => '拔高',
  118. };
  119. @endphp
  120. {{ $label }}
  121. @if(app()->environment('local'))
  122. <span class="text-xs text-gray-400">({{ $difficulty }})</span>
  123. @endif
  124. </td>
  125. <td class="px-6 py-4 whitespace-nowrap">
  126. <button wire:click="deleteQuestion('{{ $question['question_code'] }}')" class="text-red-600 hover:underline">删除</button>
  127. </td>
  128. </tr>
  129. @empty
  130. <tr><td colspan="5" class="px-6 py-12 text-center">暂无数据</td></tr>
  131. @endforelse
  132. </tbody>
  133. </table>
  134. @if(!empty($metaData) && ($metaData['total'] ?? 0) > 0)
  135. <div class="px-4 py-3 border-t border-gray-200 flex items-center justify-between">
  136. <div class="text-sm text-gray-700">共 {{ $metaData['total'] ?? 0 }} 条记录</div>
  137. <div class="flex items-center gap-2">
  138. <button wire:click="previousPage" @disabled($currentPage <= 1) class="px-3 py-1 border rounded">上一页</button>
  139. @foreach($this->getPages() as $page)
  140. <button wire:click="gotoPage({{ $page }})" class="px-3 py-1 border rounded {{ $page === $currentPage ? 'bg-blue-50 text-blue-700' : '' }}">{{ $page }}</button>
  141. @endforeach
  142. <button wire:click="nextPage" @disabled($currentPage >= ($metaData['total_pages'] ?? 1)) class="px-3 py-1 border rounded">下一页</button>
  143. </div>
  144. </div>
  145. @endif
  146. </div>
  147. </div>
  148. </x-filament-panels::page>