Feedback - hide null answers in text fields/areas

Feedback - hide null answers in text fields/areas

by Jason Miller -
Number of replies: 0

This is a minor change that one of my curriculum developers requested.

We are using moodle 1.9

When viewing the analysis of feedback containing text based answers she wanted to not show the responces where the user did not provide an answer.

I accomplished this by adding an if statement to the textfield lib.php and the text area lib.php files.  The respective files can be found in the feedback folder under ../mod/feedback/item/textarea/lib.php and ../mod/feedback/item/textfield/lib.php

Under the function print_analysed section look for the foreach statement

foreach($values as $value) {

echo '<tr><td valign="top" align="left">-&nbsp;&nbsp;</td><td align="left" valign="top">' . str_replace("\n", '<br />', $value->value) . '</td></tr>';

}

I added an if statement directly above the echo to echo only if the value was not null.

Code is below....

foreach($values as $value) {

if($value->value != ""){

echo '<tr><td valign="top" align="left">-&nbsp;&nbsp;</td><td align="left" valign="top">' . str_replace("\n", '<br />', $value->value) . '</td></tr>';

}

}

I did the same to both the text field and text area questions... works like a charm.

 

Jason

Average of ratings: -