Spaces:
Runtime error

File size: 3,355 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
import React from 'react'
import { Flag, ChevronLeft, ChevronRight } from 'lucide-react'

export default function QuestionPanel({
  question,
  questionNumber,
  totalQuestions,
  selectedAnswer,
  onAnswerSelect,
  onMarkForReview,
  isMarked,
  onPrevious,
  onNext,
  canGoPrevious,
  canGoNext,
  contrast
}) {
  const progressPercent = (questionNumber / totalQuestions) * 100

  return (
    <div className="question-panel">
      {/* Progress Bar */}
      <div className="mb-6">
        <div className="flex justify-between items-center mb-2">
          <h2 className="text-lg font-semibold">Question {questionNumber} of {totalQuestions}</h2>
          <button
            onClick={onMarkForReview}
            className={`flex items-center gap-2 px-3 py-2 rounded-lg transition-colors ${
              isMarked
                ? 'bg-yellow-100 text-yellow-700 hover:bg-yellow-200'
                : 'bg-gray-100 text-gray-700 hover:bg-gray-200'
            }`}
          >
            <Flag className="w-4 h-4" />
            {isMarked ? 'Marked' : 'Mark for Review'}
          </button>
        </div>
        <div className="progress-bar">
          <div
            className="progress-fill"
            style={{ width: `${progressPercent}%` }}
          />
        </div>
      </div>

      {/* Question Text */}
      <div className="question-text">
        {question.text}
      </div>

      {/* Image if present */}
      {question.image && (
        <div className="image-container">
          <img
            src={question.image}
            alt="Question Image"
            style={{ filter: `contrast(${contrast}%)` }}
          />
          <p className="text-xs text-gray-500 mt-2">
            Note: You can adjust image contrast in the settings panel
          </p>
        </div>
      )}

      {/* Answer Options */}
      <div className="space-y-2 mb-8">
        {question.options.map((option, idx) => (
          <button
            key={idx}
            onClick={() => onAnswerSelect(option.label)}
            className={`answer-option w-full text-left ${
              selectedAnswer === option.label ? 'selected' : ''
            }`}
          >
            <div className="flex items-start gap-3">
              <div className="flex-shrink-0 w-6 h-6 flex items-center justify-center border-2 border-current rounded">
                {selectedAnswer === option.label && (
                  <div className="w-3 h-3 bg-current rounded-sm" />
                )}
              </div>
              <div className="flex-1">
                <div className="font-semibold">{option.label}</div>
                <div className="text-gray-600">{option.text}</div>
              </div>
            </div>
          </button>
        ))}
      </div>

      {/* Navigation Buttons */}
      <div className="navigation-buttons">
        <button
          onClick={onPrevious}
          disabled={!canGoPrevious}
          className="btn btn-secondary flex items-center gap-2"
        >
          <ChevronLeft className="w-4 h-4" />
          Previous
        </button>
        <button
          onClick={onNext}
          disabled={!canGoNext}
          className="btn btn-primary flex items-center gap-2 ml-auto"
        >
          Next
          <ChevronRight className="w-4 h-4" />
        </button>
      </div>
    </div>
  )
}