Jump to content

Archived

This topic is now archived and is closed to further replies.

realjumper

Pie chart or bar graph

Recommended Posts

Hi,

In my application to test the users knowledge of Kanji, I ask 20 random questions. At the completion of the test I show them, amoung other things, how many they got correct, how many they got wrong, and the percentage of correct answers....the code is below. What I would like to do is to show this data in the form of a pie chart or perhaps a bar graph as it is a bit more applealing than just the stats. I'm not asking for the code, I'm just asking to be sent in the right direction so that I can find out how to do this and have a go myself. If you can set me on my way, I'd be most gratefull, thanks

[code]

$yes = $row[test_correct];
$no = $row[test_wrong];

$total = $yes+$no;

$sum = $yes/$total*'100';

$perc = round($sum);


if ($row[test_attempts] == '20')
  {
  echo "Test Complete";
 
  echo "<p>";
 
  echo "Correct Answers: $row[test_correct]";
 
  echo "<p>";
 
  echo "Wrong Answers: $row[test_wrong]";
 
  echo "<p>";
 
  echo "Percentage Correct: $perc%";
 
[/code]

Share this post


Link to post
Share on other sites
I think the best thing is to get a free PHP graph class and use it to display a nice graph.
That way you won't be re-inventing code and coding what someone's put time into, I found one here:
http://www.qualityunit.com/postgraph/

It's open source and free.

Here's an example graph from it:
[img]http://www.qualityunit.com/web/content/english/default/img/graph2.png[/img]

Share this post


Link to post
Share on other sites
if you do want to do it yourself, you'll need to look into using the GD library functions.

Share this post


Link to post
Share on other sites
If you just show %correct for a single student then a pie is ideal.

If you want to show all questions and the % of students who got each correct then use a column chart with a column for each question

Share this post


Link to post
Share on other sites
Great, thank you all for your help.....I think a bar graph would be the way to go for each result, and a pie chart for the total at the end of the test. What I mean is.... After each question, once the user has selected one four possible answers, the new question appears as well as whether they got the previous question right or wrong and a running total of the number of right and wrong answers so far. So, a bar graph that reflects this progress would be good.....do you think?

Once they complete the test, perhaps a pie chart as well as the total results bar graph of right and wrong would be good. I could also supply a link so that the student could review his errors.

That sounds like a plan ;-)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.