Adding front-end functionality to a PHP and MySQL driven Quiz application - php

I recently built a quiz web application using PHP and MySQL (www.ReadySetQuiz.ME) The format looks something like this:
When did we declare Independence from the British?
1775
1777
1776
1774
The Louisiana Purchase was an aquisition from which country?
England
France
Spain
Germany
The answers are a list of radio buttons. After you answer all the questions you hit the submit button and it shows how many you got correct and a breakdown of each question: whether you chose the correct answer (if not, which was the correct answer) and a distribution of previous users' choices.
One big problem I'd like to solve with this current quiz design is people can just open another tab in their browser and Google the answer. I'd like to only show 1 problem at a time and add a time limit to encourage quick responses, and consequently, eliminate the aforementioned problem.
So, I'm looking for some input/guidance - big picture (50,000 feet). How do I make it so one question is presented at a time and users only have a few seconds to answer the question? Do I use JavaScript? Are there any new improvements in HTML5 that can help me accomplish something like this? I'm really just looking for what I need to learn next. Thanks for your time!

Question1) How do I make it so one question is presented at a time and users only have a few seconds to answer the question?
You need to use a countdown/timer to present the user for a minute of less.
Question 2) Do I use JavaScript?
Yeah you can use javascript and use jQuery to make your life easier.
Also disabling right click menu and text selection in the browser window (using js) will make it difficult for the user to just copy the keyword and paste it in a new browser and search. So if they will have to type the question/keywords it will take time.

Related

PHP/ajax table and Google results

A couple years ago I had a client with a limited budget and a short deadline who wanted a sortable searchable table of their parts inventory online - at the time they had only an excel spreadsheet. I created a database, then I just used Script Artist (because I had it) to do the front end. It all works great and he's been happy with it, except now we'd like to make sure that Google can actually find all 17,000+ parts they have available and not just the first 25.
The page where the inventory is located is just www.thesite.com/inventory.php and the url remains the same no matter what page you're on.
I've been looking around at different options, using pushState vs html snapshots, and I'm not sure what would be the best option or if I can even do anything with the current Script Artist setup or if I should just pitch the whole thing. I'd really rather not have to start over since he still doesn't have much of a budget, so if anyone could give me any input that would be helpful. Thanks.

Generating an image from pre-existing ones?

