@@ -365,16 +365,16 @@ protected function create_input_box(qtype_formulas_part $part, $answerindex,
365
365
/** @var qype_formulas_question $question */
366
366
$ question = $ qa ->get_question ();
367
367
368
- $ variablename = $ part ->partindex ;
369
- if ($ part ->has_combined_unit_field ()) {
370
- $ variablename .= '_ ' ;
368
+ // The variable name will be N_M for answer #M in part #N or N_ for the (single) combined
369
+ // unit field of part N, or N_u for the (single) unit field of part N.
370
+ // FIXME: N_xxx for unit field with xxx = numbox
371
+ $ variablename = $ part ->partindex . '_ ' ;
372
+ if ($ answerindex === self ::UNIT_FIELD ) {
373
+ $ variablename .= $ part ->numbox ;
371
374
} else {
372
- $ variablename .= ($ answerindex == $ part -> numbox ? '_u ' : " _ { $ answerindex}" );
375
+ $ variablename .= ($ answerindex === self :: COMBINED_FIELD ? '' : $ answerindex );
373
376
}
374
377
375
- // The variable name will be N_M for answer #M in part #N or N_ for the (single) combined
376
- // unit field of part N, or N_u for the (single) unit field of part N.
377
- $ variablename = "{$ part ->partindex }_ {$ answerindex }" ;
378
378
$ currentanswer = $ qa ->get_last_qt_var ($ variablename );
379
379
$ inputname = $ qa ->get_qt_field_name ($ variablename );
380
380
@@ -392,9 +392,12 @@ protected function create_input_box(qtype_formulas_part $part, $answerindex,
392
392
default :
393
393
$ titlestring = 'number ' ;
394
394
}
395
- if ($ part -> postunit !== '' ) {
395
+ if ($ answerindex === self :: COMBINED_FIELD ) {
396
396
$ titlestring .= '_unit ' ;
397
397
}
398
+ if ($ answerindex === self ::UNIT_FIELD ) {
399
+ $ titlestring = 'unit ' ;
400
+ }
398
401
$ title = get_string ($ titlestring , 'qtype_formulas ' );
399
402
400
403
$ inputattributes = [
0 commit comments