adding some strings
[moodle-linuxchix.git] / mod / survey / graph.php
blob5edc80ad23642074c56f6b7ffe8fcdb474159c7b
1 <?php // $Id$
3 require_once("../../config.php");
4 require_once("$CFG->libdir/graphlib.php");
5 require_once("lib.php");
7 $id = required_param('id', PARAM_INT); // Course Module ID
8 $type = required_param('type', PARAM_FILE); // Graph Type
9 $group = optional_param('group', 0, PARAM_INT); // Group ID
10 $sid = optional_param('sid', false, PARAM_INT); // Student ID
11 $qid = optional_param('qid', 0, PARAM_INT); // Group ID
13 if (! $cm = get_coursemodule_from_id('survey', $id)) {
14 error("Course Module ID was incorrect");
17 if (! $course = get_record("course", "id", $cm->course)) {
18 error("Course is misconfigured");
21 require_login($course->id, false, $cm);
23 $groupmode = groupmode($course, $cm); // Groups are being used
24 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
26 if (!has_capability('mod/survey:readresponses', $context)) {
27 if ($type != "student.png" or $sid != $USER->id ) {
28 error("Sorry, you aren't allowed to see this.");
29 } else if ($groupmode and !ismember($group)) {
30 error("Sorry, you aren't allowed to see this.");
34 if (! $survey = get_record("survey", "id", $cm->instance)) {
35 error("Survey ID was incorrect");
38 /// Check to see if groups are being used in this survey
39 if ($groupmode and $group) {
40 $users = get_group_users($group);
41 } else {
42 $users = get_course_users($course->id);
43 $group = false;
46 $stractual = get_string("actual", "survey");
47 $stractualclass = get_string("actualclass", "survey");
48 $stractualstudent = get_string("actualstudent", "survey", $course->student);
50 $strpreferred = get_string("preferred", "survey");
51 $strpreferredclass = get_string("preferredclass", "survey");
52 $strpreferredstudent = get_string("preferredstudent", "survey", $course->student);
54 $virtualscales = false; //set default value for case clauses
56 switch ($type) {
58 case "question.png":
60 $question = get_record("survey_questions", "id", $qid);
61 $question->text = get_string($question->text, "survey");
62 $question->options = get_string($question->options, "survey");
64 $options = explode(",",$question->options);
66 while (list($key,) = each($options)) {
67 $buckets1[$key] = 0;
68 $buckets2[$key] = 0;
71 if ($aaa = get_records_select("survey_answers", "survey = '$cm->instance' AND question = '$qid'")) {
72 foreach ($aaa as $aa) {
73 if (!$group or isset($users[$aa->userid])) {
74 if ($a1 = $aa->answer1) {
75 $buckets1[$a1 - 1]++;
77 if ($a2 = $aa->answer2) {
78 $buckets2[$a2 - 1]++;
85 $maxbuckets1 = max($buckets1);
86 $maxbuckets2 = max($buckets2);
87 $maxbuckets = ($maxbuckets1 > $maxbuckets2) ? $maxbuckets1 : $maxbuckets2;
89 $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
90 $graph->parameter['title'] = "$question->text";
92 $graph->x_data = $options;
94 $graph->y_data['answers1'] = $buckets1;
95 $graph->y_format['answers1'] = array('colour' => 'ltblue','bar' => 'fill','legend' =>$stractual,'bar_size' => 0.4);
96 $graph->y_data['answers2'] = $buckets2;
97 $graph->y_format['answers2'] = array('colour' =>'ltorange','bar' => 'fill','legend' =>$strpreferred,'bar_size' => 0.2);
99 $graph->parameter['legend'] = 'outside-top';
100 $graph->parameter['legend_border'] = 'black';
101 $graph->parameter['legend_offset'] = 4;
103 if (($maxbuckets1 > 0.0) && ($maxbuckets2 > 0.0)) {
104 $graph->y_order = array('answers1', 'answers2');
105 } else if ($maxbuckets1 > 0.0) {
106 $graph->y_order = array('answers1');
107 } else {
108 $graph->y_order = array('answers2');
111 $graph->parameter['y_axis_gridlines']= $maxbuckets + 1;
112 $graph->parameter['y_resolution_left']= 1;
113 $graph->parameter['y_decimal_left'] = 0;
114 $graph->parameter['x_axis_angle'] = 20;
115 $graph->parameter['shadow'] = 'none';
117 $graph->y_tick_labels = null;
118 $graph->offset_relation = null;
120 $graph->draw_stack();
122 break;
126 case "multiquestion.png":
128 $question = get_record("survey_questions", "id", $qid);
129 $question->text = get_string($question->text, "survey");
130 $question->options = get_string($question->options, "survey");
132 $options = explode(",",$question->options);
133 $questionorder = explode( ",", $question->multi);
135 $qqq = get_records_list("survey_questions", "id", $question->multi);
137 foreach ($questionorder as $i => $val) {
138 $names[$i] = get_string($qqq["$val"]->shorttext, "survey");
139 $buckets1[$i] = 0;
140 $buckets2[$i] = 0;
141 $count1[$i] = 0;
142 $count2[$i] = 0;
143 $indexof[$val] = $i;
144 $stdev1[$i] = 0;
145 $stdev2[$i] = 0;
148 $aaa = get_records_select("survey_answers", "((survey = $cm->instance) AND (question in ($question->multi)))");
150 if ($aaa) {
151 foreach ($aaa as $a) {
152 if (!$group or isset($users[$a->userid])) {
153 $index = $indexof[$a->question];
154 if ($a->answer1) {
155 $buckets1[$index] += $a->answer1;
156 $count1[$index]++;
158 if ($a->answer2) {
159 $buckets2[$index] += $a->answer2;
160 $count2[$index]++;
166 foreach ($questionorder as $i => $val) {
167 if ($count1[$i]) {
168 $buckets1[$i] = (float)$buckets1[$i] / (float)$count1[$i];
170 if ($count2[$i]) {
171 $buckets2[$i] = (float)$buckets2[$i] / (float)$count2[$i];
175 if ($aaa) {
176 foreach ($aaa as $a) {
177 if (!$group or isset($users[$a->userid])) {
178 $index = $indexof[$a->question];
179 if ($a->answer1) {
180 $difference = (float) ($a->answer1 - $buckets1[$index]);
181 $stdev1[$index] += ($difference * $difference);
183 if ($a->answer2) {
184 $difference = (float) ($a->answer2 - $buckets2[$index]);
185 $stdev2[$index] += ($difference * $difference);
191 foreach ($questionorder as $i => $val) {
192 if ($count1[$i]) {
193 $stdev1[$i] = sqrt( (float)$stdev1[$i] / ((float)$count1[$i]));
195 if ($count2[$i]) {
196 $stdev2[$i] = sqrt( (float)$stdev2[$i] / ((float)$count2[$i]));
198 $buckets1[$i] = $buckets1[$i] - 1;
199 $buckets2[$i] = $buckets2[$i] - 1;
204 $maxbuckets1 = max($buckets1);
205 $maxbuckets2 = max($buckets2);
208 $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
209 $graph->parameter['title'] = "$question->text";
211 $graph->x_data = $names;
212 $graph->y_data['answers1'] = $buckets1;
213 $graph->y_format['answers1'] = array('colour' => 'ltblue', 'line' => 'line', 'point' => 'square',
214 'shadow_offset' => 4, 'legend' => $stractual);
215 $graph->y_data['answers2'] = $buckets2;
216 $graph->y_format['answers2'] = array('colour' => 'ltorange', 'line' => 'line', 'point' => 'square',
217 'shadow_offset' => 4, 'legend' => $strpreferred);
218 $graph->y_data['stdev1'] = $stdev1;
219 $graph->y_format['stdev1'] = array('colour' => 'ltltblue', 'bar' => 'fill',
220 'shadow_offset' => '4', 'legend' => 'none', 'bar_size' => 0.3);
221 $graph->y_data['stdev2'] = $stdev2;
222 $graph->y_format['stdev2'] = array('colour' => 'ltltorange', 'bar' => 'fill',
223 'shadow_offset' => '4', 'legend' => 'none', 'bar_size' => 0.2);
224 $graph->offset_relation['stdev1'] = 'answers1';
225 $graph->offset_relation['stdev2'] = 'answers2';
227 $graph->parameter['bar_size'] = 0.15;
229 $graph->parameter['legend'] = 'outside-top';
230 $graph->parameter['legend_border'] = 'black';
231 $graph->parameter['legend_offset'] = 4;
233 $graph->y_tick_labels = $options;
235 if (($maxbuckets1 > 0.0) && ($maxbuckets2 > 0.0)) {
236 $graph->y_order = array('stdev1', 'answers1', 'stdev2', 'answers2');
237 } else if ($maxbuckets1 > 0.0) {
238 $graph->y_order = array('stdev1', 'answers1');
239 } else {
240 $graph->y_order = array('stdev2', 'answers2');
243 $graph->parameter['y_max_left']= count($options) - 1;
244 $graph->parameter['y_axis_gridlines']= count($options);
245 $graph->parameter['y_resolution_left']= 1;
246 $graph->parameter['y_decimal_left']= 1;
247 $graph->parameter['x_axis_angle'] = 20;
249 $graph->draw();
251 break;
255 case "overall.png":
257 $qqq = get_records_list("survey_questions", "id", $survey->questions);
260 foreach ($qqq as $key => $qq) {
261 if ($qq->multi) {
262 $qqq[$key]->text = get_string($qq->text, "survey");
263 $qqq[$key]->options = get_string($qq->options, "survey");
264 if ($qq->type < 0) {
265 $virtualscales = true;
269 foreach ($qqq as $qq) { // if any virtual, then use JUST virtual, else use JUST nonvirtual
270 if ($qq->multi) {
271 if ($virtualscales && $qq->type < 0) {
272 $question[] = $qq;
273 } else if (!$virtualscales && $qq->type > 0) {
274 $question[] = $qq;
278 $numquestions = count($question);
280 $options = explode(",",$question[0]->options);
281 $numoptions = count($options);
283 for ($i=0; $i<$numquestions; $i++) {
284 $names[$i] = $question[$i]->text;
285 $buckets1[$i] = 0.0;
286 $buckets2[$i] = 0.0;
287 $stdev1[$i] = 0.0;
288 $stdev2[$i] = 0.0;
289 $count1[$i] = 0;
290 $count2[$i] = 0;
291 $subquestions = $question[$i]->multi; // otherwise next line doesn't work
292 $aaa = get_records_select("survey_answers", "((survey = $cm->instance) AND (question in ($subquestions)))");
294 if ($aaa) {
295 foreach ($aaa as $a) {
296 if (!$group or isset($users[$a->userid])) {
297 if ($a->answer1) {
298 $buckets1[$i] += $a->answer1;
299 $count1[$i]++;
301 if ($a->answer2) {
302 $buckets2[$i] += $a->answer2;
303 $count2[$i]++;
309 if ($count1[$i]) {
310 $buckets1[$i] = (float)$buckets1[$i] / (float)$count1[$i];
312 if ($count2[$i]) {
313 $buckets2[$i] = (float)$buckets2[$i] / (float)$count2[$i];
316 // Calculate the standard devaiations
317 if ($aaa) {
318 foreach ($aaa as $a) {
319 if (!$group or isset($users[$a->userid])) {
320 if ($a->answer1) {
321 $difference = (float) ($a->answer1 - $buckets1[$i]);
322 $stdev1[$i] += ($difference * $difference);
324 if ($a->answer2) {
325 $difference = (float) ($a->answer2 - $buckets2[$i]);
326 $stdev2[$i] += ($difference * $difference);
332 if ($count1[$i]) {
333 $stdev1[$i] = sqrt( (float)$stdev1[$i] / ((float)$count1[$i]));
335 if ($count2[$i]) {
336 $stdev2[$i] = sqrt( (float)$stdev2[$i] / ((float)$count2[$i]));
339 $buckets1[$i] = $buckets1[$i] - 1; // Hack because there should not be ANY 0 values in the data.
340 $buckets2[$i] = $buckets2[$i] - 1;
344 $maxbuckets1 = max($buckets1);
345 $maxbuckets2 = max($buckets2);
348 $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
349 $graph->parameter['title'] = strip_tags(format_string($survey->name,true));
351 $graph->x_data = $names;
353 $graph->y_data['answers1'] = $buckets1;
354 $graph->y_format['answers1'] = array('colour' => 'ltblue', 'line' => 'line', 'point' => 'square',
355 'shadow_offset' => 4, 'legend' => $stractual);
356 $graph->y_data['answers2'] = $buckets2;
357 $graph->y_format['answers2'] = array('colour' => 'ltorange', 'line' => 'line', 'point' => 'square',
358 'shadow_offset' => 4, 'legend' => $strpreferred);
360 $graph->y_data['stdev1'] = $stdev1;
361 $graph->y_format['stdev1'] = array('colour' => 'ltltblue', 'bar' => 'fill',
362 'shadow_offset' => '4', 'legend' => 'none', 'bar_size' => 0.3);
363 $graph->y_data['stdev2'] = $stdev2;
364 $graph->y_format['stdev2'] = array('colour' => 'ltltorange', 'bar' => 'fill',
365 'shadow_offset' => '4', 'legend' => 'none', 'bar_size' => 0.2);
366 $graph->offset_relation['stdev1'] = 'answers1';
367 $graph->offset_relation['stdev2'] = 'answers2';
369 $graph->parameter['legend'] = 'outside-top';
370 $graph->parameter['legend_border'] = 'black';
371 $graph->parameter['legend_offset'] = 4;
373 $graph->y_tick_labels = $options;
375 if (($maxbuckets1 > 0.0) && ($maxbuckets2 > 0.0)) {
376 $graph->y_order = array('stdev1', 'answers1', 'stdev2', 'answers2');
377 } else if ($maxbuckets1 > 0.0) {
378 $graph->y_order = array('stdev1', 'answers1');
379 } else {
380 $graph->y_order = array('stdev2', 'answers2');
383 $graph->parameter['y_max_left']= $numoptions - 1;
384 $graph->parameter['y_axis_gridlines']= $numoptions;
385 $graph->parameter['y_resolution_left']= 1;
386 $graph->parameter['y_decimal_left']= 1;
387 $graph->parameter['x_axis_angle'] = 0;
388 $graph->parameter['x_inner_padding'] = 6;
390 $graph->draw();
392 break;
396 case "student.png":
398 $qqq = get_records_list("survey_questions", "id", $survey->questions);
400 foreach ($qqq as $key => $qq) {
401 if ($qq->multi) {
402 $qqq[$key]->text = get_string($qq->text, "survey");
403 $qqq[$key]->options = get_string($qq->options, "survey");
404 if ($qq->type < 0) {
405 $virtualscales = true;
409 foreach ($qqq as $qq) { // if any virtual, then use JUST virtual, else use JUST nonvirtual
410 if ($qq->multi) {
411 if ($virtualscales && $qq->type < 0) {
412 $question[] = $qq;
413 } else if (!$virtualscales && $qq->type > 0) {
414 $question[] = $qq;
418 $numquestions= count($question);
420 $options = explode(",",$question[0]->options);
421 $numoptions = count($options);
423 for ($i=0; $i<$numquestions; $i++) {
424 $names[$i] = $question[$i]->text;
425 $buckets1[$i] = 0.0;
426 $buckets2[$i] = 0.0;
427 $count1[$i] = 0;
428 $count2[$i] = 0;
429 $studbuckets1[$i] = 0.0;
430 $studbuckets2[$i] = 0.0;
431 $studcount1[$i] = 0;
432 $studcount2[$i] = 0;
433 $stdev1[$i] = 0.0;
434 $stdev2[$i] = 0.0;
436 $subquestions = $question[$i]->multi; // otherwise next line doesn't work
437 $aaa = get_records_select("survey_answers","((survey = $cm->instance) AND (question in ($subquestions)))");
439 if ($aaa) {
440 foreach ($aaa as $a) {
441 if (!$group or isset($users[$a->userid])) {
442 if ($a->userid == $sid) {
443 if ($a->answer1) {
444 $studbuckets1[$i] += $a->answer1;
445 $studcount1[$i]++;
447 if ($a->answer2) {
448 $studbuckets2[$i] += $a->answer2;
449 $studcount2[$i]++;
452 if ($a->answer1) {
453 $buckets1[$i] += $a->answer1;
454 $count1[$i]++;
456 if ($a->answer2) {
457 $buckets2[$i] += $a->answer2;
458 $count2[$i]++;
464 if ($count1[$i]) {
465 $buckets1[$i] = (float)$buckets1[$i] / (float)$count1[$i];
467 if ($count2[$i]) {
468 $buckets2[$i] = (float)$buckets2[$i] / (float)$count2[$i];
470 if ($studcount1[$i]) {
471 $studbuckets1[$i] = (float)$studbuckets1[$i] / (float)$studcount1[$i];
473 if ($studcount2[$i]) {
474 $studbuckets2[$i] = (float)$studbuckets2[$i] / (float)$studcount2[$i];
477 // Calculate the standard devaiations
478 foreach ($aaa as $a) {
479 if (!$group or isset($users[$a->userid])) {
480 if ($a->answer1) {
481 $difference = (float) ($a->answer1 - $buckets1[$i]);
482 $stdev1[$i] += ($difference * $difference);
484 if ($a->answer2) {
485 $difference = (float) ($a->answer2 - $buckets2[$i]);
486 $stdev2[$i] += ($difference * $difference);
491 if ($count1[$i]) {
492 $stdev1[$i] = sqrt( (float)$stdev1[$i] / ((float)$count1[$i]));
494 if ($count2[$i]) {
495 $stdev2[$i] = sqrt( (float)$stdev2[$i] / ((float)$count2[$i]));
498 $buckets1[$i] = $buckets1[$i] - 1; // Hack because there should not be ANY 0 values in the data.
499 $buckets2[$i] = $buckets2[$i] - 1;
500 $studbuckets1[$i] = $studbuckets1[$i] - 1;
501 $studbuckets2[$i] = $studbuckets2[$i] - 1;
505 $maxbuckets1 = max($buckets1);
506 $maxbuckets2 = max($buckets2);
509 $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
510 $graph->parameter['title'] = strip_tags(format_string($survey->name,true));
512 $graph->x_data = $names;
514 $graph->y_data['answers1'] = $buckets1;
515 $graph->y_format['answers1'] = array('colour' => 'ltblue', 'line' => 'line', 'point' => 'square',
516 'shadow_offset' => 0.1, 'legend' => $stractualclass);
517 $graph->y_data['answers2'] = $buckets2;
518 $graph->y_format['answers2'] = array('colour' => 'ltorange', 'line' => 'line', 'point' => 'square',
519 'shadow_offset' => 0.1, 'legend' => $strpreferredclass);
520 $graph->y_data['studanswers1'] = $studbuckets1;
521 $graph->y_format['studanswers1'] = array('colour' => 'blue', 'line' => 'line', 'point' => 'square',
522 'shadow_offset' => 4, 'legend' => $stractualstudent);
523 $graph->y_data['studanswers2'] = $studbuckets2;
524 $graph->y_format['studanswers2'] = array('colour' => 'orange', 'line' => 'line', 'point' => 'square',
525 'shadow_offset' => 4, 'legend' => $strpreferredstudent);
526 $graph->y_data['stdev1'] = $stdev1;
527 $graph->y_format['stdev1'] = array('colour' => 'ltltblue', 'bar' => 'fill',
528 'shadow_offset' => 0.1, 'legend' => 'none', 'bar_size' => 0.3);
529 $graph->y_data['stdev2'] = $stdev2;
530 $graph->y_format['stdev2'] = array('colour' => 'ltltorange', 'bar' => 'fill',
531 'shadow_offset' => 0.1, 'legend' => 'none', 'bar_size' => 0.2);
532 $graph->offset_relation['stdev1'] = 'answers1';
533 $graph->offset_relation['stdev2'] = 'answers2';
535 $graph->y_tick_labels = $options;
537 $graph->parameter['bar_size'] = 0.15;
539 $graph->parameter['legend'] = 'outside-top';
540 $graph->parameter['legend_border'] = 'black';
541 $graph->parameter['legend_offset'] = 4;
543 if (($maxbuckets1 > 0.0) && ($maxbuckets2 > 0.0)) {
544 $graph->y_order = array('stdev1', 'stdev2', 'answers1', 'answers2', 'studanswers1', 'studanswers2');
545 } else if ($maxbuckets1 > 0.0) {
546 $graph->y_order = array('stdev1', 'answers1', 'studanswers1');
547 } else {
548 $graph->y_order = array('stdev2', 'answers2', 'studanswers2');
551 $graph->parameter['y_max_left']= $numoptions - 1;
552 $graph->parameter['y_axis_gridlines']= $numoptions;
553 $graph->parameter['y_resolution_left']= 1;
554 $graph->parameter['y_decimal_left']= 1;
555 $graph->parameter['x_axis_angle'] = 20;
557 $graph->draw();
558 break;
562 case "studentmultiquestion.png":
564 $question = get_record("survey_questions", "id", $qid);
565 $question->text = get_string($question->text, "survey");
566 $question->options = get_string($question->options, "survey");
568 $options = explode(",",$question->options);
569 $questionorder = explode( ",", $question->multi);
571 $qqq = get_records_list("survey_questions", "id", $question->multi);
573 foreach ($questionorder as $i => $val) {
574 $names[$i] = get_string($qqq[$val]->shorttext, "survey");
575 $buckets1[$i] = 0;
576 $buckets2[$i] = 0;
577 $count1[$i] = 0;
578 $count2[$i] = 0;
579 $indexof[$val] = $i;
580 $studbuckets1[$i] = 0.0;
581 $studbuckets2[$i] = 0.0;
582 $studcount1[$i] = 0;
583 $studcount2[$i] = 0;
584 $stdev1[$i] = 0.0;
585 $stdev2[$i] = 0.0;
588 $aaa = get_records_select("survey_answers", "((survey = $cm->instance) AND (question in ($question->multi)))");
590 if ($aaa) {
591 foreach ($aaa as $a) {
592 if (!$group or isset($users[$a->userid])) {
593 $index = $indexof[$a->question];
594 if ($a->userid == $sid) {
595 if ($a->answer1) {
596 $studbuckets1[$index] += $a->answer1;
597 $studcount1[$index]++;
599 if ($a->answer2) {
600 $studbuckets2[$index] += $a->answer2;
601 $studcount2[$index]++;
604 if ($a->answer1) {
605 $buckets1[$index] += $a->answer1;
606 $count1[$index]++;
608 if ($a->answer2) {
609 $buckets2[$index] += $a->answer2;
610 $count2[$index]++;
616 foreach ($questionorder as $i => $val) {
617 if ($count1[$i]) {
618 $buckets1[$i] = (float)$buckets1[$i] / (float)$count1[$i];
620 if ($count2[$i]) {
621 $buckets2[$i] = (float)$buckets2[$i] / (float)$count2[$i];
623 if ($studcount1[$i]) {
624 $studbuckets1[$i] = (float)$studbuckets1[$i] / (float)$studcount1[$i];
626 if ($studcount2[$i]) {
627 $studbuckets2[$i] = (float)$studbuckets2[$i] / (float)$studcount2[$i];
631 foreach ($aaa as $a) {
632 if (!$group or isset($users[$a->userid])) {
633 $index = $indexof[$a->question];
634 if ($a->answer1) {
635 $difference = (float) ($a->answer1 - $buckets1[$index]);
636 $stdev1[$index] += ($difference * $difference);
638 if ($a->answer2) {
639 $difference = (float) ($a->answer2 - $buckets2[$index]);
640 $stdev2[$index] += ($difference * $difference);
645 foreach ($questionorder as $i => $val) {
646 if ($count1[$i]) {
647 $stdev1[$i] = sqrt( (float)$stdev1[$i] / ((float)$count1[$i]));
649 if ($count2[$i]) {
650 $stdev2[$i] = sqrt( (float)$stdev2[$i] / ((float)$count2[$i]));
652 $buckets1[$i] = $buckets1[$i] - 1; // Hack because there should not be ANY 0 values in the data.
653 $buckets2[$i] = $buckets2[$i] - 1;
654 $studbuckets1[$i] = $studbuckets1[$i] - 1;
655 $studbuckets2[$i] = $studbuckets2[$i] - 1;
660 $maxbuckets1 = max($buckets1);
661 $maxbuckets2 = max($buckets2);
664 $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
665 $graph->parameter['title'] = "$question->text";
667 $graph->x_data = $names;
668 $graph->y_data['answers1'] = $buckets1;
669 $graph->y_format['answers1'] = array('colour' => 'ltblue', 'line' => 'line', 'point' => 'square',
670 'shadow_offset' => 0.1, 'legend' => $stractualclass);
671 $graph->y_data['answers2'] = $buckets2;
672 $graph->y_format['answers2'] = array('colour' => 'ltorange', 'line' => 'line', 'point' => 'square',
673 'shadow_offset' => 0.1, 'legend' => $strpreferredclass);
674 $graph->y_data['studanswers1'] = $studbuckets1;
675 $graph->y_format['studanswers1'] = array('colour' => 'blue', 'line' => 'line', 'point' => 'square',
676 'shadow_offset' => 4, 'legend' => $stractualstudent);
677 $graph->y_data['studanswers2'] = $studbuckets2;
678 $graph->y_format['studanswers2'] = array('colour' => 'orange', 'line' => 'line', 'point' => 'square',
679 'shadow_offset' => 4, 'legend' => $strpreferredstudent);
680 $graph->y_data['stdev1'] = $stdev1;
681 $graph->y_format['stdev1'] = array('colour' => 'ltltblue', 'bar' => 'fill',
682 'shadow_offset' => 0.1, 'legend' => 'none', 'bar_size' => 0.3);
683 $graph->y_data['stdev2'] = $stdev2;
684 $graph->y_format['stdev2'] = array('colour' => 'ltltorange', 'bar' => 'fill',
685 'shadow_offset' => 0.1, 'legend' => 'none', 'bar_size' => 0.2);
686 $graph->offset_relation['stdev1'] = 'answers1';
687 $graph->offset_relation['stdev2'] = 'answers2';
689 $graph->parameter['bar_size'] = 0.15;
691 $graph->parameter['legend'] = 'outside-top';
692 $graph->parameter['legend_border'] = 'black';
693 $graph->parameter['legend_offset'] = 4;
695 $graph->y_tick_labels = $options;
697 if (($maxbuckets1 > 0.0) && ($maxbuckets2 > 0.0)) {
698 $graph->y_order = array('stdev1', 'stdev2', 'answers1', 'answers2', 'studanswers1', 'studanswers2');
699 } else if ($maxbuckets1 > 0.0) {
700 $graph->y_order = array('stdev1', 'answers1', 'studanswers1');
701 } else {
702 $graph->y_order = array('stdev2', 'answers2', 'studanswers2');
705 $graph->parameter['y_max_left']= count($options)-1;
706 $graph->parameter['y_axis_gridlines']= count($options);
707 $graph->parameter['y_resolution_left']= 1;
708 $graph->parameter['y_decimal_left']= 1;
709 $graph->parameter['x_axis_angle'] = 20;
711 $graph->draw();
713 break;
715 default:
716 break;
719 exit;