Code Monkey home page Code Monkey logo

questionnaire's Introduction

Questionnaire

This is a demo application which will help to make Questionnaire (Survey, Feedback, Poll, Filter, Exam, Questions) for users in your App.

This project got inspiration from this repo -> https://github.com/AndreiD/surveylib

alt text

Let see what you will learn from this Project.

  • How to use Room (part of Android Architecture Components ).
  • How to use simple Background process with RxJava (RxAndroid) or we say how to replace Async task with RxJava.
  • Parcelable with Nested Model (as List of Model inside Model) in Pojo.
  • Other various logic building.

Situations: (When its helpful to use/refer this Project)

  • This project only works with situations where You have Multiple/Single Choice(s) based questions.(If more variation needed, refer AndreiD's work)

  • If you want persistence with the previous selection of choice(s), means user can go back and modify the selection and previous selections will not lose there state.(This is addition feature in this Project)

  • What if you don't want or submit the result of Questionnaire as soon the completion. Means if there is other work(s) before sending the data to back-end, and also you don't want to hanging with result in between Activities. See the AnswerActivity , how to retrieve the result from database and display/send. (This is addition feature in this Project)

Want to send result in Json format see the AnswerActivity.java
/*Here,JSON got created and send to make Result View as per Project requirement.
* Alternatively, in your case, you make Network-call to send the result to back-end.*/
private void makeJsonDataToMakeResultView()
{
  try
  {
     JSONArray questionAndAnswerArray = new JSONArray();
     int questionsSize = questionsList.size();
     if (questionsSize > 0)
	  {
		  for (int i = 0; i < questionsSize; i++)
		  {
             JSONObject questionName = new JSONObject();
             questionName.put("question",questionsList.get(i).getQuestion());
            //questionName.put("question_id",String.valueOf(questionsList.get(i).getQuestionId()));
             String questionId = String.valueOf(questionsList.get(i).getQuestionId());

            JSONArray answerChoicesList = new JSONArray();
            int selectedChoicesSize = questionsWithAllChoicesList.size();

            for (int k = 0; k < selectedChoicesSize; k++)
             {
                String questionIdOfChoice = questionsWithAllChoicesList.get(k).getQuestionId();
                if (questionId.equals(questionIdOfChoice))
                 {
                     JSONObject selectedChoice = new JSONObject();
                     selectedChoice.put("answer_choice", questionsWithAllChoicesList.get(k).getAnswerChoice());
                    //selectedChoice.put("answer_id", questionsWithAllChoicesList.get(k).getAnswerChoiceId());
                     answerChoicesList.put(selectedChoice);
                 }
             }

            questionName.put("selected_answer", answerChoicesList);

            questionAndAnswerArray.put(questionName);
          }
      }
		  questionsAnswerView(questionAndAnswerArray);

  } catch (JSONException e)
	 {
		  e.printStackTrace();
	 }
}

If you found helpful and learnt something new from this work, please star this project.

License

Copyright 2018 Shashi Prasad Kushwaha

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.

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.