Skip to content

Commit c882f95

Browse files
committed
fix(courseexam): parse_exam_markdown to increment start_instance_id
Signed-off-by: Tarek <[email protected]>
1 parent 4104da4 commit c882f95

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

benchmarks/courseexam_bench/data/example_course_2024_midterm/exam.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@
2323
What state is a process in when it is waiting for I/O to complete?
2424

2525
A. Running
26+
2627
B. Ready
28+
2729
C. Blocked
30+
2831
D. Terminated
2932

33+
Your answer should be a single letter only (A, B, C, or D).
34+
3035
```json
3136
{
3237
"problem_id": "1",
@@ -44,6 +49,8 @@ D. Terminated
4449

4550
True or False: A race condition occurs when multiple threads access shared data concurrently and at least one thread modifies the data.
4651

52+
Your answer should be either "True" or "False" only. No extra text.
53+
4754
```json
4855
{
4956
"problem_id": "2",
@@ -61,6 +68,8 @@ True or False: A race condition occurs when multiple threads access shared data
6168

6269
Explain the purpose of a Translation Lookaside Buffer (TLB) in a virtual memory system.
6370

71+
Your answer should be a brief explanation (about 2-3 sentences).
72+
6473
```json
6574
{
6675
"problem_id": "3",
@@ -78,6 +87,8 @@ Explain the purpose of a Translation Lookaside Buffer (TLB) in a virtual memory
7887

7988
Describe the two phases of the two-phase commit protocol.
8089

90+
Your answer should include a brief description of each phase (about 1-2 sentences each).
91+
8192
```json
8293
{
8394
"problem_id": "4",
@@ -97,17 +108,21 @@ Describe the two phases of the two-phase commit protocol.
97108
Which of the following operations modify the inode? (Select all that apply)
98109

99110
A. Changing file permissions
111+
100112
B. Reading file contents
113+
101114
C. Changing file size
102115

116+
Your answer should be a comma-separated list of letters only (no extra text). For example: "A,B"
117+
103118
```json
104119
{
105120
"problem_id": "5",
106121
"points": 5,
107122
"type": "ExactMatch",
108123
"tags": ["operating-systems", "file-systems"],
109-
"answer": "A,C",
110-
"comments": "Multiple correct answers but NO partial credit. Only exact match \"A,C\" gets 5 points."
124+
"answer": "A, C",
125+
"comments": "Multiple correct answers but NO partial credit. Only exact match \"A, C\" gets 5 points."
111126
}
112127
```
113128

@@ -118,17 +133,21 @@ C. Changing file size
118133
Which statements about CPU scheduling are true? (Select all that apply)
119134

120135
A. Round-robin can lead to starvation
136+
121137
B. SJF minimizes average waiting time
138+
122139
C. Priority scheduling can have priority inversion
123140

141+
Your answer should be a comma-separated list of letters only (no extra text). For example: "A, B"
142+
124143
```json
125144
{
126145
"problem_id": "6",
127146
"points": 10,
128147
"type": "Freeform",
129148
"tags": ["operating-systems", "scheduling"],
130-
"answer": "B,C",
131-
"llm_judge_instructions": "Correct: B,C. Award 10 points for B,C. Award 6 points for only B or only C. Award 0 if A is selected (incorrect).",
149+
"answer": "B, C",
150+
"llm_judge_instructions": "Correct: B, C. Award 10 points for B, C. Award 6 points for only B or only C. Award 0 if A is selected (incorrect).",
132151
"comments": "Multiple choice with partial credit. Freeform type with rubric allows rewarding incomplete but correct answers while penalizing wrong choices."
133152
}
134153
```
@@ -160,6 +179,8 @@ Refer to the Raft Algorithm Reference.
160179

161180
True or False: A candidate must receive votes from a majority of servers to become leader.
162181

182+
Your answer should be either "True" or "False" only. No extra text.
183+
163184
```json
164185
{
165186
"problem_id": "8",
@@ -180,6 +201,8 @@ Refer to the Raft Algorithm Reference.
180201

181202
What are the three possible outcomes when a candidate runs for election? List all three.
182203

204+
Your answer should list the three outcomes in a single response (one to two sentences each).
205+
183206
```json
184207
{
185208
"problem_id": "9",
@@ -199,6 +222,8 @@ What are the three possible outcomes when a candidate runs for election? List al
199222

200223
True or False: In Paxos, a proposer must receive responses from a majority of acceptors to achieve consensus.
201224

225+
Your answer should be either "True" or "False" only. No extra text.
226+
202227
```json
203228
{
204229
"problem_id": "10.1",
@@ -216,6 +241,8 @@ True or False: In Paxos, a proposer must receive responses from a majority of ac
216241

217242
True or False: The CAP theorem states that a distributed system can simultaneously guarantee Consistency, Availability, and Partition tolerance.
218243

244+
Your answer should be either "True" or "False" only. No extra text.
245+
219246
```json
220247
{
221248
"problem_id": "10.2",

benchmarks/courseexam_bench/prepare_dataset.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pathlib import Path
44

55

6-
def parse_exam_markdown(exam_md_path):
6+
def parse_exam_markdown(exam_md_path, start_instance_id):
77
content = exam_md_path.read_text()
88

99
exam_metadata_match = re.search(r"```json\n(\{[^`]+?\})\n```", content)
@@ -12,7 +12,7 @@ def parse_exam_markdown(exam_md_path):
1212
sections = content.split("\n---\n")[1:]
1313

1414
questions = []
15-
instance_id = 1
15+
instance_id = start_instance_id
1616

1717
for section in sections:
1818
json_blocks = re.findall(r"```json\n(\{[^`]+?\})\n```", section)
@@ -67,7 +67,7 @@ def parse_exam_markdown(exam_md_path):
6767
questions.append(question)
6868
instance_id += 1
6969

70-
return exam_metadata, questions
70+
return exam_metadata, questions, instance_id
7171

7272

7373
def main():
@@ -76,6 +76,7 @@ def main():
7676

7777
all_exams_metadata = []
7878
all_questions = []
79+
next_instance_id = 1
7980

8081
for exam_folder in data_dir.iterdir():
8182
if not exam_folder.is_dir() or exam_folder.name in [
@@ -88,7 +89,9 @@ def main():
8889
if not exam_md.exists():
8990
continue
9091

91-
exam_metadata, questions = parse_exam_markdown(exam_md)
92+
exam_metadata, questions, next_instance_id = parse_exam_markdown(
93+
exam_md, next_instance_id
94+
)
9295
all_exams_metadata.append(exam_metadata)
9396
all_questions.extend(questions)
9497

0 commit comments

Comments
 (0)