History | Log In     View a printable version of the current page.  
We are currently focused especially on Moodle 2.0, Moodle 1.9.x bugs and Moodle 1.9.x testing.    Confused? Lost? Please read this introduction to the Tracker.
Issue Details (XML | Word | Printable)

Key: MDL-12369
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Tim Hunt
Reporter: Tim Hunt
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Moodle

get_actual_response should not truncate the student's response

Created: 28/Nov/07 08:45 PM   Updated: 11/Dec/07 07:27 PM
Component/s: Questions
Affects Version/s: 1.9
Fix Version/s: 1.9

Participants: Jean-Michel Vedrine and Tim Hunt
Security Level: None


 Description  « Hide
For some reason, it was chopping it off at 40 characters.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Jean-Michel Vedrine - 10/Dec/07 03:04 AM
Tim,
I quite agree with you on this change.
For the same reason the get_actual_response of any questiontype should not do any formatting on the question response. For instance (see MDL-12418) get_actual_response should not call format_text as it currently do in the multichoice's questiontype.php file. Truncating or formatting the response prevent from doing any string comparison with the student's response so it is a bad thing.

But removing all this code from get_actual_response left us with a problem : all quiz reports (currently core overview report and my own detailed responses report) calling the get_actual_response method via the get_question_actual_response function in questionlib.php need to be modified because currently display is awfull whith long responses.

Rather than truncating responses in the reports I think the good way to do it would be to use get_actual_response when you want to do strings compare and use response_summary for display purpose.
I will also move format_text out of get_actual response as suggested in the patch uploaded in MDL-12418
What do you think of that ?
If you agree, I will modify detailed responses report, test my changes and send a patch file for variuos questiontype.php and overview report.php.
I hope this will also solve MDL-12418

Tim Hunt - 11/Dec/07 07:27 PM
It would be really great if you could work on this, because I don't have time at the moment.


I would like to say that it should be simple: the question types should output raw data from the reporting methods, and the reports should be responsible for the formatting / truncation if desired.

By reporting methods, I guess I mean:

get_actual_response
get_all_responses
get_correct_responses

Unfortunately, this does not work, because different question types have different sorts of answers. For example shortanswer (plain text answer strings) and multichoice (HTML answers). Therefore the question type may have to be involved in the formatting.


There several things me might try to solve this.

1. Say that it never does any harm to run plain text through format_text, and so we can stick to the above policy. I don't thin that works, because people do use the Moodle quiz for programmer-type questions like "What is the HTML tag for bold?" (answer "<b>") which absolutely must be processed as plain text.

2. Instead use the policy:

The output from all three reporting methods must be fully formatted, so they can be directly output to the browser without further processing. However, they must be formatted in exactly the same way, so the strings returned by the various methods can be compared with each other.

No, this does not work, because when doing Excel or CSV output, you don't want the strings formatted.

3. Lastly, we could, insist that the three reporting methods return the raw data (and, as in 2. insist that the return values from all three methods are comparable), and then add a new method to the question types: format_responses_as_html, that does the appropriate formatting on those values before they are printed into the HTML.

I thing 3. is the only plan that is going to work.

It would be up to the report to call and $QTYPE[...]->format_responses_as_html(shorten_text($response), 40); on data that is going to be output as HTML. I think data exported as CSV/Excel should be kept as raw data and not truncated.


Does that sound like a workable plan?


Finally, you may like to note that we (the OU) is planning to commission a whole lot of changes to the quiz reports (probably to Jamie Pratt). I am developing a spec here: http://docs.moodle.org/en/Development:Quiz_report_enhancements. However, I have not finished it yet, which is why I have not yet asked for discussion in the quiz forum. So, anyway, if you don't manage to do this, I can include it in that spec.