1+ // Render edit form fields
2+ function renderEditFields ( type , question = null ) {
3+ const container = document . getElementById ( 'editDynamicFields' ) ;
4+ let html = '' ;
5+
6+ if ( type === 'mc' ) {
7+ html += `<label for="editVraag">Vraag:</label>` ;
8+ html += `<input type="text" id="editVraag" name="editVraag" required value="${ escapeHtml ( question ? question . vraag : '' ) } ">` ;
9+ html += `<label for="editJuisteAntwoord">Juiste antwoord:</label>` ;
10+ html += `<input type="text" id="editJuisteAntwoord" name="editJuisteAntwoord" required value="${ escapeHtml ( question ? question . juisteAntwoord : '' ) } ">` ;
11+ html += `<label>Foute antwoorden:</label>` ;
12+ html += `<input type="text" id="editFouteAntwoord1" name="editFouteAntwoord1" required value="${ escapeHtml ( question && question . fouteAntwoorden [ 0 ] ? question . fouteAntwoorden [ 0 ] : '' ) } ">` ;
13+ html += `<input type="text" id="editFouteAntwoord2" name="editFouteAntwoord2" required value="${ escapeHtml ( question && question . fouteAntwoorden [ 1 ] ? question . fouteAntwoorden [ 1 ] : '' ) } ">` ;
14+ html += `<input type="text" id="editFouteAntwoord3" name="editFouteAntwoord3" required value="${ escapeHtml ( question && question . fouteAntwoorden [ 2 ] ? question . fouteAntwoorden [ 2 ] : '' ) } ">` ;
15+ html += renderBibleReferenceInput ( 'editBiblicalReference' , 'editBiblicalReference' , question && question . biblicalReference ? question . biblicalReference : '' ) ;
16+ html += renderEditCategories ( question ? question . categories : [ ] ) ;
17+ } else if ( type === 'fitb' ) {
18+ html += `<label for="editVraag">Vraag (gebruik _____ voor het invulveld):</label>` ;
19+ html += `<input type="text" id="editVraag" name="editVraag" required value="${ escapeHtml ( question ? question . vraag : '' ) } ">` ;
20+ html += `<label for="editJuisteAntwoord">Juiste antwoord:</label>` ;
21+ html += `<input type="text" id="editJuisteAntwoord" name="editJuisteAntwoord" required value="${ escapeHtml ( question ? question . juisteAntwoord : '' ) } ">` ;
22+ html += `<label>Foute antwoorden:</label>` ;
23+ html += `<input type="text" id="editFouteAntwoord1" name="editFouteAntwoord1" required value="${ escapeHtml ( question && question . fouteAntwoorden [ 0 ] ? question . fouteAntwoorden [ 0 ] : '' ) } ">` ;
24+ html += `<input type="text" id="editFouteAntwoord2" name="editFouteAntwoord2" required value="${ escapeHtml ( question && question . fouteAntwoorden [ 1 ] ? question . fouteAntwoorden [ 1 ] : '' ) } ">` ;
25+ html += `<input type="text" id="editFouteAntwoord3" name="editFouteAntwoord3" required value="${ escapeHtml ( question && question . fouteAntwoorden [ 2 ] ? question . fouteAntwoorden [ 2 ] : '' ) } ">` ;
26+ html += renderBibleReferenceInput ( 'editBiblicalReference' , 'editBiblicalReference' , question && question . biblicalReference ? question . biblicalReference : '' ) ;
27+ html += renderEditCategories ( question ? question . categories : [ ] ) ;
28+ } else if ( type === 'tf' ) {
29+ const isWaar = question && question . juisteAntwoord === 'Waar' ;
30+ html += `<label for="editVraag">Stelling:</label>` ;
31+ html += `<input type="text" id="editVraag" name="editVraag" required value="${ escapeHtml ( question ? question . vraag : '' ) } ">` ;
32+ html += `<label for="editJuisteAntwoord">Is dit waar?</label>` ;
33+ html += `<select id="editJuisteAntwoord" name="editJuisteAntwoord">` ;
34+ html += `<option value="Waar" ${ isWaar ? 'selected' : '' } >Waar</option>` ;
35+ html += `<option value="Niet waar" ${ ! isWaar ? 'selected' : '' } >Niet waar</option>` ;
36+ html += `</select>` ;
37+ html += renderBibleReferenceInput ( 'editBiblicalReference' , 'editBiblicalReference' , question && question . biblicalReference ? question . biblicalReference : '' ) ;
38+ html += renderEditCategories ( question ? question . categories : [ ] ) ;
39+ }
40+
41+ container . innerHTML = html ;
42+
43+ // Setup autocomplete for edit Bible reference input
44+ setupBibleReferenceAutocomplete ( 'editBiblicalReference' ) ;
45+ }
0 commit comments