Giter VIP home page Giter VIP logo

surveylib's Introduction

Android Survey

Android Arsenal

Sadly, I don't have time to maintain this. If you'd like to be a maintainer, drop me a message in an issue !

Special thanks to https://github.com/howettl for his contribution.

A simple to use, survey library for collecting feedback from your users.

alt text

Instalation:

compile 'com.androidadvance.surveylib:surveylib:0.0.1'

How to use it:

  1. Take a look at the example project
Step 1:

You will need: A json file with the questions. Check the assets folder to see 3 examples.

Step 2:

Call the class SurveyActivity and pass as an extra the json string.

        private static final int SURVEY_REQUEST = 1337;
        a_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i_survey = new Intent(MainActivity.this, SurveyActivity.class);
                i_survey.putExtra("json_survey", loadSurveyJson("example_survey_1.json"));
                startActivityForResult(i_survey, SURVEY_REQUEST);
            }
        });

What is loadSurveyJson ? check this function.

Step 3:

The activity is started with a request code.

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == SURVEY_REQUEST) {
            if (resultCode == RESULT_OK) {

                String answers_json = data.getExtras().getString("answers");
                Log.d("****", "****************** WE HAVE ANSWERS ******************");
                Log.v("ANSWERS JSON", answers_json);
                Log.d("****", "*****************************************************");

                //do whatever you want with them...
            }
        }
    }
Last step:

Add this activity to your manifest file.

<activity android:name="com.androidadvance.androidsurvey.SurveyActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:windowSoftInputMode="stateHidden"/>
The Json format of the Questions.

You have couple of question types: String, StringMultiline, Number, Radioboxes, Checkboxes. They can be "required" or not, the choices can be random. Check the examples, everything is simple to use.

Customizations
Colors

Use html codes in your json question title, choices. You can see a compiled list here

Define your material design colors in the style.

Not enough ? You have to do it yourself. Simplest way is to Fork this project and style, add, modify who you like.

More question types / Other Stuff

Fork this project

Troubleshooting

  1. Make sure you have the latest shit. At this moment: compileSdkVersion 23, targetSdkVersion 23, buildToolsVersion "23.0.1", compile 'com.android.support:appcompat-v7:23.1.0', compile 'com.android.support:design:23.1.0' etc.
  2. Feed a valid json! Otherwise you'll get errors.
  3. Check the sample project.

Updates, Questions, and Requests

Ping me here :)

TODO://

  • Offline mode storage.
  • Sync with server example.
  • Adding a sliding bar / stars question type
  • Waiting for your suggestions

You like this library ? Check my other projects.

If you use this library, please star this project.

License

Copyright 2015 AndroidAdvance.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

surveylib's People

Contributors

andreid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

surveylib's Issues

Litle Update your code

hi Andre,
many thanks for your library for suvey

i was modified your code to get more better survey and can save to databse..
this output for my modified
"survey_properties": {
"intro_message": "Your feedback helps us to build a better mobile product.


Hello, Feedback from our clients, friends and family is how we make key decisions on what the future holds for XYZ App.

By combining data and previous feedback we have introduced many new features e.g. x, y, z.

It will take less than 2 minutes to answer the feedback quiz.",
"end_message": "Thank you for having the time to take our survey.",
"skip_intro": false
},
"questions": [
{
"question_type": "Checkboxes",
"question_id": 3,
"question_title": "Do you currently use one of these other software solutions?",
"description": "",
"required": false,
"random_choices": true,
"choices": [
{
"idChoice": 1,
"valueChoice": "Yes, I use a red product"
},
{
"idChoice": 2,
"valueChoice": "I use a green product"
},
{
"idChoice": 3,
"valueChoice": "I partialy use a blue product"
}
]
},

{
  "question_type": "String",
  "question_id": 4,
  "question_title": "Why did you not subscribe at the end of your free trial ?",
  "description": "",
  "required": false
},
{
  "question_type": "Radioboxes",
  "question_id": 2,
  "question_title": "What is your age group ?",
  "description": "",
  "required": true,
  "random_choices": false,
  "choices": [
    {
      "idChoice": 1,
      "valueChoice": "less than 20"
    },
    {
      "idChoice": 2,
      "valueChoice": "20-30"
    },
    {
      "idChoice": 3,
      "valueChoice": "30-40"
    },
    {
      "idChoice": 4,
      "valueChoice": "40-50"
    },
    {
      "idChoice": 5,
      "valueChoice": "50+"
    }
  ]
},
{
  "question_type": "Checkboxes",
  "question_id": 1,
  "question_title": "What were you hoping the XYZ mobile app would do?",
  "description": "(Select all that apply)",
  "required": false,
  "random_choices": false,
  "choices": [
    {
      "idChoice": 1,
      "valueChoice": "thing #1"
    },
    {
      "idChoice": 2,
      "valueChoice": "thing #2"
    },
    {
      "idChoice": 3,
      "valueChoice": "thing #3"
    },
    {
      "idChoice": 4,
      "valueChoice": "thing #4"
    }
  ]
},
{
  "question_type": "Radioboxes",
  "question_id": 2,
  "question_title": "What is your age group ?",
  "description": "",
  "required": true,
  "random_choices": false,
  "choices": [
    {
      "idChoice": 1,
      "valueChoice": "less than 20"
    },
    {
      "idChoice": 2,
      "valueChoice": "20-30"
    },
    {
      "idChoice": 3,
      "valueChoice": "30-40"
    },
    {
      "idChoice": 4,
      "valueChoice": "40-50"
    },
    {
      "idChoice": 5,
      "valueChoice": "50+"
    }
  ]
},

{
  "question_title": "If this app was paid, how much you would give to have it ?",
  "question_id": 5,
  "description": "",
  "required": false,
  "question_type": "Number"
},
{
  "question_id": 6,
  "question_title": "berapa istri yang sudah kamu miliki ?",
  "description": "jelaskan dengan detail ",
  "required": true,
  "question_type": "Number"
},
{
  "question_id": 7,
  "question_type": "StringMultiline",
  "question_title": "We love feedback and if there is anything else you’d like us to improve please let us know.",
  "description": "",
  "required": false,
  "number_of_lines": 4
}

]

