some more info and some difficulty added!
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user