package org.adaptlab.chpir.android.survey.questionfragments;

import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RatingBar;

import org.adaptlab.chpir.android.survey.QuestionFragment;

public class RatingQuestionFragment extends QuestionFragment  {
    private final static int NUM_STARS = 5;
    private float mRating;
    private RatingBar mRatingBar;

    @Override
    protected void createQuestionComponent(ViewGroup questionComponent) {
        mRatingBar = new RatingBar(getActivity());
        mRatingBar.setNumStars(NUM_STARS);
        mRatingBar.setLayoutParams(new ViewGroup.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        mRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {       
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                mRating = rating;
                setResponseText();
            }
        });
        questionComponent.addView(mRatingBar);
    }

    @Override
    protected String serialize() {
        return String.valueOf(mRating);
    }

    @Override
    protected void deserialize(String responseText) {
        if (!responseText.equals("")) {
            mRating = Float.parseFloat(responseText);
            mRatingBar.setRating(mRating);
        }
    }

    @Override
    protected void unSetResponse() {

    }
  
}

@@ -55,16 +55,75 @@
 ments;%0A%0A
+import android.view.MotionEvent;%0Aimport android.view.View;%0A
 import a
@@ -1115,16 +1115,339 @@
     %7D);%0A
+        mRatingBar.setOnTouchListener( new View.OnTouchListener()%7B%0A            @Override%0A            public boolean onTouch(View v, MotionEvent event)%7B%0A                if(mSpecialResponses!=null)%7B%0A                    mSpecialResponses.clearCheck();%0A                %7D%0A                return false;%0A            %7D%0A        %7D);%0A
         
@@ -1485,16 +1485,16 @@
 ngBar);%0A
-
     %7D%0A%0A 
@@ -1865,16 +1865,127 @@
 ) %7B%0A
+        mRatingBar.setRating(0);%0A        if (mResponse != null) %7B%0A            mResponse.setResponse(%22%22);%0A        %7D
 %0A    %7D%0A
-  %0A
 %7D%0A

Implement and test the unSetResponse function in the RatingQuestionFragment