Download & Extend

Email Quiz Author: Errors after completing quiz and no body in resulting email

Project:Quiz
Version:7.x-4.x-dev
Component:Code - Quiz core
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I'm using 7.x-4.x-dev (2011-Oct-06)

I have the quiz set to email the author of the quiz (and not the taker). When the user completes the quiz they are shown two errors:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1521 of /www/includes/bootstrap.inc).
Warning: implode() [function.implode]: Invalid arguments passed in DefaultMailSystem->format() (line 23 of /www/modules/system/system.mail.inc).

The email is sent, it has a subject but no body.

Comments

#1

Title:Email Quiz Aurhot: Errors after completing quiz and no body in resulting email email» Email Quiz Author: Errors after completing quiz and no body in resulting email email

If I set the author and the taker to receive email, I get the same errors but repeated twice.

Both emails are sent, both with no body.

#2

Title:Email Quiz Author: Errors after completing quiz and no body in resulting email email» Email Quiz Author: Errors after completing quiz and no body in resulting email

#3

So I fixed the problem of the invalid arguments passed to DefaultMailSystem->format(). See patch.

I'm still looking at the array getting passed to check_plain()

AttachmentSize
quiz_email_body-1313920-3.patch 585 bytes

#4

Status:active» needs review

Ok, I fixed both of the errors above.

The other one was caused by not properly passing the quiz body through check_plain().

Here is a patch that addresses both problems.

AttachmentSize
quiz_email_body-1313920-4.patch 1.34 KB

#5

Thank you for this. I've been getting the same problem. So I used this patch but then I get an internal server error on the page that is supposed to be shown after the quiz is completed.

I'm not an advanced Drupal user at all so any help would be appreciated.

#6

Hey parsimony,
I don't think I was having that problem. Can you look at the apache and/or php error logs? That might give you a clue about what is breaking.

#7

Ok, I see now. I left some debug code in the patch. Sorry about that!

Try this one and see if it helps.

AttachmentSize
quiz_email_body-1313920-7.patch 1.32 KB

#8

I faced this bug, but after this patch,
I get undefined index at this line,
'!desc' => check_plain($quiz->body[$quiz->language][0]['value']),
I used print_r(quiz),
stdClass Object ( [vid] => 8 [uid] => 1 [title] => TF test [log] => [status] => 1 [comment] => 1 [promote] => 1 [sticky] => 0 [nid] => 5 [type] => quiz [language] => [created] => 1324449896 [changed] => 1324639465 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1324639465 [revision_uid] => 1 [aid] => 0 [number_of_random_questions] => 0 [max_score_for_random] => 1 [pass_rate] => 75 [summary_pass] => [summary_pass_format] => filtered_html [summary_default] => [summary_default_format] => filtered_html [randomization] => 1 [backwards_navigation] => 1 [repeat_until_correct] => 0 [feedback_time] => 0 [display_feedback] => 1 [quiz_open] => 1324425600 [quiz_close] => 1327017600 [takes] => 0 [show_attempt_stats] => 1 [keep_results] => 2 [time_limit] => 0 [quiz_always] => 1 [tid] => 0 [has_userpoints] => 0 [allow_skipping] => 1 [allow_resume] => 1 [allow_jumping] => 1 [body] => Array ( ) [rdf_mapping] => Array ( [rdftype] => Array ( [0] => sioc:Item [1] => foaf:Document ) [title] => Array ( [predicates] => Array ( [0] => dc:title ) ) [created] => Array ( [predicates] => Array ( [0] => dc:date [1] => dc:created ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] => Array ( [predicates] => Array ( [0] => dc:modified ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [body] => Array ( [predicates] => Array ( [0] => content:encoded ) ) [uid] => Array ( [predicates] => Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => Array ( [predicates] => Array ( [0] => foaf:name ) ) [comment_count] => Array ( [predicates] => Array ( [0] => sioc:num_replies ) [datatype] => xsd:integer ) [last_activity] => Array ( [predicates] => Array ( [0] => sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) ) [cid] => 0 [last_comment_timestamp] => 1324449896 [last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0 [name] => admin [picture] => 0 [data] => b:0; )

Any help will be appreciated.

#9

@selvamkf, probably the body field is empty (your print_r() says so, [body] => Array ( )).

Add a check like,

-    '!desc' => check_plain($quiz->body[$quiz->language][0]['value']),
+    '!desc' => isset($quiz->body[$quiz->language][0]['value'])  ? check_plain($quiz->body[$quiz->language][0]['value']) : '',

#10

@sivaji , that fixes the issue. Thanks.

#11

Status:needs review» fixed

I'm going to mark this fixed as it looks as though this code (with the correction in #9) has made it into 7.x-4.x-dev...

#12

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.