Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,33 +45,24 @@ def _check_rate_limit(key: str) -> bool:
|
|
| 45 |
# Check both root and passages/ subfolder so it works regardless of where files are uploaded
|
| 46 |
PASSAGE_DIR = "passages"
|
| 47 |
|
| 48 |
-
def
|
| 49 |
-
"""Return True if the student's class string indicates Class 5 (e.g. '5', '5A', '5B', '5a')."""
|
| 50 |
-
return str(klass).strip().startswith("5")
|
| 51 |
-
|
| 52 |
-
def load_passage(n: int, klass: str = "") -> str | None:
|
| 53 |
-
if is_class5(klass):
|
| 54 |
-
# Class 5 uses separate passage files: pssgs1class5.txt, pssgs2class5.txt, ...
|
| 55 |
-
fname = f"pssg{n}class5.txt"
|
| 56 |
-
else:
|
| 57 |
-
fname = f"pssg{n}.txt"
|
| 58 |
candidates = [
|
| 59 |
-
|
| 60 |
-
os.path.join(PASSAGE_DIR,
|
| 61 |
]
|
| 62 |
for path in candidates:
|
| 63 |
if os.path.exists(path):
|
| 64 |
with open(path, "r", encoding="utf-8") as f:
|
| 65 |
return f.read().strip()
|
| 66 |
-
log.info(f"Passage file not found in root or passages/: {
|
| 67 |
return None
|
| 68 |
|
| 69 |
-
def passages_for_level(level: int
|
| 70 |
"""Count = level + 1, minimum 1."""
|
| 71 |
count = max(1, level + 1)
|
| 72 |
result = []
|
| 73 |
for i in range(1, count + 1):
|
| 74 |
-
p = load_passage(i
|
| 75 |
if p:
|
| 76 |
result.append(p)
|
| 77 |
return result
|
|
@@ -623,15 +614,18 @@ MODERATE_RULES = """
|
|
| 623 |
## ๐ Moderate Mode โ Full Rules
|
| 624 |
|
| 625 |
You'll see **English passages** with Bengali translations below each one.
|
| 626 |
-
Read them
|
| 627 |
|
| 628 |
-
### โฑ๏ธ Timer
|
| 629 |
-
|
| 630 |
-
-
|
| 631 |
-
|
| 632 |
-
|
|
|
|
|
|
|
|
|
|
| 633 |
|
| 634 |
-
|
| 635 |
|
| 636 |
### Scoring
|
| 637 |
| LLM Score | Meaning |
|
|
@@ -660,7 +654,6 @@ Once all passages are hidden, type what you remember!
|
|
| 660 |
- Capitalisation and spacing **do not matter** โ the app ignores them
|
| 661 |
- Gibberish or mindless repetition โ **โ1 โญ**
|
| 662 |
- **Copy-paste is disabled**
|
| 663 |
-
- **You cannot submit until all passages have disappeared!**
|
| 664 |
"""
|
| 665 |
|
| 666 |
EASY_RULES = """
|
|
@@ -704,10 +697,6 @@ def grade_standard(student_name: str, student_class: str, title: str, student_su
|
|
| 704 |
try:
|
| 705 |
if not all([student_name.strip(), student_class.strip(), title.strip(), student_summary.strip()]):
|
| 706 |
return "โ ๏ธ Please fill in all fields.", "", ""
|
| 707 |
-
|
| 708 |
-
wc = count_words(student_summary)
|
| 709 |
-
if wc < 100:
|
| 710 |
-
return f"โ ๏ธ You wrote {wc} words. Please write at least 100 words.", "", ""
|
| 711 |
|
| 712 |
rate_key = student_key(student_name, student_class)
|
| 713 |
prompt = f"TITLE: {title}\nSUMMARY: {student_summary}\n{RUBRIC_USER_TEXT}\n{JSON_SCHEMA_HINT}"
|
|
@@ -798,9 +787,11 @@ def grade_passage_mode(student_name: str, student_class: str, student_text: str,
|
|
| 798 |
if not all([student_name.strip(), student_class.strip(), student_text.strip()]):
|
| 799 |
return "โ ๏ธ Please fill in all fields.", level, ""
|
| 800 |
|
| 801 |
-
passages = passages_for_level(level
|
| 802 |
if not passages:
|
| 803 |
-
return "โ ๏ธ No passages found. Please upload
|
|
|
|
|
|
|
| 804 |
english_only_passages = [extract_english_only(p) for p in passages]
|
| 805 |
combined_english = "\n\n".join(english_only_passages)
|
| 806 |
|
|
@@ -816,14 +807,6 @@ def grade_passage_mode(student_name: str, student_class: str, student_text: str,
|
|
| 816 |
|
| 817 |
heuristic_bad, heuristic_reason = is_nonsense_heuristic(student_text)
|
| 818 |
is_failing = is_nonsense_ai or heuristic_bad
|
| 819 |
-
|
| 820 |
-
# Relevance check: if answer does not resemble passage at all
|
| 821 |
-
if not is_nonsense_ai and not heuristic_bad and raw_score <= 1:
|
| 822 |
-
return (
|
| 823 |
-
"โ Your answer does not match the passage at all. Please try to recall the actual passage.",
|
| 824 |
-
level,
|
| 825 |
-
""
|
| 826 |
-
)
|
| 827 |
|
| 828 |
if mode == "moderate":
|
| 829 |
max_stars = compute_max_stars_moderate(level)
|
|
@@ -945,7 +928,7 @@ with gr.Blocks(title="Summary & Passage Grader", theme=gr.themes.Soft()) as demo
|
|
| 945 |
)
|
| 946 |
|
| 947 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 948 |
-
# MODERATE MODE (
|
| 949 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 950 |
with gr.Tab("๐ฎ Moderate Mode"):
|
| 951 |
gr.Markdown(MODERATE_RULES)
|
|
@@ -953,80 +936,58 @@ with gr.Blocks(title="Summary & Passage Grader", theme=gr.themes.Soft()) as demo
|
|
| 953 |
mod_name = gr.Textbox(label="Student Name", placeholder="Your full name")
|
| 954 |
mod_class = gr.Textbox(label="Class", placeholder="e.g. 5A")
|
| 955 |
|
| 956 |
-
mod_level_state
|
| 957 |
-
mod_timer_state
|
| 958 |
-
|
| 959 |
-
mod_passages_state = gr.State(value=[]) # list of passage texts
|
| 960 |
-
mod_last_visible_state = gr.State(value=-1) # passages visible on last tick
|
| 961 |
|
| 962 |
mod_load_btn = gr.Button("๐ Load My Level & Passages", variant="primary")
|
| 963 |
mod_level_display = gr.Markdown()
|
|
|
|
| 964 |
mod_passages_display = gr.Markdown()
|
| 965 |
|
| 966 |
-
mod_timer_component = gr.Timer(1, active=False)
|
| 967 |
-
|
| 968 |
def mod_load(name, klass):
|
| 969 |
if not name.strip() or not klass.strip():
|
| 970 |
-
return
|
| 971 |
-
gr.Timer(1, active=False))
|
| 972 |
level = get_student_level(name, klass, "moderate")
|
| 973 |
-
passages = passages_for_level(level
|
| 974 |
-
|
| 975 |
max_s = compute_max_stars_moderate(level)
|
|
|
|
| 976 |
level_md = (f"### ๐ฎ Your Level: **{level}** "
|
| 977 |
-
f"Passages: **{
|
| 978 |
-
f"Max stars: **{max_s:.1f} โญ**
|
| 979 |
-
|
| 980 |
-
if pcount == 0:
|
| 981 |
-
return (level_md, "โ ๏ธ No passages found.", level, 0, 0, [], -1,
|
| 982 |
-
gr.Timer(1, active=False))
|
| 983 |
-
ptext = format_passages_display(passages)
|
| 984 |
ts = time.time()
|
| 985 |
-
return
|
| 986 |
-
gr.Timer(1, active=True))
|
| 987 |
|
| 988 |
mod_load_btn.click(
|
| 989 |
fn=mod_load,
|
| 990 |
inputs=[mod_name, mod_class],
|
| 991 |
-
outputs=[mod_level_display, mod_passages_display,
|
| 992 |
-
mod_level_state, mod_timer_state,
|
| 993 |
-
mod_passages_state, mod_last_visible_state, mod_timer_component]
|
| 994 |
)
|
| 995 |
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
elapsed
|
| 1002 |
-
|
| 1003 |
-
|
| 1004 |
-
|
| 1005 |
-
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
visible_passages.append((i, passages[i]))
|
| 1010 |
-
|
| 1011 |
-
# Nothing changed โ don't touch anything
|
| 1012 |
-
if visible_count == last_visible:
|
| 1013 |
-
return gr.update(), gr.Timer(1, active=True), last_visible
|
| 1014 |
-
|
| 1015 |
-
# Something changed โ rebuild passage display
|
| 1016 |
-
if visible_count == 0:
|
| 1017 |
-
ptext = "๐ *All passages hidden โ time is up! Type what you remember.*"
|
| 1018 |
-
return ptext, gr.Timer(1, active=False), 0
|
| 1019 |
else:
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
-
|
| 1025 |
-
|
| 1026 |
-
|
| 1027 |
-
fn=mod_tick,
|
| 1028 |
-
inputs=[mod_timer_state, mod_pcount_state, mod_passages_state, mod_last_visible_state],
|
| 1029 |
-
outputs=[mod_passages_display, mod_timer_component, mod_last_visible_state]
|
| 1030 |
)
|
| 1031 |
|
| 1032 |
mod_answer = gr.Textbox(label="โ๏ธ Type the English passage(s) here (no copy-paste!)",
|
|
@@ -1035,34 +996,23 @@ with gr.Blocks(title="Summary & Passage Grader", theme=gr.themes.Soft()) as demo
|
|
| 1035 |
mod_report = gr.Markdown()
|
| 1036 |
mod_status = gr.Markdown()
|
| 1037 |
|
| 1038 |
-
def mod_grade(name, klass, answer, level
|
| 1039 |
-
# Server-side enforcement: cannot submit until all passages hidden
|
| 1040 |
-
if ts > 0 and pcount > 0:
|
| 1041 |
-
elapsed = time.time() - ts
|
| 1042 |
-
secs_allowed = pcount * 60
|
| 1043 |
-
if elapsed < secs_allowed:
|
| 1044 |
-
remaining = int(secs_allowed - elapsed)
|
| 1045 |
-
return (f"โ ๏ธ Still {remaining} seconds left! "
|
| 1046 |
-
f"Wait for all passages to disappear first."),\
|
| 1047 |
-
"", gr.update(), gr.update(), level, 0, 0
|
| 1048 |
-
|
| 1049 |
report, new_level, status = grade_passage_mode(name, klass, answer, level, "moderate")
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
ptext = format_passages_display(new_passages)
|
| 1053 |
max_s = compute_max_stars_moderate(new_level)
|
|
|
|
| 1054 |
level_md = (f"### ๐ฎ Your Level: **{new_level}** "
|
| 1055 |
-
f"Passages: **{
|
| 1056 |
-
f"Max stars: **{max_s:.1f} โญ**
|
| 1057 |
-
|
| 1058 |
-
return report, status, level_md, ptext, new_level, 0,
|
| 1059 |
|
| 1060 |
mod_submit_btn.click(
|
| 1061 |
fn=mod_grade,
|
| 1062 |
-
inputs=[mod_name, mod_class, mod_answer, mod_level_state,
|
| 1063 |
-
|
| 1064 |
-
|
| 1065 |
-
mod_passages_display, mod_level_state, mod_timer_state, mod_pcount_state]
|
| 1066 |
)
|
| 1067 |
|
| 1068 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
@@ -1084,7 +1034,7 @@ with gr.Blocks(title="Summary & Passage Grader", theme=gr.themes.Soft()) as demo
|
|
| 1084 |
if not name.strip() or not klass.strip():
|
| 1085 |
return "โ ๏ธ Enter name and class first.", "", 2
|
| 1086 |
level = get_student_level(name, klass, "easy")
|
| 1087 |
-
passages = passages_for_level(level
|
| 1088 |
ptext = format_passages_display(passages)
|
| 1089 |
level_md = (f"### ๐ข Your Level: **{level}** "
|
| 1090 |
f"Passages: **{len(passages)}** Max stars: **5 โญ**")
|
|
@@ -1104,7 +1054,7 @@ with gr.Blocks(title="Summary & Passage Grader", theme=gr.themes.Soft()) as demo
|
|
| 1104 |
|
| 1105 |
def easy_grade(name, klass, answer, level):
|
| 1106 |
report, new_level, status = grade_passage_mode(name, klass, answer, level, "easy")
|
| 1107 |
-
passages = passages_for_level(new_level
|
| 1108 |
ptext = format_passages_display(passages)
|
| 1109 |
level_md = (f"### ๐ข Your Level: **{new_level}** "
|
| 1110 |
f"Passages: **{len(passages)}** Max stars: **5 โญ**")
|
|
@@ -1121,4 +1071,4 @@ with gr.Blocks(title="Summary & Passage Grader", theme=gr.themes.Soft()) as demo
|
|
| 1121 |
|
| 1122 |
if __name__ == "__main__":
|
| 1123 |
os.makedirs(PASSAGE_DIR, exist_ok=True)
|
| 1124 |
-
demo.launch()
|
|
|
|
| 45 |
# Check both root and passages/ subfolder so it works regardless of where files are uploaded
|
| 46 |
PASSAGE_DIR = "passages"
|
| 47 |
|
| 48 |
+
def load_passage(n: int) -> str | None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
candidates = [
|
| 50 |
+
f"pssg{n}.txt", # root of repo
|
| 51 |
+
os.path.join(PASSAGE_DIR, f"pssg{n}.txt"), # passages/ subfolder
|
| 52 |
]
|
| 53 |
for path in candidates:
|
| 54 |
if os.path.exists(path):
|
| 55 |
with open(path, "r", encoding="utf-8") as f:
|
| 56 |
return f.read().strip()
|
| 57 |
+
log.info(f"Passage file not found in root or passages/: pssg{n}.txt")
|
| 58 |
return None
|
| 59 |
|
| 60 |
+
def passages_for_level(level: int) -> list[str]:
|
| 61 |
"""Count = level + 1, minimum 1."""
|
| 62 |
count = max(1, level + 1)
|
| 63 |
result = []
|
| 64 |
for i in range(1, count + 1):
|
| 65 |
+
p = load_passage(i)
|
| 66 |
if p:
|
| 67 |
result.append(p)
|
| 68 |
return result
|
|
|
|
| 614 |
## ๐ Moderate Mode โ Full Rules
|
| 615 |
|
| 616 |
You'll see **English passages** with Bengali translations below each one.
|
| 617 |
+
Read them, then **the passage disappears after a time limit** โ type it back from memory!
|
| 618 |
|
| 619 |
+
### โฑ๏ธ Timer
|
| 620 |
+
| Level | Passage visible for |
|
| 621 |
+
|---|---|
|
| 622 |
+
| Level 0 | 1 minute |
|
| 623 |
+
| Level 1 | 2 minutes |
|
| 624 |
+
| Level 2 | 3 minutes |
|
| 625 |
+
| Level 3 | 4 minutes |
|
| 626 |
+
| Level N | (N+1) minutes |
|
| 627 |
|
| 628 |
+
After time is up the passage is **hidden** โ type what you remember!
|
| 629 |
|
| 630 |
### Scoring
|
| 631 |
| LLM Score | Meaning |
|
|
|
|
| 654 |
- Capitalisation and spacing **do not matter** โ the app ignores them
|
| 655 |
- Gibberish or mindless repetition โ **โ1 โญ**
|
| 656 |
- **Copy-paste is disabled**
|
|
|
|
| 657 |
"""
|
| 658 |
|
| 659 |
EASY_RULES = """
|
|
|
|
| 697 |
try:
|
| 698 |
if not all([student_name.strip(), student_class.strip(), title.strip(), student_summary.strip()]):
|
| 699 |
return "โ ๏ธ Please fill in all fields.", "", ""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 700 |
|
| 701 |
rate_key = student_key(student_name, student_class)
|
| 702 |
prompt = f"TITLE: {title}\nSUMMARY: {student_summary}\n{RUBRIC_USER_TEXT}\n{JSON_SCHEMA_HINT}"
|
|
|
|
| 787 |
if not all([student_name.strip(), student_class.strip(), student_text.strip()]):
|
| 788 |
return "โ ๏ธ Please fill in all fields.", level, ""
|
| 789 |
|
| 790 |
+
passages = passages_for_level(level)
|
| 791 |
if not passages:
|
| 792 |
+
return "โ ๏ธ No passages found. Please upload pssg1.txt etc. to the root of your HF repo (same folder as app.py).", level, ""
|
| 793 |
+
|
| 794 |
+
# Extract English-only portions for grading
|
| 795 |
english_only_passages = [extract_english_only(p) for p in passages]
|
| 796 |
combined_english = "\n\n".join(english_only_passages)
|
| 797 |
|
|
|
|
| 807 |
|
| 808 |
heuristic_bad, heuristic_reason = is_nonsense_heuristic(student_text)
|
| 809 |
is_failing = is_nonsense_ai or heuristic_bad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 810 |
|
| 811 |
if mode == "moderate":
|
| 812 |
max_stars = compute_max_stars_moderate(level)
|
|
|
|
| 928 |
)
|
| 929 |
|
| 930 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 931 |
+
# MODERATE MODE (passage disappears after timer)
|
| 932 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 933 |
with gr.Tab("๐ฎ Moderate Mode"):
|
| 934 |
gr.Markdown(MODERATE_RULES)
|
|
|
|
| 936 |
mod_name = gr.Textbox(label="Student Name", placeholder="Your full name")
|
| 937 |
mod_class = gr.Textbox(label="Class", placeholder="e.g. 5A")
|
| 938 |
|
| 939 |
+
mod_level_state = gr.State(value=2)
|
| 940 |
+
mod_timer_state = gr.State(value=0)
|
| 941 |
+
mod_visible_state = gr.State(value=True)
|
|
|
|
|
|
|
| 942 |
|
| 943 |
mod_load_btn = gr.Button("๐ Load My Level & Passages", variant="primary")
|
| 944 |
mod_level_display = gr.Markdown()
|
| 945 |
+
mod_timer_display = gr.Markdown()
|
| 946 |
mod_passages_display = gr.Markdown()
|
| 947 |
|
|
|
|
|
|
|
| 948 |
def mod_load(name, klass):
|
| 949 |
if not name.strip() or not klass.strip():
|
| 950 |
+
return "โ ๏ธ Enter name and class first.", "", "", 2, 0, True
|
|
|
|
| 951 |
level = get_student_level(name, klass, "moderate")
|
| 952 |
+
passages = passages_for_level(level)
|
| 953 |
+
ptext = format_passages_display(passages)
|
| 954 |
max_s = compute_max_stars_moderate(level)
|
| 955 |
+
mins = level + 1
|
| 956 |
level_md = (f"### ๐ฎ Your Level: **{level}** "
|
| 957 |
+
f"Passages: **{len(passages)}** "
|
| 958 |
+
f"Max stars: **{max_s:.1f} โญ**")
|
| 959 |
+
timer_md = f"โฑ๏ธ **You have {mins} minute(s) to read. The passage will disappear after that!**"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 960 |
ts = time.time()
|
| 961 |
+
return level_md, timer_md, ptext, level, ts, True
|
|
|
|
| 962 |
|
| 963 |
mod_load_btn.click(
|
| 964 |
fn=mod_load,
|
| 965 |
inputs=[mod_name, mod_class],
|
| 966 |
+
outputs=[mod_level_display, mod_timer_display, mod_passages_display,
|
| 967 |
+
mod_level_state, mod_timer_state, mod_visible_state]
|
|
|
|
| 968 |
)
|
| 969 |
|
| 970 |
+
mod_check_btn = gr.Button("๐ Check Timer / Hide Passage")
|
| 971 |
+
|
| 972 |
+
def mod_check_timer(level, ts, visible):
|
| 973 |
+
if ts == 0:
|
| 974 |
+
return gr.update(), "โ ๏ธ Load passages first.", visible
|
| 975 |
+
elapsed = time.time() - ts
|
| 976 |
+
secs_allowed = (level + 1) * 60
|
| 977 |
+
remaining = max(0.0, secs_allowed - elapsed)
|
| 978 |
+
if remaining > 0:
|
| 979 |
+
mins_left = int(remaining // 60)
|
| 980 |
+
secs_left = int(remaining % 60)
|
| 981 |
+
timer_md = f"โฑ๏ธ **Time remaining: {mins_left}m {secs_left}s**"
|
| 982 |
+
return gr.update(), timer_md, True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 983 |
else:
|
| 984 |
+
timer_md = "โฐ **Time's up! Passage hidden. Now type from memory!**"
|
| 985 |
+
return gr.update(value="๐ *Passage hidden โ time is up! Type what you remember.*"), timer_md, False
|
| 986 |
+
|
| 987 |
+
mod_check_btn.click(
|
| 988 |
+
fn=mod_check_timer,
|
| 989 |
+
inputs=[mod_level_state, mod_timer_state, mod_visible_state],
|
| 990 |
+
outputs=[mod_passages_display, mod_timer_display, mod_visible_state]
|
|
|
|
|
|
|
|
|
|
| 991 |
)
|
| 992 |
|
| 993 |
mod_answer = gr.Textbox(label="โ๏ธ Type the English passage(s) here (no copy-paste!)",
|
|
|
|
| 996 |
mod_report = gr.Markdown()
|
| 997 |
mod_status = gr.Markdown()
|
| 998 |
|
| 999 |
+
def mod_grade(name, klass, answer, level):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1000 |
report, new_level, status = grade_passage_mode(name, klass, answer, level, "moderate")
|
| 1001 |
+
passages = passages_for_level(new_level)
|
| 1002 |
+
ptext = format_passages_display(passages)
|
|
|
|
| 1003 |
max_s = compute_max_stars_moderate(new_level)
|
| 1004 |
+
mins = new_level + 1
|
| 1005 |
level_md = (f"### ๐ฎ Your Level: **{new_level}** "
|
| 1006 |
+
f"Passages: **{len(passages)}** "
|
| 1007 |
+
f"Max stars: **{max_s:.1f} โญ**")
|
| 1008 |
+
timer_md = f"โฑ๏ธ **Next round: you'll have {mins} minute(s) to read.**"
|
| 1009 |
+
return report, status, level_md, timer_md, ptext, new_level, 0, True
|
| 1010 |
|
| 1011 |
mod_submit_btn.click(
|
| 1012 |
fn=mod_grade,
|
| 1013 |
+
inputs=[mod_name, mod_class, mod_answer, mod_level_state],
|
| 1014 |
+
outputs=[mod_report, mod_status, mod_level_display, mod_timer_display,
|
| 1015 |
+
mod_passages_display, mod_level_state, mod_timer_state, mod_visible_state]
|
|
|
|
| 1016 |
)
|
| 1017 |
|
| 1018 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
| 1034 |
if not name.strip() or not klass.strip():
|
| 1035 |
return "โ ๏ธ Enter name and class first.", "", 2
|
| 1036 |
level = get_student_level(name, klass, "easy")
|
| 1037 |
+
passages = passages_for_level(level)
|
| 1038 |
ptext = format_passages_display(passages)
|
| 1039 |
level_md = (f"### ๐ข Your Level: **{level}** "
|
| 1040 |
f"Passages: **{len(passages)}** Max stars: **5 โญ**")
|
|
|
|
| 1054 |
|
| 1055 |
def easy_grade(name, klass, answer, level):
|
| 1056 |
report, new_level, status = grade_passage_mode(name, klass, answer, level, "easy")
|
| 1057 |
+
passages = passages_for_level(new_level)
|
| 1058 |
ptext = format_passages_display(passages)
|
| 1059 |
level_md = (f"### ๐ข Your Level: **{new_level}** "
|
| 1060 |
f"Passages: **{len(passages)}** Max stars: **5 โญ**")
|
|
|
|
| 1071 |
|
| 1072 |
if __name__ == "__main__":
|
| 1073 |
os.makedirs(PASSAGE_DIR, exist_ok=True)
|
| 1074 |
+
demo.launch()
|