Jump to content

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]
Link to comment
https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/
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]
Link to comment
https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/#findComment-57608
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 ;-)
Link to comment
https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/#findComment-57616
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.