XQuery/Basic Feedback Form

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Motivation[edit | edit source]

You want to gather feedback from visitors.

Implementation[edit | edit source]

A simple HTML form gathers suggested improvements and an email address. The suggestion is emailed to one of the authors and an acknowledgment sent to the submitter. Here the default send-mail client on the eXist implementation at UWE, Bristol is used.

XQuery script[edit | edit source]

xquery version "1.0";
(: A simple Feedback form using the eXist mail module :)
import module namespace mail="http://exist-db.org/xquery/mail";
declare option exist:serialize "method=xhtml media-type=text/html";

let $comment:= normalize-space(request:get-parameter("comment",""))
let $email := normalize-space(request:get-parameter("email",""))
    <title>Feedback on the XQuery Wikibook</title>
   <h1>Feedback on the XQuery Wikibook</h1>
   <form method="post">
     Please let us know how this Wikibook could be improved.<br/>
     <textarea name="comment" rows="5" cols="80"/><br/>
     Your email address <input type="text" name="email" size="60"/>
     <input type="submit" value="Send"/>
  {if ($email ne "" and $comment ne "")
      let $commentMessage :=
    <subject>Wikibook Feedback</subject>
      let $ackMessage := 
    <subject>Wikibook Feedback</subject>
      <text>Many thanks for your feedback - we appreciate your interest in this collaborative work.</text>
     let $sendcomment := mail:send-email($commentMessage,(),())
     let $sendack := mail:send-email($ackMessage,(),())
       if ($sendcomment and $sendack)
           <p>You suggested that the XQuery Wikibook could be improved by:<br/>
           <br/>Thanks for the feedback.</p>
         <p>Something went wrong - please try again</p>
    if ($comment ne "")
    then <div>Please provide an email address so that we can let you know of progress on your suggestion.</div>

Feedback Form