# Survey creation

**URL:** <https://discourse.processing.org/t/survey-creation/31453>\
**Category:** Coding Questions\
**Created:** [July 26, 2021, 7:29pm UTC](https://discourse.processing.org/t/survey-creation/31453 "2021-07-26T19:29:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![coderdoge](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@coderdoge](https://discourse.processing.org/u/coderdoge)\
**Post date:** [July 26, 2021, 7:29pm UTC](https://discourse.processing.org/t/survey-creation/31453/1 "2021-07-26T19:29:08Z")

</div>

Hi all,  
I have started a new project in which I want to make a survey using processing. My idea was to insert shapes as multiple choice selection tools and text as the question itself. I’ve been struggling to formulate this, however, so I came here to ask a rough example of a survey with like an example question?  
Thanks,  
Doge

---

<div class="post-metadata">

**Author:** ![coderdoge](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@coderdoge](https://discourse.processing.org/u/coderdoge)\
**Post date:** [July 26, 2021, 7:30pm UTC](https://discourse.processing.org/t/survey-creation/31453/2 "2021-07-26T19:30:17Z")

</div>

Also I am relatively experienced in Java programming but not so much in Processing.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 26, 2021, 10:11pm UTC](https://discourse.processing.org/t/survey-creation/31453/3 "2021-07-26T22:11:20Z")

</div>

```auto

// list of questions
ArrayList<Question> questions = new ArrayList();

// current
int questionNumber=0;

void setup() {
  size (900, 400);
  textSize(14);

  // make list 
  String[] a1={"wee", "wwddx", "sdf", "sdf", "sdf", "YES", "no."};
  String[] a2={"awwwwee", "aaawwddx", "asdf", "asdf", "sdf", "YES", "no."};
  String[] a3={"bbbbbawwwwee", "bbbbbbaaawwddx", "bbbbasdf", "asdf", "sdf", "YES", "no."};

  questions.add ( new Question("Does it rain?", a1, 40, 40));
  questions.add ( new Question("Did it?", a2, 40, 40));
  questions.add ( new Question("Ask?", a3, 40, 40));
}

void draw() {
  background(0);

  if (questionNumber<questions.size()) {
    Question q1 = questions.get(questionNumber); 
    q1.display();
  } else {
    text("Test is over", 
      333, 333);
  }
}

// -------------------------------------------------------------------

void mousePressed() {

  // end ? 
  if (questionNumber>=questions.size()) {
    return;
  }

  //submit 
  if (mouseX>width/2) {
    questionNumber++;
    return;
  }

  // check input
  Question q1 = questions.get(questionNumber) ; 
  q1.checkMouse();
}

// =========================================================================

class Question {
  //
  String text1;

  float x;
  float y;

  ArrayList<Button> buttons = new ArrayList();

  //constr 
  Question (String t1_, 
    String[] a1, 
    float x_, float y_ ) {

    text1 = t1_;

    x=x_;
    y=y_;

    for (int i = 0; i < 6; i++) {
      buttons.add ( new Button( a1[i], 66, 32*i+66 ));
    }
  }//constr 

  void display() {
    fill(255);
    text (text1, x-10, y-10);

    for (Button b1 : buttons) {
      b1.display();
    }

    textSize(89); 
    text ("SUBMIT", 
      width/2, height-222);
    textSize(14);
  }

  void checkMouse() {
    Button b2=null;
    boolean foundOne = false; 
    for (Button b1 : buttons) {
      if (b1.checkMouse()) {
        b1.isOn=true;
        b2=b1; 
        foundOne=true;
      }//if
    }//for
    if (foundOne) {
      for (Button b1 : buttons) {
        b1.isOn=false;
      }
      b2.isOn=true;
    } // if
  }// func
}

// ====================================================================

class Button {
  //

  String possibleAnswer; 

  float x;
  float y;
  float sizeButton = 10; 
  boolean isOn = false;  

  //constr 
  Button ( String t1_, 
    float x_, float y_ ) {

    possibleAnswer = t1_; 

    x=x_;
    y=y_;
  }//constr 

  void display() {
    if (isOn) {
      fill(255);
    } else {
      fill(0);
      stroke(255);
    }
    rect(x, y, sizeButton, sizeButton);
    fill(255);
    text(possibleAnswer, x+22, y+11);
  }

  boolean checkMouse() {
    if (dist(mouseX, mouseY, 
      x+sizeButton/2, y+sizeButton/2) < 20)
      return true;
    else
      return false;
  }
}//class
//

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 27, 2021, 10:05am UTC](https://discourse.processing.org/t/survey-creation/31453/4 "2021-07-27T10:05:19Z")

</div>

Hello @coderdoge,

Welcome to the forum.

> [@coderdoge](#):
>
> Also I am relatively experienced in Java programming but not so much in Processing.

[Processing in Java](https://happycoding.io/tutorials/java/processing-in-java) \< Has a section called _Processing is Java_

One of the best tools in a programmers tool chest is knowing the resources available to you and learning to navigate and use them.

I encourage you to review the resources available here:

- The Processing _website_ has references, examples, tutorials, etc.  
[https://processing.org/](https://processing.org/)
- The Processing PDE (IDE) has lots to offer!  
An exploration of the menus will reveal what is available; libraries, tools and local examples there.
- The Coding Train  
[https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
[https://thecodingtrain.com/](https://thecodingtrain.com/)  
Once you to get past his opening “Whoops” video there is a lot to explore!
- Happy Coding  
[Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)
- The source code can give insight if you are adventurous:  
[GitHub - processing/processing: Source code for the Processing Core and Development Environment (PDE)](https://github.com/processing/processing)  
Many of the Processing functions are here:  
[processing/core/src/processing/core/PApplet.java at master · processing/processing · GitHub](https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java)
- And the Internet. `:)`

Have fun!

`:)`

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 27, 2021, 12:33pm UTC](https://discourse.processing.org/t/survey-creation/31453/5 "2021-07-27T12:33:50Z")

</div>

That’s only the beginning of course

You need to record the answers (for example in the first class)

And make submit a real button

Give a result screen maybe

And a start screen with Headline and Explanation

---

<div class="post-metadata">

**Author:** ![coderdoge](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@coderdoge](https://discourse.processing.org/u/coderdoge)\
**Post date:** [July 27, 2021, 6:14pm UTC](https://discourse.processing.org/t/survey-creation/31453/6 "2021-07-27T18:14:58Z")

</div>

thank you so much, this really helps me out! Also, is there a possible way for a survey like this one to be opened up via something like a discord link or an email link? Thanks again

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 27, 2021, 6:31pm UTC](https://discourse.processing.org/t/survey-creation/31453/7 "2021-07-27T18:31:32Z")

</div>

> [@coderdoge](#):
>
> s really helps me out! Also, is there a possible way for a survey like this one to be opened up via something like a discord link or an email link? Thanks again

yeah sure, you need to put it on a website then.
