From f863bed701a356805c39452b82b6576e97d1aefb Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 28 Aug 2008 01:46:47 +0000 Subject: [PATCH] MDL-8475 - Better handling of blank answer - further changes to make it even more robust. Also, make the same changes to the shortanswer question type that were already made to the numerical question type. --- lang/en_utf8/qtype_shortanswer.php | 1 + lib/moodlelib.php | 13 ++- .../type/numerical/edit_numerical_form.php | 11 +-- question/type/numerical/questiontype.php | 98 ++++++++++--------- .../shortanswer/edit_shortanswer_form.php | 3 + question/type/shortanswer/questiontype.php | 50 +++++----- 6 files changed, 97 insertions(+), 79 deletions(-) diff --git a/lang/en_utf8/qtype_shortanswer.php b/lang/en_utf8/qtype_shortanswer.php index f79f8cd0c9c..9a5d85ba387 100644 --- a/lang/en_utf8/qtype_shortanswer.php +++ b/lang/en_utf8/qtype_shortanswer.php @@ -2,4 +2,5 @@ $string['addmoreanswerblanks'] = 'Blanks for {no} More Answers'; $string['answerno'] = 'Answer $a'; $string['filloutoneanswer'] = 'You must provide at least one possible answer. Answers left blank will not be used. \'*\' can be used as a wildcard to match any characters. The first matching answer will be used to determine the score and feedback.'; +$string['answermustbegiven'] = 'You must enter an answer if there is a grade or feedback.'; ?> \ No newline at end of file diff --git a/lib/moodlelib.php b/lib/moodlelib.php index bb0e19d933c..050c1c34cf7 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -600,7 +600,18 @@ function clean_param($param, $type) { } } - +/** + * This function is useful for testing whether something you got back from + * the HTML editor actually contains anything. Sometimes the HTML editor + * appear to be empty, but actually you get back a
tag or something. + * + * @param string $string a string containing HTML. + * @return boolean does the string contain any actual content - that is text, + * images, objcts, etc. + */ +function html_is_blank($string) { + return trim(strip_tags($string, '