exam-analysis-compact.blade.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <x-filament-panels::page>
  2. <div class="space-y-4">
  3. @if($loading)
  4. <x-exam-analysis.loading message="正在分析试卷数据..." />
  5. @else
  6. <!-- 页面头部 -->
  7. <x-exam-analysis.header :recordData="$recordData" title="📊 OCR试卷分析" />
  8. <!-- 快速统计 -->
  9. <x-exam-analysis.quick-stats :recordData="$recordData" />
  10. <!-- ChatGPT智能识别 -->
  11. <div class="bg-white rounded-lg shadow-sm border border-gray-200">
  12. <div class="p-4 border-b border-gray-200">
  13. <div class="flex items-center justify-between">
  14. <h2 class="text-base font-semibold text-gray-900">🤖 ChatGPT智能识别</h2>
  15. <div class="flex items-center gap-2">
  16. <input type="checkbox" wire:model="useChatGPT" id="useChatGPT-compact" class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
  17. <label for="useChatGPT-compact" class="text-sm text-gray-700">启用</label>
  18. </div>
  19. </div>
  20. </div>
  21. @if($useChatGPT)
  22. <div class="p-4">
  23. <div class="space-y-3">
  24. <div>
  25. <label class="block text-sm font-medium text-gray-700 mb-1">
  26. 试卷图片URL <span class="text-red-500">*</span>
  27. </label>
  28. <input
  29. type="url"
  30. wire:model="imageUrl"
  31. placeholder="请输入试卷图片URL"
  32. class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
  33. />
  34. </div>
  35. @if(!empty($imageUrl))
  36. <div class="flex items-center gap-2">
  37. <button
  38. wire:click="analyzeWithChatGPT"
  39. wire:loading.attr="disabled"
  40. class="px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1"
  41. >
  42. @if($isAnalyzing)
  43. <svg class="animate-spin h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  44. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  45. <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
  46. </svg>
  47. 分析中...
  48. @else
  49. <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  50. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"></path>
  51. </svg>
  52. 智能识别
  53. @endif
  54. </button>
  55. <button
  56. wire:click="resetChatGPTForm"
  57. class="px-3 py-2 bg-gray-200 text-gray-700 text-sm font-medium rounded-md hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-400"
  58. >
  59. 重置
  60. </button>
  61. </div>
  62. <!-- 图片预览 -->
  63. <div class="mt-2">
  64. <div class="border border-gray-300 rounded-md overflow-hidden max-w-sm">
  65. <img src="{{ $imageUrl }}" alt="试卷图片" class="w-full h-auto" onerror="this.style.display='none'">
  66. </div>
  67. </div>
  68. @endif
  69. <!-- ChatGPT分析结果 -->
  70. @if(!empty($chatGPTResult))
  71. <div class="mt-3 p-3 bg-green-50 border border-green-200 rounded-md">
  72. <h3 class="text-sm font-semibold text-green-900 mb-1">✅ 分析完成</h3>
  73. <div class="text-xs text-green-800">
  74. <p>已分析 {{ count($chatGPTResult['questions'] ?? []) }} 道题目</p>
  75. <p>得分:{{ $chatGPTResult['score_obtained'] ?? 0 }}/{{ $chatGPTResult['total_score'] ?? 0 }}</p>
  76. <p>掌握度:{{ number_format(($chatGPTResult['summary']['overall_mastery'] ?? 0) * 100, 1) }}%</p>
  77. </div>
  78. </div>
  79. @endif
  80. </div>
  81. </div>
  82. @else
  83. <div class="p-4 text-center text-gray-500">
  84. <p class="text-sm">启用ChatGPT直接从图片识别答案</p>
  85. </div>
  86. @endif
  87. </div>
  88. <!-- 学习分析概览 -->
  89. <x-exam-analysis.learning-analysis :analysisData="$analysisData" />
  90. <!-- 题目详情分析 -->
  91. <x-exam-analysis.question-details :questions="$recordData['questions'] ?? []" />
  92. <!-- 学习建议 -->
  93. @if(isset($analysisData['recommendations']))
  94. <x-exam-analysis.recommendations :recommendations="$analysisData['recommendations']" />
  95. @endif
  96. @endif
  97. </div>
  98. </x-filament-panels::page>