some more info and some difficulty added!

This commit is contained in:
2025-08-12 18:56:52 +02:00
parent 0bffdf612c
commit c7c1b8ecd6
8 changed files with 116 additions and 43 deletions

View File

@@ -35,6 +35,7 @@ class ProblemScannerThread(threading.Thread):
id INTEGER PRIMARY KEY AUTOINCREMENT,
folder TEXT,
description TEXT,
difficulty TEXT,
test_code TEXT
)''')
conn.commit()
@@ -65,13 +66,18 @@ class ProblemScannerThread(threading.Thread):
description = f.read()
with open(test_path, 'r', encoding='utf-8') as f:
test_code = f.read()
with open(manifest_path, 'r', encoding='utf-8') as f:
manifest = json.load(f)
difficulty = manifest.get('difficulty', 'unknown')
problems.append({
'folder': folder.name,
'description': description,
'test_code': test_code
'test_code': test_code,
'difficulty': difficulty
})
print(f"Found problem: {folder.name}")
print(f"Found problem: {folder.name} ; Difficulty: {difficulty}")
except Exception as e:
print(f"Error reading problem files for {folder.name}: {e}")
else:
@@ -99,8 +105,10 @@ class ProblemScannerThread(threading.Thread):
# Insert new problems
for p in problems:
c.execute('INSERT INTO problems (folder, description, test_code) VALUES (?, ?, ?)',
(p['folder'], p['description'], p['test_code']))
c.execute('''INSERT INTO problems
(folder, description, difficulty, test_code)
VALUES (?, ?, ?, ?)''',
(p['folder'], p['description'], p['difficulty'], p['test_code']))
conn.commit()
print(f"Updated database with {len(problems)} problems")