<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -58,43 +58,52 @@ module SmerfSystemHelpers
     # Retrieve the owner object of the answer
     question_object = smerf_get_owner_object(answer_object, form)
 
-    # 1. Make sure that the answer that relates to this subsequestion 
-    # has the correct response, e.g.
+    # 1. Make sure that if an answer that has a subquestion is answered that
+    # the subquestion has an answer, e.g.
+    #
     # Select your skills
     # Banker
     # Builder
     # ...
     # Other
     #    Please specify
-    # We want to make sure 'Other' was selected if the 'Please specify'
+    # We want to make sure that if 'Other' was selected the 'Please specify'
     # subquestion has an answer
-    # 
-    # Check if this subquestion has an answer
-    if (smerf_question_answered?(question, responses))
-      # Check if the correct answer selected
-      if (!smerf_question_has_answer?(question_object, responses, answer_code))
-        return &quot;'#{answer_object.answer}' needs to be selected&quot;
-      end  
-    end
-    
-    # 2. Make sure that if an answer that has a subquestion is answered that
-    # the subquestion has an answer, e.g.
     #
+    # Check if the answer this subquestion relates to has been answered
+    if (smerf_question_has_answer?(question_object, responses, answer_code))
+      # Make sure the subquestion has been answered
+      if (!smerf_question_answered?(question, responses))
+        return &quot;'#{answer_object.answer}' needs additional information&quot;
+      end
+    end
+
+    # 2. Make sure that the answer that relates to this subsequestion
+    # has the correct response, e.g.
     # Select your skills
     # Banker
     # Builder
     # ...
     # Other
     #    Please specify
-    # We want to make sure that if 'Other' was selected the 'Please specify'
+    # We want to make sure 'Other' was selected if the 'Please specify'
     # subquestion has an answer
     # 
-    # Check if the answer this subquestion relates to has been answered
-    if (smerf_question_has_answer?(question_object, responses, answer_code))
-      # Make sure the subquestion has been answered
-      if (!smerf_question_answered?(question, responses))
-        return &quot;'#{answer_object.answer}' needs additional information&quot;
-      end        
+    # Check if this subquestion has an answer
+    if (smerf_question_answered?(question, responses))
+      # Check if the correct answer selected
+      if (!smerf_question_has_answer?(question_object, responses, answer_code))
+        # Check if a different answer provided, if so clear subquestion answer
+        # and notify user. This allows a subquestion to be cleared if the user
+        # decided they want to select a non-subquestion answer.
+        if (smerf_question_answered?(question_object, responses) &amp;&amp; question.type == 'singlechoice')
+          # Clear subquetion answers
+          responses.delete(question.code)
+          return &quot;Ambiguous answer provided for question '#{question_object.question.strip}', the answers to this question has been cleared&quot;
+        else
+          return &quot;'#{answer_object.answer}' needs to be selected&quot;
+        end
+      end  
     end
     
     return nil</diff>
      <filename>lib/smerf_system_helpers.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9be23171633eaa8fbb4723a03af48cb72c9797cd</id>
    </parent>
  </parents>
  <author>
    <name>Etienne van Tonder</name>
    <email>etiennevt@gmail.com</email>
  </author>
  <url>http://github.com/springbok/smerf/commit/79e061ecfd674870ba4465b8e9a50da4b1ed521b</url>
  <id>79e061ecfd674870ba4465b8e9a50da4b1ed521b</id>
  <committed-date>2009-05-07T20:36:10-07:00</committed-date>
  <authored-date>2009-05-07T20:36:10-07:00</authored-date>
  <message>When dealing with subquestions of type singlechoice it was not possible for the user to clear previously selected answers if they decided to select a non-subquestion answer. SMERF will now check to see if a non-subquestion answer was selected and if the subquestion type is singlechoice it will clear the answers of the subquestion. Additionally it will display an error message to inform the user of the ambiguous answer, here is an example error message: Are you aged over 40: Ambiguous answer provided for question 'Specify your ages', the answers to this question has been cleared.</message>
  <tree>9ee1b1678f68ffcb64196f64957d01012601e24f</tree>
  <committer>
    <name>Etienne van Tonder</name>
    <email>etiennevt@gmail.com</email>
  </committer>
</commit>
