* $URL$ * $Date:: 2010-11-26 16:55:48 -0600 (Fri, 26 Nov 2010) $: * */ require_once("includes/application_top.php"); require_once('includes/jpgraph/jpgraph.php'); require_once("includes/jpgraph/jpgraph_bar.php"); // Which pool are we using? $pool_id = intval($_GET["pool_id"]); $width = isset($_GET["width"]) ? intval($_GET["width"]) : 350; $height = isset($_GET["height"]) ? intval($_GET["height"]) : 150; // Load pool info if ($pool_id > 0) { $poolInfo = getPoolInfo($pool_id); $userStats = loadPoolHistory($user_id, $pool_id); foreach ($poolInfo["subelements"] as $name=>$value) { $data1y[] = intval($userStats["subelements"][$name]["correct_percent"])+0; // percent correct $data2y[] = ($userStats["subelements"][$name]["question_count"] / $value["question_count"]) *100; // percent attempted if ($userStats["subelements"][$name]["attempts"] > 0) $data3y[] = 100 - intval($userStats["subelements"][$name]["correct_percent"])+0; // percent wrong else $data3y[] = 0; $datax[] = $name; } } //$data1y=array(12,8,19,3,10,5); //$data2y=array(8,2,11,7,14,4); // Create the graph. These two calls are always required $graph = new Graph($width,$height,"auto"); $graph->SetScale("textlin", 0, 100); $graph->SetShadow(); $graph->img->SetMargin(40,30,20,65); // Create the bar plots $b1plot = new BarPlot($data1y); $b1plot->SetFillColor("green"); $b2plot = new BarPlot($data2y); $b2plot->SetFillColor("blue"); $b3plot = new BarPlot($data3y); $b3plot->SetFillColor("red"); // Create the grouped bar plot $ab1plot = new AccBarPlot (array($b1plot ,$b3plot)); $gbplot = new GroupBarPlot(array($ab1plot,$b2plot)); // ,$b2plot,$b3plot)); // ...and add it to the graph $graph->Add($gbplot); $graph->title->Set("Subelement Statistics"); //$graph->xaxis->title->Set("Subelements"); $graph->yaxis->title->Set("Percentage"); $graph->title->SetFont(FF_FONT1,FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); // Set up legend $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->Pos(0.5,0.95,"center","bottom"); $b1plot->SetLegend("% Correct"); $b2plot->SetLegend("% Attempted"); $b3plot->SetLegend("% Wrong"); // Setup X-axis $graph->xaxis->SetTickLabels($datax); // Display the graph $graph->Stroke(); ?>