@@ -545,6 +545,7 @@ Numbas.signals.on('localisation initialised', () => {
545545 this . hasColumnHeaders = Knockout . computed ( function ( ) {
546546 return Knockout . unwrap ( this . columnHeaders ) . length > 0 ;
547547 } , this ) ;
548+ this . cellFeedback = defaultObservable ( params . cellFeedback , [ ] ) ;
548549 this . title = params . title || '' ;
549550 var _numRows = typeof params . rows == 'function' ? params . rows : Knockout . observable ( Knockout . unwrap ( params . rows ) || 2 ) ;
550551 this . numRows = Knockout . computed ( {
@@ -606,7 +607,16 @@ Numbas.signals.on('localisation initialised', () => {
606607 var prefilled = ( ( Knockout . unwrap ( vm . prefilledCells ) || [ ] ) [ row ] || [ ] ) [ column ] ;
607608 var use_prefilled = prefilled != '' && prefilled !== undefined ;
608609 c = use_prefilled ? prefilled : c ;
609- var cell = { cell : Knockout . observable ( c ) , prefilled : use_prefilled , label : R ( 'matrix input.cell label' , { row :row + 1 , column :column + 1 } ) } ;
610+ const feedback = Knockout . pureComputed ( ( ) => {
611+ const v = ( vm . cellFeedback ( ) [ row ] || [ ] ) [ column ] ;
612+ return v ;
613+ } ) ;
614+ var cell = {
615+ cell : Knockout . observable ( c ) ,
616+ prefilled : use_prefilled ,
617+ label : R ( 'matrix input.cell label' , { row :row + 1 , column :column + 1 } ) ,
618+ feedback
619+ } ;
610620 cell . cell . subscribe ( make_result ) ;
611621 return cell ;
612622 }
@@ -769,7 +779,7 @@ Numbas.signals.on('localisation initialised', () => {
769779 <tr>
770780 <th data-bind="visible: $parent.hasRowHeaders"><span data-bind="latex: $parent.rowHeaders()[$index()+($parent.hasColumnHeaders() ? 1 : 0)] || ''"></span></th>
771781 <!-- ko foreach: $data -->
772- <td class="cell"><input type="text" autocapitalize="off" inputmode="text" spellcheck="false" data-bind="attr: {'aria-label': label}, textInput: cell, autosize: true, disable: prefilled || $parents[1].disable, event: $parents[1].events"/></td>
782+ <td class="cell" data-bind="attr: {'feedback-state': feedback}" ><input type="text" autocapitalize="off" inputmode="text" spellcheck="false" data-bind="attr: {'aria-label': label}, textInput: cell, autosize: true, disable: prefilled || $parents[1].disable, event: $parents[1].events"/></td>
773783 <!-- /ko -->
774784 </tr>
775785 </tbody>
0 commit comments