Spaces:
Runtime error

File size: 4,124 Bytes
6fe52ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import React from 'react'
import { Sliders } from 'lucide-react'

export default function SidebarPanel({
  totalQuestions,
  currentQuestionIndex,
  answers,
  markedForReview,
  onGoToQuestion,
  answeredCount,
  markedCount,
  contrast,
  onContrastChange
}) {
  const getQuestionStatus = (idx) => {
    if (markedForReview.has(idx)) return 'marked'
    if (answers.hasOwnProperty(idx)) return 'answered'
    return 'not-answered'
  }

  const unansweredCount = totalQuestions - answeredCount

  return (
    <div className="sidebar-panel">
      {/* Summary Stats */}
      <div className="mb-6">
        <h3 className="text-sm font-semibold text-gray-700 mb-3 uppercase">Exam Status</h3>
        <div className="space-y-2 text-sm">
          <div className="flex justify-between">
            <span className="text-gray-600">Answered:</span>
            <span className="font-semibold text-green-600">{answeredCount}</span>
          </div>
          <div className="flex justify-between">
            <span className="text-gray-600">Not Answered:</span>
            <span className="font-semibold text-red-600">{unansweredCount}</span>
          </div>
          <div className="flex justify-between">
            <span className="text-gray-600">Marked:</span>
            <span className="font-semibold text-amber-600">{markedCount}</span>
          </div>
        </div>
        <div className="mt-3 pt-3 border-t border-gray-200">
          <div className="w-full bg-gray-200 rounded-full h-2">
            <div
              className="bg-green-500 h-2 rounded-full transition-all"
              style={{ width: `${(answeredCount / totalQuestions) * 100}%` }}
            />
          </div>
        </div>
      </div>

      {/* Image Settings */}
      <div className="settings-panel">
        <h3 className="settings-title flex items-center gap-2">
          <Sliders className="w-4 h-4" />
          Image Contrast
        </h3>
        <div className="setting-item">
          <div className="setting-label">Adjust image clarity</div>
          <input
            type="range"
            min="50"
            max="150"
            value={contrast}
            onChange={(e) => onContrastChange(Number(e.target.value))}
            className="contrast-slider w-full"
          />
          <div className="text-xs text-gray-500 mt-1">{contrast}%</div>
        </div>
      </div>

      {/* Question Review */}
      <div className="mt-4">
        <h3 className="settings-title">Question Review</h3>
        <div className="question-review">
          {Array.from({ length: totalQuestions }).map((_, idx) => {
            const status = getQuestionStatus(idx)
            return (
              <button
                key={idx}
                onClick={() => onGoToQuestion(idx)}
                className={`review-item w-full text-left ${
                  idx === currentQuestionIndex ? 'bg-blue-50 font-semibold' : ''
                }`}
              >
                <span
                  className={`status-indicator ${
                    status === 'answered'
                      ? 'answered'
                      : status === 'marked'
                      ? 'marked'
                      : 'not-answered'
                  }`}
                />
                Q{idx + 1}
                <span className="text-xs ml-1">
                  {status === 'answered' && '✓'}
                  {status === 'marked' && '⚑'}
                </span>
              </button>
            )
          })}
        </div>
      </div>

      {/* Help Text */}
      <div className="mt-6 pt-4 border-t border-gray-200 text-xs text-gray-600">
        <p className="mb-2">
          <span className="inline-block w-3 h-3 rounded-full bg-green-500 mr-2"></span>
          Answered
        </p>
        <p className="mb-2">
          <span className="inline-block w-3 h-3 rounded-full bg-red-500 mr-2"></span>
          Not Answered
        </p>
        <p>
          <span className="inline-block w-3 h-3 rounded-full bg-amber-500 mr-2"></span>
          Marked
        </p>
      </div>
    </div>
  )
}