This is kinda confusing, so forgive me if you don't understand what I am asking. I'm trying to develop my skills and I wanted to move onto images as a next step. I did a bit of searching and I thought a good way to try this would maybe be to generate military ribbon racks depending on the options the user selects.
(See something like this as an example: http://www.ribbon-rack-builder.com/ribbons/build/4)
Now, from looking at the source code I can see that the creator of that website creates a form with all of the different ribbons and allows the user to select the ones they want with checkboxes. This form is then posted to some PHP on the page somewhere.
Being new to the image concept I have no idea what kind of PHP this would be. Could anyone give me an idea of how this website could do this and where I should start should I want to create something similar?
Thanks very much!
First, you'll need to get which checkboxes were checked:
Set the name in the form to check_list[] and you will be able to
access all the checkboxes as an array($_POST['check_list'][])
Second, you'll most likely want to use the GD and Image Functions built into PHP.
There is a lot there, and it can be confusing, so I suggest you do some reading through questions on SO on the subject: https://stackoverflow.com/search?q=merge+image+[php]

Optimal chart library for my site [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I want a chart api that can work almost like google stock market chart.
That means a chart where it will go from one date to another and on it will be approximated points of some events.
Example of use:
I have a day of watching a video, each time I see something interesting I click a button. The clicks are not in interval times, but I still want to see a graph where I would see the clicks in each second but approximated (will be watching the whole day on a graph and that means a separate second won't be seen). Now if I take enough people who will click the button I will have good approximated values in some points and will see what points are interesting and what points are not.
EDIT:
My problem currently is that I have all the points where users clicked on the button, but adding them all in a chart would yield lies. For example 1 user clicked at 12:00 and one at 13:00, I will see that in the mean time suppose at 12:25 I will see that 1 person clicked. A bad solution for this is to insert more data putting 0's at every other place other than the data points. That will give me very ugly graphs as the points are in seconds and the graph should show 86400 seconds (1 day) at only around 1000 pixels wide. So I want a graph that can approximate the points I give him and put 0's at all the other points by himself.
EDIT2:
That means that most of the points will be clustered while just small portion not, and I want to show those cluster as interesting points and the non-clusters as just noise.
The best Javascript charts library I ever seen is Highcharts. It's free (for non-commercial usage), can be used as it is, or with other JS frameworks (jQuery, Mootools, Prototype).
It generates points interpolation (i.e. approximation lines between irregular points, as you said) very easily. You can see that feature in the Time data with irregular intervals demo.
+1 for google charts. Your asking for something specific which require's work on your part. Google chart event's should help you in your quest interactive charts

How can I create a list catalouge page for my website, without shopping cart/detailed product page functions

I want to make Newegg's like catalouge functionality for my little website. I want mine to be sligthly different(greatly simplified) though. I haven't done anything so advanced(atleast in my books) before, and wanted to know if it's possible to do. I want to use PHP and JS. The new records will be added manually through using either phpMyAdmin or pehaps I will install and use either SQLyog, HeidiSQL or Navicat for such purposes. Could someone point me to the right resources to get this kind of job done as fast as possible and properly?
What I had in mind was:
For example the cell which contains the thumbimage, all the mini information about the product and the big price tag will not have a separate, more detailed page. Everything user will need to know will be inside that product cell.
Right under the thumbnail image there will be numbers(1 2 3 4 5 6), and when you hover over them, under the cursor, a big version of one of the all available images will appear.
Lastly, it should have the page generation(don't know what you call it). For example there's more than 20 product entries on the page, then the server should create a new page(First 1 >2< Last) to hold the older records.
Oh and there won't be any shopping cart functionality. You can't really "order" these kinds of products, you just find something you like and call me up about it.
TIA
I'm sure there are dozens of books on this subject. I'm attempting a short reply, however:
This sounds like something that could profit from:
a MCV-framework like CakePHP (or Django, Ruby on Rails etc), which could handle database-logic (including pagination, which is the word you're looking for), and
a JavaScript library like JQuery to handle Ajax, JavaScript and other UI-related stuff.
++?
For the page numbers, I recently had to do this. The technique is called pagination, and this thread helped me out immensely: PHP Formula For a Series of Numbers (Mathy Problem)
The thumbnail effect you want to include would need to be done in javascript. I'd recommend learning jQuery, as it is pretty easy to use for this sort of thing.
This is a hard question to answer because you haven't given much indication as to your skill level, or progress towards accomplishing your goal. Assuming we're starting at 0, there is probably more to discuss than this thread can contain. :\
UPDATE
To learn PHP's database functions, I would lean on W3School's PHP/MySQL tutorial for a quick summary, referring to the php manual's mysql documentation for details and code examples when W3schools isn't enough. This should at least get you the markup you will need to work with.
For the thumbnails, I would reiterate my recommendation for jQuery, specifically attaching a .hover() event to the image numbers (this is equivalent to the onmouseover and onmouseout events in JS) that uses the .fadeIn() and .fadeOut() animations to show and hide your full size images. Hope that helps.

How do I create a "todo" list for my web users to tick off?

I'm trying to think of a way to create a list of items that I can display on a webpage that my visitors can tick off, without ever having to log in.
The list may be like so:
[ ] Buy potatoes
[ ] Pickup kids
[x] Drink more water
[ ] Go for a Run
If User A visits the site, and clicks "Drink More Water" I want that to save in a database so that when User B visits, "Drink More Water" is already ticked.
Is there any simple ways to do that:
in PHP?
with Javascript?
or even as a WordPress plugin?
Do you know if there's any existing code around that does this?
TaDa List by 37Signals comes very close, but only allows specific people to tick things off.
Any suggestions would be greatly appreciated.
Thanks
Turgs
If you want to create this yourself you should learn PHP and MySQL (and possibly Javascript (for AJAX)), and HTML and CSS (maybe you already know some of these). After you know these it will become clear how to create this.
You should first learn HTML
then PHP
then MySQL (or any SQL that works with PHP)
then CSS
Then Javascript
We can't really answer your question like this, because it involves big amounts of code. Adn won't really help you if you don't know these languages.
I'll tell you what you need to do, but you're going to have to research most of the things.
You need html to create the list.
You need php to query sql and check if one of them should be checked or not.
Load the page with the data you got from your database server (set the checked ones as checked).
When the user checks one of them you need to store it in the database, so that when another user loads the page he can then get the changes from the database.
Hope this is clear enough.
Just store that information in cookies.
$_COOKIE['ticket'] = 3;
when he visit the page next time just check if $_COOKIE['ticket'] is not empty.
You could do this kind of thing with a file instead of a database. So when the user checks off a box, it loads a PHP file that reads an XML file with the tasks and check-status, then re-writes that file with the modified value.
It's quick, dirty, and doesn't need a database.
You could use a REST like url that defines a list. i.e.: http://ticklist.com/list/145
People can share this common list.
Something like the logic of http://friendpaste.comTo let people share and edit source codes.

Categories