atz21 commited on
Commit
cda728b
·
verified ·
1 Parent(s): 2140c1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -51
app.py CHANGED
@@ -16,14 +16,21 @@ PROMPTS = {
16
  ## Instructions
17
  Output must be a valid JSON array, with one object per (sub-)question, in order.
18
  Each object must have exactly these keys:
19
- - "question_number": string (e.g., "1", "1(a)", "2(b)(ii)")
20
- - "qp": string (exact question text or "[Not found]")
21
- - "ms": string (relevant markscheme text or "[Not found]")
22
- - "as": string (final cleaned student answer; "[No response]" or "[illegible]" if needed)
23
- Rules:
24
- - Preserve math inside fenced code ```...```.
25
- - If diagram/graph missing, write "[Graph omitted]".
26
- - Do not add extra commentary outside JSON.
 
 
 
 
 
 
 
27
  ## Example
28
  [
29
  {
@@ -39,51 +46,34 @@ Rules:
39
  "role": "system",
40
  "content": """Developer: You are an official examiner. Apply the following grading rules precisely.
41
  ### Abbreviations:
42
- - **M**: Marks for demonstrating a correct Method.
43
- - **A**: Marks for providing an accurate Answer; often requires a valid M mark first.
44
- - **R**: Marks for clear Reasoning.
45
- - **AG**: Answer is given in the question—no marks awarded.
46
- - **FT**: Follow Through; award marks when candidates continue with their own previous (possibly incorrect) answers, provided their later method is correct.
 
 
47
  ---
48
  ## Grading Instructions
49
- 1. **General Marking**
50
- - Award marks using official annotations (e.g., M1, A2).
51
- - Do not award full marks for answers alone; check for method marks.
52
- 2. **Method and Answer/Accuracy Marks**
53
- - A marks usually require a valid M mark first.
54
- - Multiple A marks may be independent unless specified.
55
- 3. **Implied Marks**
56
- - Implied M marks can only be given when the method is clearly demonstrated or properly inferred.
57
- 4. **Follow Through (FT) Marks**
58
- - Award FT if an earlier mistake is carried forward correctly (unless nonsensical).
59
- 5. **Misread (MR)**
60
- - Deduct MR once for consistent misreading.
61
- 6. **Alternative Methods**
62
- - Allow valid alternative approaches unless 'Hence' precludes them.
63
- 7. **Alternative Forms**
64
- - Accept equivalent algebraic/numeric forms unless otherwise specified.
65
- 8. **Format and Accuracy**
66
- - Default accuracy: 3 s.f. unless stated.
67
- - Simplify arithmetic/algebra as appropriate.
68
- 9. **Presentation of Work**
69
- - Ignore crossed-out work unless stated.
70
- - Mark only the first full solution unless otherwise indicated.
71
- 10. **Graphs/Diagrams**
72
- - Award marks for correctly executed graphs/diagrams as specified.
73
  ---
74
  ## Output Format
75
- Produce a GitHub-flavored Markdown table with these columns:
76
- | Student wrote | Marks Awarded | Reason |
77
- - Each row = one markable step/point in order, following the markscheme.
78
- - For blanks, write “(no answer)” and mark lost.
79
- - Use proper notation (M1A0, A1, etc.).
80
- - Any lost mark (M0, A0, R0, etc.): wrap in red `<span style="color:red">M0</span>` and make the Reason column red.
81
- - Awarded marks appear plain.
82
- After the table, provide:
83
- ### Summary & Final Mark
84
- - Show total marks vs available.
85
- - Note any FT used.
86
- - Classify errors (Conceptual, Silly mistake, Misread, etc.).
87
  """
88
  }
89
  }
@@ -222,8 +212,8 @@ def align_and_grade(qp_file, ms_file, ans_file):
222
  section = f"## Question {qnum}\n\n{grading_piece}"
223
  grading_sections.append(section)
224
 
225
- # Extract marks from "Summary & Final Mark"
226
- match = re.search(r"(\d+)\s*/\s*(\d+)", grading_piece)
227
  if match:
228
  awarded, possible = int(match.group(1)), int(match.group(2))
229
  marks_summary.append((qnum, awarded, possible))
@@ -282,3 +272,5 @@ with gr.Blocks(title="LeadIB AI Grading (JSON Alignment + Auto-Grading)") as dem
282
 
283
  if __name__ == "__main__":
284
  demo.launch()
 
 
 
16
  ## Instructions
17
  Output must be a valid JSON array, with one object per (sub-)question, in order.
18
  Each object must have exactly these keys:
19
+ - "question_number": string (e.g., "1", "1(a)", "2(b)(ii)")
20
+ - "qp": string (exact question text or "[Not found]")
21
+ - "ms": string (relevant markscheme text or "[Not found]")
22
+ - "as": string (final cleaned student answer; "[No response]" or "[illegible]" if needed)
23
+
24
+ ### Numbering Rules
25
+ - Always use **logical order of questions** (1, 2, 3, …) regardless of how they are labeled in the PDF.
26
+ - If the QP shows a mismatch (e.g., under "Question 1" the serial number says "12"), **still treat it as Q1**.
27
+ - Subparts must be written in standard form (e.g., "1(a)", "1(b)(ii)").
28
+
29
+ ### Formatting Rules
30
+ - Preserve math inside fenced code ```...```.
31
+ - If diagram/graph missing, write "[Graph omitted]".
32
+ - Do not add extra commentary outside JSON.
33
+
34
  ## Example
35
  [
36
  {
 
46
  "role": "system",
47
  "content": """Developer: You are an official examiner. Apply the following grading rules precisely.
48
  ### Abbreviations:
49
+ - **M**: Marks for Method
50
+ - **A**: Marks for Accuracy/Answer
51
+ - **R**: Marks for Reasoning
52
+ - **AG**: Answer given in question—no marks
53
+ - **FT**: Follow Through marks (if error carried forward correctly)
54
+ - **MR**: Deduct for misread (once only)
55
+
56
  ---
57
  ## Grading Instructions
58
+ 1. Award marks using official annotations (e.g., M1, A2).
59
+ 2. Do not award full marks for answers alone; check for method marks.
60
+ 3. A marks usually require a valid M mark first.
61
+ 4. Accept valid equivalent forms unless otherwise specified.
62
+ 5. Apply FT where appropriate.
63
+ 6. Use proper notation: M1A0, A1, etc.
64
+ 7. Any lost mark: use red `<span style="color:red">M0</span>` and make Reason red.
65
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ---
67
  ## Output Format
68
+ 1. Produce a GitHub-flavored Markdown table with columns:
69
+ | Student wrote | Marks Awarded | Reason |
70
+ - Each row = one markable step/point, in order.
71
+ - For blanks: “(no answer)” with marks lost.
72
+
73
+ 2. After the table, write ONLY one line for total marks in the form: Final Marks: X / Y
74
+
75
+ ⚠️ Do NOT include summaries, error classifications, or extra commentary.
76
+ Only table + final marks line.
 
 
 
77
  """
78
  }
79
  }
 
212
  section = f"## Question {qnum}\n\n{grading_piece}"
213
  grading_sections.append(section)
214
 
215
+ # Extract marks from "Final Marks: X / Y"
216
+ match = re.search(r"Final Marks:\s*(\d+)\s*/\s*(\d+)", grading_piece)
217
  if match:
218
  awarded, possible = int(match.group(1)), int(match.group(2))
219
  marks_summary.append((qnum, awarded, possible))
 
272
 
273
  if __name__ == "__main__":
274
  demo.launch()
275
+
276
+