With this code:
$html .= "
<input type='text' name='participant[" . $k . "][answer]'
class='form-control'" . ($required ? " required" : ""). ">";
The generated input is like:
<input type='text'
name='participant[1][answer]' class='form-control' required>
Do you know how to have "" instead of ''? Like:
<input type="text" name="participant[1][answer]" class="form-control" required>