question-management.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <x-filament-panels::page>
  2. <div class="space-y-6">
  3. @php
  4. $questionsData = $this->questions;
  5. $metaData = $this->meta;
  6. $statisticsData = $this->statistics;
  7. @endphp
  8. <div class="flex justify-end">
  9. <button
  10. type="button"
  11. wire:click="$dispatch('ai-generate')"
  12. class="filament-button filament-button-size-sm filament-button-color-success filament-button-icon-start inline-flex items-center justify-center px-4 py-2 text-sm font-medium transition-colors border border-transparent rounded-lg focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
  13. >
  14. <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  15. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
  16. </svg>
  17. 生成题目
  18. </button>
  19. </div>
  20. <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
  21. <div class="bg-white p-4 rounded-lg border">
  22. <div class="text-sm text-gray-500">题目总数</div>
  23. <div class="text-2xl font-bold text-primary-600">{{ $statisticsData['total'] ?? 0 }}</div>
  24. </div>
  25. <div class="bg-white p-4 rounded-lg border">
  26. <div class="text-sm text-gray-500">基础难度</div>
  27. <div class="text-2xl font-bold text-green-600">{{ $statisticsData['by_difficulty']['0.3'] ?? 0 }}</div>
  28. </div>
  29. <div class="bg-white p-4 rounded-lg border">
  30. <div class="text-sm text-gray-500">中等难度</div>
  31. <div class="text-2xl font-bold text-yellow-600">{{ $statisticsData['by_difficulty']['0.6'] ?? 0 }}</div>
  32. </div>
  33. <div class="bg-white p-4 rounded-lg border">
  34. <div class="text-sm text-gray-500">拔高难度</div>
  35. <div class="text-2xl font-bold text-red-600">{{ $statisticsData['by_difficulty']['0.85'] ?? 0 }}</div>
  36. </div>
  37. </div>
  38. <div class="bg-white p-4 rounded-lg border">
  39. <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
  40. <div>
  41. <label class="block text-sm font-medium text-gray-700 mb-2">搜索题目</label>
  42. <input type="text" wire:model.live.debounce.300ms="search" placeholder="输入关键词" class="w-full border rounded p-2">
  43. </div>
  44. <div>
  45. <label class="block text-sm font-medium text-gray-700 mb-2">知识点筛选</label>
  46. <input type="text" wire:model.live="selectedKpCode" placeholder="KP1001" class="w-full border rounded p-2">
  47. </div>
  48. <div>
  49. <label class="block text-sm font-medium text-gray-700 mb-2">难度筛选</label>
  50. <input type="text" wire:model.live="selectedDifficulty" placeholder="0.3/0.6/0.85" class="w-full border rounded p-2">
  51. </div>
  52. <div>
  53. <label class="block text-sm font-medium text-gray-700 mb-2">每页显示</label>
  54. <input type="number" wire:model.live="perPage" min="10" max="100" step="5" class="w-full border rounded p-2">
  55. </div>
  56. </div>
  57. </div>
  58. <div class="bg-white rounded-lg border overflow-hidden">
  59. <table class="min-w-full divide-y divide-gray-200">
  60. <thead class="bg-gray-50">
  61. <tr>
  62. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">题目编号</th>
  63. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">知识点</th>
  64. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">题干</th>
  65. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">难度</th>
  66. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">操作</th>
  67. </tr>
  68. </thead>
  69. <tbody class="bg-white divide-y divide-gray-200">
  70. @forelse($questionsData as $question)
  71. <tr class="hover:bg-gray-50">
  72. <td class="px-6 py-4 whitespace-nowrap">{{ $question['question_code'] ?? 'N/A' }}</td>
  73. <td class="px-6 py-4 whitespace-nowrap">{{ $question['kp_code'] ?? 'N/A' }}</td>
  74. <td class="px-6 py-4">{{ \Illuminate\Support\Str::limit($question['stem'] ?? 'N/A', 50) }}</td>
  75. <td class="px-6 py-4">
  76. @php
  77. $difficulty = $question['difficulty'] ?? null;
  78. $label = match (true) {
  79. !$difficulty => 'N/A',
  80. (float)$difficulty <= 0.4 => '基础',
  81. (float)$difficulty <= 0.7 => '中等',
  82. default => '拔高',
  83. };
  84. @endphp
  85. {{ $label }}
  86. </td>
  87. <td class="px-6 py-4 whitespace-nowrap">
  88. <button wire:click="deleteQuestion('{{ $question['question_code'] }}')" class="text-red-600 hover:underline">删除</button>
  89. </td>
  90. </tr>
  91. @empty
  92. <tr><td colspan="5" class="px-6 py-12 text-center">暂无数据</td></tr>
  93. @endforelse
  94. </tbody>
  95. </table>
  96. @if(!empty($metaData) && ($metaData['total'] ?? 0) > 0)
  97. <div class="px-4 py-3 border-t border-gray-200 flex items-center justify-between">
  98. <div class="text-sm text-gray-700">共 {{ $metaData['total'] ?? 0 }} 条记录</div>
  99. <div class="flex items-center gap-2">
  100. <button wire:click="previousPage" @disabled($currentPage <= 1) class="px-3 py-1 border rounded">上一页</button>
  101. @foreach($this->getPages() as $page)
  102. <button wire:click="gotoPage({{ $page }})" class="px-3 py-1 border rounded {{ $page === $currentPage ? 'bg-blue-50 text-blue-700' : '' }}">{{ $page }}</button>
  103. @endforeach
  104. <button wire:click="nextPage" @disabled($currentPage >= ($metaData['total_pages'] ?? 1)) class="px-3 py-1 border rounded">下一页</button>
  105. </div>
  106. </div>
  107. @endif
  108. </div>
  109. @if($showGenerateModal)
  110. <div class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
  111. <div class="bg-white rounded-lg p-6 max-w-2xl w-full">
  112. <h3 class="text-lg font-semibold mb-4">生成题目</h3>
  113. <div class="space-y-4">
  114. <div>
  115. <label class="block text-sm font-medium mb-2">知识点 <span class="text-red-500">*</span></label>
  116. <select wire:model.live="generateKpCode" class="w-full border rounded p-2">
  117. <option value="">选择知识点</option>
  118. @foreach($this->knowledgePointOptions as $code => $name)
  119. <option value="{{ $code }}">{{ $code }} - {{ $name }}</option>
  120. @endforeach
  121. </select>
  122. </div>
  123. @if(!empty($this->skillsOptions))
  124. <div>
  125. <div class="flex items-center justify-between mb-2">
  126. <label class="block text-sm font-medium">选择技能 <span class="text-red-500">*</span></label>
  127. <button type="button" class="text-sm text-blue-600 hover:underline" wire:click="toggleAllSkills">
  128. {{ count($selectedSkills) === count($this->skillsOptions) ? '取消全选' : '全选' }}
  129. </button>
  130. </div>
  131. <div class="max-h-48 overflow-y-auto border rounded p-3 space-y-2">
  132. @foreach($this->skillsOptions as $skill)
  133. <label class="flex items-center space-x-2">
  134. <input type="checkbox" value="{{ $skill['code'] }}" wire:model="selectedSkills" class="rounded border-gray-300">
  135. <span class="text-sm">
  136. <span class="font-medium">{{ $skill['code'] }}</span>
  137. <span class="text-gray-600 ml-2">{{ $skill['name'] }}</span>
  138. <span class="text-xs text-gray-400 ml-2">(权重: {{ $skill['weight'] ?? 1 }})</span>
  139. </span>
  140. </label>
  141. @endforeach
  142. </div>
  143. </div>
  144. @else
  145. <div class="text-sm text-gray-500 italic">
  146. 请先选择知识点以加载技能列表
  147. </div>
  148. @endif
  149. <div>
  150. <label class="block text-sm font-medium mb-2">题目数量</label>
  151. <input type="number" wire:model="questionCount" min="1" max="500" class="w-full border rounded p-2">
  152. </div>
  153. </div>
  154. <div class="flex justify-end gap-3 mt-6">
  155. <button type="button" wire:click="closeGenerateModal" class="px-4 py-2 border rounded">取消</button>
  156. <button type="button" wire:click="executeGenerate" class="px-4 py-2 bg-blue-600 text-white rounded">开始生成</button>
  157. </div>
  158. </div>
  159. </div>
  160. @endif
  161. <script>
  162. document.addEventListener('livewire:init', () => {
  163. Livewire.on('ai-generate', () => {
  164. @this.call('openGenerateModal');
  165. });
  166. });
  167. </script>
  168. </div>
  169. </x-filament-panels::page>