capradeepgujaran commited on
Commit
12a21f4
·
verified ·
1 Parent(s): 5788a19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -53,7 +53,7 @@ class QuizApp:
53
 
54
  def calculate_score(self, answers):
55
  try:
56
- answers = json.loads(answers)
57
  total = len(self.current_questions)
58
  correct = 0
59
 
@@ -189,16 +189,20 @@ def create_quiz_app():
189
  ### Assessment Instructions:
190
  1. Review each question carefully
191
  2. For each question, you may select one or more correct options
192
- 3. Enter your answers as arrays of indices (e.g., [0, 2] for first and third options)
 
 
 
 
 
 
 
193
  4. Click 'Submit Assessment' when you're ready
194
  5. You need 80% or higher to earn your certificate
195
  """)
196
 
197
  questions_display = gr.JSON(label="Assessment Questions")
198
- answers_input = gr.JSON(
199
- label="Your Answers",
200
- placeholder="Enter answers as arrays of indices, e.g., [[0], [1, 2], [3]]"
201
- )
202
  submit_btn = gr.Button("Submit Assessment", variant="primary")
203
  score_display = gr.Number(label="Your Score")
204
 
 
53
 
54
  def calculate_score(self, answers):
55
  try:
56
+ answers = json.loads(answers) if isinstance(answers, str) else answers
57
  total = len(self.current_questions)
58
  correct = 0
59
 
 
189
  ### Assessment Instructions:
190
  1. Review each question carefully
191
  2. For each question, you may select one or more correct options
192
+ 3. Enter your answers in the following format:
193
+ ```
194
+ [
195
+ [0], // First question: selected first option
196
+ [1, 2], // Second question: selected second and third options
197
+ [3] // Third question: selected fourth option
198
+ ]
199
+ ```
200
  4. Click 'Submit Assessment' when you're ready
201
  5. You need 80% or higher to earn your certificate
202
  """)
203
 
204
  questions_display = gr.JSON(label="Assessment Questions")
205
+ answers_input = gr.JSON(label="Your Answers")
 
 
 
206
  submit_btn = gr.Button("Submit Assessment", variant="primary")
207
  score_display = gr.Number(label="Your Score")
208