Index: mod/quiz/report/responses/responses_table.php =================================================================== --- mod/quiz/report/responses/response_table_copy.php Tue Oct 14 21:07:52 2008 +++ mod/quiz/report/responses/responses_table.php Tue Oct 14 21:12:08 2008 @@ -162,7 +162,6 @@ if ($response){ $format_options = new stdClass; $format_options->para = false; - $format_options->noclean = true; $format_options->newlines = false; $response = format_text($response, FORMAT_MOODLE, $format_options); if (strlen($response) > QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY){ @@ -187,7 +186,7 @@ return ''; } } else { - return $response; + return $this->format_text($response); } } else { return NULL; Index: lib/tablelib.php =================================================================== --- lib/tablelib_copy.php Tue Oct 14 19:56:35 2008 +++ lib/tablelib.php Tue Oct 14 21:17:13 2008 @@ -730,6 +730,37 @@ /** + * Used from col_* functions when text is to be displayed. Does the + * right thing - either converts text to html or strips any html tags + * depending on if we are downloading and what is the download type. Params + * are the same as format_text function in weblib.php but some default + * options are changed. + */ + function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL){ + if (!$this->is_downloading()){ + if (is_null($options)){ + $options = new stdClass; + } + //some sensible defaults + if (!isset($options->para)){ + $options->para = false; + } + if (!isset($options->newlines)){ + $options->newlines = false; + } + if (!isset($options->smiley)) { + $options->smiley = false; + } + if (!isset($options->filter)) { + $options->filter = false; + } + return format_text($text, $format, $options); + } else { + $eci =& $this->export_class_instance(); + return $eci->format_text($text, $format, $options, $courseid); + } + } + /** * This method is deprecated although the old api is still supported. * @deprecated 1.9.2 - Jun 2, 2008 */ @@ -1295,6 +1326,16 @@ function document_started(){ return $this->documentstarted; } + /** + * Given text in a variety of format codings, this function returns + * the text as safe HTML or as plain text dependent on what is appropriate + * for the download format. The default removes all tags. + */ + function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL){ + //use some whitespace to indicate where there was some line spacing. + $text = str_replace(array('

', "\n", "\r"), ' ', $text); + return strip_tags($text); + } } class table_spreadsheet_export_format_parent extends table_default_export_format_parent{ @@ -1525,6 +1566,25 @@ function finish_document(){ echo "\n"; exit; + } + function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL){ + if (is_null($options)){ + $options = new stdClass; + } + //some sensible defaults + if (!isset($options->para)){ + $options->para = false; + } + if (!isset($options->newlines)){ + $options->newlines = false; + } + if (!isset($options->smiley)) { + $options->smiley = false; + } + if (!isset($options->filter)) { + $options->filter = false; + } + return format_text($text, $format, $options); } } // ou-specific ends - many changes throughout this file until Moodle 2.0