grading-panel.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <div>
  2. <div class="bg-white shadow-md rounded-lg p-6">
  3. <h2 class="text-xl font-semibold text-gray-900 mb-6">试卷评分</h2>
  4. {{-- 试卷基本信息 --}}
  5. <div class="bg-gray-50 rounded-lg p-4 mb-6">
  6. <div class="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
  7. <div>
  8. <span class="text-gray-600">试卷名称:</span>
  9. <span class="font-medium text-gray-900">{{ $paperName ?? '未知' }}</span>
  10. </div>
  11. <div>
  12. <span class="text-gray-600">班级:</span>
  13. <span class="font-medium text-gray-900">{{ $paperClass ?? '未知' }}</span>
  14. </div>
  15. <div>
  16. <span class="text-gray-600">学生:</span>
  17. <span class="font-medium text-gray-900">{{ $paperStudent ?? '未知' }}</span>
  18. </div>
  19. <div>
  20. <span class="text-gray-600">考试日期:</span>
  21. <span class="font-medium text-gray-900">{{ $paperDate ?? '未知' }}</span>
  22. </div>
  23. </div>
  24. </div>
  25. {{-- 评分列表 --}}
  26. @if(!empty($questions))
  27. <div class="space-y-4">
  28. @foreach($questions as $index => $question)
  29. <div class="border border-gray-200 rounded-lg p-4 hover:border-blue-300 transition-colors">
  30. <div class="flex items-start justify-between mb-3">
  31. <div class="flex items-center">
  32. <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800 mr-3">
  33. 第 {{ $question['question_number'] ?? ($index + 1) }} 题
  34. </span>
  35. <span class="text-sm text-gray-600">
  36. {{ ($question['question_type'] ?? '未知') }}
  37. </span>
  38. <span class="ml-2 text-sm font-medium text-gray-700">
  39. ({{ $question['score'] ?? 0 }} 分)
  40. </span>
  41. </div>
  42. </div>
  43. {{-- 题目内容 --}}
  44. <div class="mb-4">
  45. <p class="text-gray-800">{{ $question['content'] ?? $question['question_text'] ?? '' }}</p>
  46. {{-- 选择题选项 --}}
  47. @if(($question['question_type'] ?? '') === 'choice' && !empty($question['options']))
  48. <div class="mt-3 grid grid-cols-1 md:grid-cols-2 gap-2">
  49. @foreach($question['options'] as $option)
  50. <div class="text-sm text-gray-700 bg-gray-50 px-3 py-2 rounded">
  51. <span class="font-medium">{{ $option['key'] ?? '' }}.</span>
  52. <span class="ml-1">{{ $option['value'] ?? '' }}</span>
  53. </div>
  54. @endforeach
  55. </div>
  56. @endif
  57. </div>
  58. {{-- 参考答案 --}}
  59. <div class="mb-4 p-3 bg-green-50 border border-green-200 rounded-md">
  60. <div class="flex items-start">
  61. <svg class="h-5 w-5 text-green-500 mr-2 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  62. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
  63. </svg>
  64. <div>
  65. <p class="text-sm font-medium text-green-800">参考答案</p>
  66. @if(!empty($question['answer']))
  67. <p class="text-sm text-green-700 mt-1">{{ $question['answer'] }}</p>
  68. @else
  69. <p class="text-sm text-yellow-700 mt-1">⚠️ 未找到参考答案</p>
  70. @endif
  71. </div>
  72. </div>
  73. </div>
  74. {{-- 评分操作区 --}}
  75. <div class="border-t pt-4">
  76. @if($question['question_type'] === 'choice')
  77. {{-- 选择题评分 --}}
  78. <div class="flex items-center space-x-4">
  79. <span class="text-sm font-medium text-gray-700">评分:</span>
  80. <div class="flex space-x-2">
  81. <button
  82. type="button"
  83. wire:click="setChoiceAnswer({{ $index }}, true)"
  84. class="inline-flex items-center px-4 py-2 border rounded-md text-sm font-medium transition-colors
  85. {{ ($gradingData[$index]['is_correct'] ?? null) === true
  86. ? 'border-green-500 bg-green-500 text-white'
  87. : 'border-gray-300 bg-white text-gray-700 hover:bg-green-50 hover:border-green-300' }}">
  88. <svg class="h-4 w-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  89. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
  90. </svg>
  91. 正确 (✓)
  92. </button>
  93. <button
  94. type="button"
  95. wire:click="setChoiceAnswer({{ $index }}, false)"
  96. class="inline-flex items-center px-4 py-2 border rounded-md text-sm font-medium transition-colors
  97. {{ ($gradingData[$index]['is_correct'] ?? null) === false
  98. ? 'border-red-500 bg-red-500 text-white'
  99. : 'border-gray-300 bg-white text-gray-700 hover:bg-red-50 hover:border-red-300' }}">
  100. <svg class="h-4 w-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  101. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
  102. </svg>
  103. 错误 (✗)
  104. </button>
  105. </div>
  106. @if(($gradingData[$index]['is_correct'] ?? null) !== null)
  107. <span class="text-sm text-gray-600">
  108. 当前:{{ ($gradingData[$index]['is_correct'] ?? false) ? '正确' : '错误' }}
  109. ({{ ($gradingData[$index]['is_correct'] ?? false) ? ($question['score'] ?? 0) : 0 }} 分)
  110. </span>
  111. @endif
  112. </div>
  113. @else
  114. {{-- 填空题/解答题评分 --}}
  115. <div class="flex items-center space-x-4">
  116. <span class="text-sm font-medium text-gray-700">得分:</span>
  117. <div class="flex items-center space-x-2">
  118. <input
  119. type="number"
  120. wire:model.live="gradingData.{{ $index }}.score"
  121. placeholder="0 - {{ $question['score'] ?? 0 }}"
  122. min="0"
  123. max="{{ $question['score'] ?? 0 }}"
  124. step="0.5"
  125. class="w-24 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
  126. <span class="text-sm text-gray-600">/ {{ $question['score'] ?? 0 }} 分</span>
  127. </div>
  128. @if(($gradingData[$index]['score'] ?? null) !== null)
  129. @php
  130. $score = $gradingData[$index]['score'] ?? 0;
  131. $maxScore = $question['score'] ?? 0;
  132. $isCorrect = $score >= $maxScore;
  133. @endphp
  134. <span class="text-sm {{ $isCorrect ? 'text-green-600' : 'text-yellow-600' }}">
  135. ({{ $isCorrect ? '完全正确' : '部分得分' }}:{{ number_format(($score / $maxScore) * 100, 1) }}%)
  136. </span>
  137. @endif
  138. </div>
  139. @endif
  140. </div>
  141. </div>
  142. @endforeach
  143. </div>
  144. {{-- 提交按钮 --}}
  145. <div class="mt-6 flex justify-end space-x-3">
  146. <button type="button" wire:click="resetGrading" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition-colors">
  147. 重置评分
  148. </button>
  149. <button type="submit" wire:click="submitGrading" class="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed">
  150. 提交评分
  151. </button>
  152. </div>
  153. @else
  154. <div class="text-center py-12">
  155. <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  156. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
  157. </svg>
  158. <p class="mt-4 text-sm text-gray-600">暂无题目数据</p>
  159. </div>
  160. @endif
  161. </div>
  162. </div>