Jump to content


Photo

Php Mock Version Of Google Forms

php google forms

  • Please log in to reply
20 replies to this topic

#1 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 27 December 2012 - 02:24 PM

I'm interested in creating online forms in a similar fashion that Google allows whenever using Google Docs, but with greater functionality and reliability. (A problem that I have experienced when creating forms by Google is that it doesn't handle a large number of questions very well, either freezing up or not saving new questions upon form creation. Other times, I have heard complaints where a user may have spent a good bit of time filling out a form only to discover that it wasn't saved upon clicking the submit button like it should have been.)

For example, I might create questions looking like this:

Page 1

1. ) Do you eat any meat? ( ) Yes ( ) No


Page 2

What kind of meats do you eat?

2.) Beef Yes [ ] No [ ]

3.) Pork Yes [ ] No [ ]

4.) Veal Yes [ ] No [ ]


Using Google Forms, I'd then indicate if the user says they don't eat ANY meat, then skip the section on specific types of meat they might eat, which is fine when dealing with a small number of questions, but not for a large number. What I want to be able to do is create a large number of questions in this manner without worrying about the technology I'm using holding me back.

Another function that I am interested that isn't really a part of Google Forms is having one user's answers relate to anothers so that say if, using the above example, another user indicates they are a vegetarian and then in a follow-up question, indicate that they can not live with anyone that eats meat, that it is reflected in a compatibility summary.

So it's basically being able to post an almost unlimited number of questions to a website that are displayed in a very systematic fashion, and be able receive an almost unlimited number of submissions in the most easy, and economical way that I'm interested in.

I thought PHP, Apache, and MySQL would be a good choices because they are widely supported, open source and free. I was also thinking these would be easier to learn these than some of the other choices out there, or should be cheaper to pay someone else to set up if they so widely supported. I've also read that PHP is rarely used alone, and am unsure of what might compliment it well for what I'm wanting to use it for. Any advice?

#2 trq

trq

    Advanced Member

  • Administrators
  • 31,005 posts
  • LocationSydney, Australia.

Posted 27 December 2012 - 04:30 PM

Any advice?



Learn to walk before you try to run. PHP is a programming language, and as such, you need to learn how to program to use it successfully.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.


#3 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 27 December 2012 - 04:42 PM

Well, would there be anything helpful for me to keep in mind as I am learning PHP given the stated goals?

#4 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 27 December 2012 - 05:30 PM

Data Normalization, which is related to your DB, not PHP.
Sessions.
Pagination.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#5 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 27 December 2012 - 05:39 PM

Data Normalization, which is related to your DB, not PHP.
Sessions.
Pagination.


No PHP at all? Are "sessions" and "pagination" database related topics or PHP related topics?

#6 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 27 December 2012 - 05:41 PM

That's weird, it doesn't seem like that was enough time for you to google those phrases... ;)
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#7 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 27 December 2012 - 05:55 PM

Oddly enough, I did click on the link "What does that term mean?" to reach Google, and started to type "Sessions" but thought the results I would get back would be a too ambiguous to be helpful as the word "sessions" has more than one meaning outside of a programming context, and although I am no expert, would suspect probably more than one meaning even within a programming context. Hence the idea of checking with the original source might be more helpful than a Google search in that particular case.

Although, I'll admit, I did find something on "pagination" through Google, which lead to what appeared to be a helpful Wikipedia article.

#8 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 27 December 2012 - 07:40 PM

Sessions in the PHP manual.
Keeping it simple.

#9 KevinM1

KevinM1

    Snarkimus Prime

  • Moderators
  • 5,224 posts
  • LocationNew Hampshire, USA

Posted 27 December 2012 - 08:17 PM

