Rohan Kumar commited on
Commit
7a1de5c
·
verified ·
1 Parent(s): ae6a5de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -20
app.py CHANGED
@@ -413,38 +413,40 @@ This takes about **3–5 minutes**. Thank you for contributing! 🙏
413
  )
414
 
415
  def rate(rating_val: str, name: str, items: list, idx: int):
 
416
  save_annotation(name, items[idx], rating_val)
417
 
 
418
  next_idx = idx + 1
419
  total = len(items)
420
-
421
- print(next_idx)
422
- print(total)
423
  if next_idx >= total:
424
- print("DONE SCREEN TRIGGERED", name)
425
- # FIX 1: Flush the text to the left margin to prevent Markdown code-blocking
426
- completion_text = "Thank you!"
427
-
428
  return (
429
- gr.update(visible=False), # col_welcome
430
- gr.update(visible=False), # col_rating
431
- gr.update(visible=True), # col_done
432
- name, # s_name
433
- items, # s_items
434
- next_idx, # s_idx
435
- gr.update(value=""), # q_html
436
- gr.update(value=completion_text), # done_md (FIX 2: Text will now display correctly)
437
  )
438
 
 
439
  return (
440
- gr.update(visible=False),
441
- gr.update(visible=True),
442
- gr.update(visible=False),
443
  name,
444
  items,
445
  next_idx,
446
- gr.update(value=render_question(items[next_idx], next_idx, total)),
447
- gr.update(value=""),
448
  )
449
 
450
  def restart():
 
413
  )
414
 
415
  def rate(rating_val: str, name: str, items: list, idx: int):
416
+ # 1. Save the annotation
417
  save_annotation(name, items[idx], rating_val)
418
 
419
+ # 2. Advance index
420
  next_idx = idx + 1
421
  total = len(items)
422
+
423
+ # 3. Check if done
 
424
  if next_idx >= total:
425
+ # Using standard string formatting to avoid ALL markdown indentation bugs
426
+ completion_text = f"## 🎉 All done, {name}!\n\nYou've completed **{total} annotations**.\nYour responses have been saved. Thank you for your contribution!\n\n*Feel free to refresh the page to annotate another batch.*"
427
+
428
+ # In modern Gradio, you can return gr.Column() directly instead of gr.update()
429
  return (
430
+ gr.Column(visible=False), # col_welcome
431
+ gr.Column(visible=False), # col_rating
432
+ gr.Column(visible=True), # col_done -> explicitly make this visible
433
+ name, # s_name
434
+ items, # s_items
435
+ next_idx, # s_idx
436
+ "", # q_html (just return string)
437
+ completion_text, # done_md (just return string)
438
  )
439
 
440
+ # 4. If not done, show next question
441
  return (
442
+ gr.Column(visible=False),
443
+ gr.Column(visible=True),
444
+ gr.Column(visible=False),
445
  name,
446
  items,
447
  next_idx,
448
+ render_question(items[next_idx], next_idx, total),
449
+ "",
450
  )
451
 
452
  def restart():