****************** WE HAVE ANSWERS ******************
androidadvance.com.androidsurveyexample E/ANSWERS JSON: [{"Answer":[{"idChoice":"2","selected":true,"valueChoice":"I use a \u003cfont color\u003d\u0027#00AA00\u0027\u003egreen product\u003c/font\u003e"},{"idChoice":"1","selected":true,"valueChoice":"\u003cfont color\u003d\u0027#AA0000\u0027\u003eYes, I use a \u003cstrong\u003ered\u003c/strong\u003e product\u003c/font\u003e"}],"Ask":"Do you currently use one of these other software solutions?","idAsk":"3"},{"Answer":[{"idChoice":"2","selected":true,"valueChoice":"I use a \u003cfont color\u003d\u0027#00AA00\u0027\u003egreen product\u003c/font\u003e"},{"idChoice":"1","selected":true,"valueChoice":"\u003cfont color\u003d\u0027#AA0000\u0027\u003eYes, I use a \u003cstrong\u003ered\u003c/strong\u003e product\u003c/font\u003e"}],"Ask":"Do you currently use one of these other software solutions?","idAsk":"3"},{"Answer":[{"idChoice":"0","selected":false,"valueChoice":"Qw"}],"Ask":"Why did you not subscribe at the end of your free trial ?","idAsk":"4"},{"Answer":[{"idChoice":"1","selected":false,"valueChoice":"less than 20"}],"Ask":"What is your age group ?","idAsk":"2"},{"Answer":[{"idChoice":"2","selected":true,"valueChoice":"thing #2"}],"Ask":"What were you hoping the XYZ mobile app would do?","idAsk":"1"},{"Answer":[{"idChoice":"3","selected":false,"valueChoice":"30-40"}],"Ask":"What is your age group ?","idAsk":"2"},{"Answer":[{"idChoice":"0","selected":false,"valueChoice":"4"}],"Ask":"If this app was paid, how much you would give to have it ?","idAsk":"5"},{"Answer":[{"idChoice":"0","selected":false,"valueChoice":"1"}],"Ask":"berapa istri yang sudah kamu miliki ?","idAsk":"6"},{"Answer":[{"idChoice":"0","selected":false,"valueChoice":"qwerty\ndggg"}],"Ask":"We love feedback and if there is anything else you’d like us to improve please let us know.","idAsk":"7"}]
androidadvance.com.androidsurveyexample E/****: *****************************************************
so i can get the id of question and answer from output json.
can you add fragment for take a picture.. or if you bussy i will create my self

your save my time

Example for specifying style

Looking through the code, it seems I can pass in a style string but there is no format specified for this string.

Can you please provide a sample?

I would like to change the default color of the button, background and question text.

more features

first of all, I'm so thankful to see your work done. great job! This lib looks promising. Is it possible to adding selection choices and pop up input based on previous selections?

help

I would like the answers to be added to a firebase database

Keyboard appears in multichoice

Hi, In the examplejson1, in the third page, the keyboard appears, even if there is nothing to write. What you write apperars in the next page, that is indeed string type

NullPointer on 10th question

I have 20 questions and it seems to crash once I 'submit' the 10th. I've moved questions around and it continues to work until the 10th question so I don't think it's a formatting error. Works perfectly up until that point and I've tested with less than 10 questions and the answers are output as expected.
Any ideas?

07-20 15:19:47.342 9834-9834/com.example.litrans.carboncount E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.litrans.carboncount, PID: 9834
    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
        at java.io.StringReader.<init>(StringReader.java:50)
        at android.text.HtmlToSpannedConverter.convert(Html.java:746)
        at android.text.Html.fromHtml(Html.java:242)
        at android.text.Html.fromHtml(Html.java:185)
        at com.androidadvance.androidsurvey.fragment.FragmentRadioboxes.onActivityCreated(FragmentRadioboxes.java:103)
        at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2363)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1442)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
        at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2199)
        at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1236)
        at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:662)
        at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:624)
        at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:605)
        at com.androidadvance.androidsurvey.SurveyActivity.go_to_next(SurveyActivity.java:128)
        at com.androidadvance.androidsurvey.fragment.FragmentRadioboxes$1.onClick(FragmentRadioboxes.java:50)
        at android.view.View.performClick(View.java:6294)
        at android.view.View$PerformClick.run(View.java:24770)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

How to reset Answer Data after submitting results

Hi,
I have a problem with clearing the Answer Data after I have submitted the survey results and go back to do a new survey. The data is persistent and keeps on adding I just cannot work out how to clear this data and start a completely new survey.

Finally thanks for creating this useful library.
It has been a real time saver.

Description doesn't appear

Hi,
in the example example1.json, there is a description "(Select all that apply)", that actually doesnt' appear in the survey. Is it maybe that the font color is the same as the background? (white).

UPDATE as @CrandellWS pointed out, it's just that it is not implemented. It should be in FragmentCheckBoxes.java and its xml. Thanks

� is appeared when after gson.tojson when using utf-8

I am using realm to store and retrieve utf-8 for nepali(Devnagari) characters but when retrieving � is also generating which is not a nepali(Devnagari) character and not stored. How to solve this issue? Along with realm I have used Gson and retrofit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.