Data Normalization: people tend to treat relational (notice that it's in italics) databases as Excel spreadsheets. That's exactly the wrong way to use them. The way to go is to normalize data so it can relate to itself/other data in a way that eliminates insertion and deletion headaches.

Sessions: HTTP is stateless, meaning there's nothing inherent in it that can remember things. Take this forum: it 'remembers' that you're logged in when you go from page to page. That remembrance is facilitated (in part) by sessions.

Pagination: Breaking long lists of items into manageable pages.

---

Data normalization is primarily a database concern, although it will affect how you write queries. Sessions are baked into PHP (and just about any other language that deals with HTTP on a regular basis) and are trivial to use, and can be modified a bit according to your needs. Pagination is really an algorithm. You'll use PHP to write it, but it's not dependent on PHP.

#10 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 27 December 2012 - 08:44 PM

Obviously there is more he'll need to know about, those were just the first "difficult" topics that came to my mind when reading the project.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#11 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 28 December 2012 - 04:11 AM

Thanks for the feedback.

"Data normalization" is a topic I vaguely recall from having to set up simple databases in Access for school projects. "Sessions" and "pagination" were topics unfamiliar to me, perhaps because they are advanced topics not easily understood by newbies in terms of technical detail, but would seem easy enough to understand in terms of end user experience. (For example, I don't like how Facebook uses ajax to incrementally load up timelines, and search results because I have to wait after I've scrolled down as opposed to having what I want to see already there. And yes, it may save bandwidth, but on some sites, like on a simple quiz engine like site, I'm not sure that it really matters.)

#12 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 28 December 2012 - 09:41 AM

That dynamic loading of the timeline using AJAX has nothing to do with sessions, well.. Other than the fact that it uses a session to recognize your browser across the different requests, so that it knows what timeline to display.

The basic principle of sessions very simple: The server gives the client an ID, which the client uses for each request sent to the server. That way the server can identify the client, despite the protocol itself (HTTP) being stateless (each request are completely independent from the others).
Keeping it simple.

#13 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 28 December 2012 - 09:42 AM

Christian. Pagination. ::)
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#14 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 28 December 2012 - 10:00 AM

Oh... Ups. Sorry, I misunderstood. :-[
Keeping it simple.

#15 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 28 December 2012 - 10:55 AM

Oh... Ups. Sorry, I misunderstood. :-[



Thanks for the additional information on sessions though. I've generally thought of online sessions in terms of timeouts due to account inactivity. For example, you log into your bank account, walk away from your computer, and after a period of time the website automatically logs you out, except with my particular project, I'm thinking the aspect of sessions I need to be more so concerned about is how often is data saved.

The problem I had with Google forms is that if a user answers 100 of 100 questions, that it doesn't go through unless they hit the "submit" button at the very end of the form, signifying to me that Google Forms aren't really built for handling large numbers of questions. A more reasonable interval would be saving data at every ten or so questions. That way if there is some sort of interruption or the form isn't completely filled out for some reason, not everything is completely lost.

As for pagination, I'd imagine something simple should suffice where related questions are broken up into small, manageable batches with the goal of eliminating the need for scrolling, and having navigation by a simple "back" and "next" button on each screen of questions as opposed to page numbers. Such a set up would make ajax unnecessary I would think.

Whether or not these assumptions are correct, I guess I will find out when I get to learning more advanced topics such as "sessions" and "pagination" in depth. For now, after getting an overview of the types of tutorials that are out there, what it would seem like I need to pay particular attention to at a beginner's level are things like HTML and PHP Form handling, and setting up MySQL (which calls for a review of database normalization principles).

#16 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 28 December 2012 - 11:02 AM

From what I see, your assumptions are indeed quite correct. At least for your intended use. :)

Not only is it easier to save the progress under way when splitting the forum up in X pages of Y questions, but it'll also make it easier for those who're actually replying to said questionnaire.
Keeping it simple.

#17 cpd

cpd

    ¬_¬

  • Members
  • PipPipPip
  • 892 posts
  • LocationLondon, UK

Posted 29 December 2012 - 07:36 AM

I don't want to put down what Jessica has recommended because they are valid topics to look up but Pagination itself is a fairly basic task that requires simple PHP syntax. I wouldn't research "pagination" but instead perhaps use it as a method for learning PHP, or rather basic programming skills. Try not to concentrate on learning how to write specific systems/tasks but instead use them to learn PHP syntax, basic control flow statements, loops etc so you can then apply it to any scenario.

Research programming control flow e.g. if statements; loops e.g. a for loop; arrays; what a constant is; classes and objects and much more. Choose a task, such as pagination, and try to do it using what you've found.

Edited by CPD, 29 December 2012 - 07:37 AM.

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."

#18 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 29 December 2012 - 11:25 AM

Not only is it easier to save the progress under way when splitting the forum up in X pages of Y questions, but it'll also make it easier for those who're actually replying to said questionnaire.


I agree.

#19 Psychology_Student

Psychology_Student

    Newbie

  • New Members
  • Pip
  • 9 posts

Posted 29 December 2012 - 11:32 AM

Try not to concentrate on learning how to write specific systems/tasks but instead use them to learn PHP syntax, basic control flow statements, loops etc so you can then apply it to any scenario.



In the long run, I think having a general, well-rounded knowledge of web programming would be in my best interests if I wanted to maintain a website based upon it. However, my interest at the particular moment is in simply creating a bare bones development environment, where I focus minimally on programming at first as to work more on content development, and then once I have something I consider worth coding around, then focus on the web programming part.

Originally, I was using Google's drag and drop interface on Google Forms to create questionnaires. That seemed easy enough at first, and would allow me to preview how a form, or questionnaire would look once I was ready to launch it live. However, I soon learned that trying to create a large number of questions on Google Forms this is cumbersome at best, as the drag and drop interface will eventually freeze up, or not save new questions if there already are many. (Then there is of course the problem with users not always being able to complete a submission as well.)

That's when I considered just trying to develop content by typing questions and answer choices in a word processor program, but the problem I found with this is that word processor programs do not do a very good job of simulating the look and feel of a database driven website as to help better visualize how things look and work within one.

So that has brought me to the point of trying to learn just enough PHP to create a mock version of Google Forms with the intention of learning more as I go along. Currently, I have WAMP installed as to be able to run PHP code locally after viewing a PHP tutorial, and am in the process of getting acquainted with MyPHPAdmin.

I'm thinking on the most basic level, I need to know PHP syntax of course, then PHP and HTML form handling, then how to use PHP if statements with regard to the answer choices of some of the questions I'd want to ask, then maybe PHP arrays for posting a group of related questions that share the same answer choices (not sure about that one), and then how I want this information stored into MySQL. That, I'm hoping, should suffice for creating a bare bones development environment until I am ready to take things to the next level, and focus on more advanced topics such as those related to security, and other things, (where having a more developed and well-rounded knowledge of programming, I'd imagine probably comes quite in handy).

#20 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 29 December 2012 - 12:06 PM

You'll want to look into sessions as well, for storing the answers between page loads. Or, more specifically, identifying a user across multiple page views. ;)
Keeping it simple.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com