﻿file = r'app\Http\Controllers\TestSessionController.php'
with open(file, 'r', encoding='utf-8') as f:
    c = f.read()

old = "          'konsumen_gender'         => '-',\n            'konsumen_usia'            => '-',"
new = "          'konsumen_gender'         => $request->konsumen_gender ?? null,\n            'konsumen_usia'            => $request->konsumen_usia ?? null,"

if old in c:
    c = c.replace(old, new)
    print("OK!")
else:
    idx = c.find("'konsumen_gender'")
    print("GAGAL, exact:")
    print(repr(c[idx-5:idx+70]))

with open(file, 'w', encoding='utf-8') as f:
    f.write(c)
