4 die(
"matrixOption oder matrixQuestion class is not loaded ... please load it before checkBoxList");
8 public $typ =
"matrix";
18 if( (isset($this->
pollID)) AND (isset($this->ID)) AND (!empty($this->
pollID)) AND (!empty($this->ID)) AND ($this->
pollID != -1) AND ($this->ID != -1) ){
24 $opt->set_default_values(
$db);
25 $opt->set_dispName(
"");
26 $opt->set_value(
"Option$i");
31 $quest->set_dispName(
"Frage1");
48 foreach( $this->option_list as $option){
49 if( strlen($option->value) > $len){
50 $len = strlen($option->value);
52 if( strlen($option->dispName) > $len){
53 $len = strlen($option->dispName);
55 $len_tot = $len_tot + strlen($option->dispName) + strlen($option->value);
56 if( $option->dispName !=
"" ){
61 if( $len_count != 0 ){
62 $av_len = ($len_count + ($len_tot/$len_count))/2;
71 echo
"<table class='table_1' > ";
72 echo
"<tr> <th>ID</th> <th>Antwort</th> <th>Beschreibung</th> <th style='max-width:2em'>Bearbeiten</th> </tr>";
73 if(
sizeof($this->option_list) != 0 ){
74 foreach($this->option_list as $opt){
75 $opt->display_option_edit();
78 echo
"<td></td> <td></td>
79 <td> <input type='submit' name='add_option_ID{$this->ID}' title='Option Einfügen' value='' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT.
"/icons/22/list-add.png );background-repeat:no-repeat;width:26px;height:26px;' /> </td>";
87 $options_seen = array();
89 $post_keys = array_keys($_POST);
90 foreach($post_keys as $post){
92 if( substr($post,0,strlen(
"option_ID")) ==
"option_ID"){
94 if( substr($post,-1*strlen(
"name")) ==
"name"){
96 }
else if( substr($post,-1*strlen(
"value")) ==
"value" ){
107 $id = substr( $post , strlen(
"option_ID") , strlen($post)-strlen(
"option_ID")-strlen(
"_".$prop) );
109 if( ($id !=
false) AND (is_numeric($id)) AND (!in_array(intval($id),$options_seen) ) ){
115 $options_seen[] = $id;
119 if($all_errs !==
""){
128 echo
"<table class='table_1' > ";
130 echo
"<tr> <th>ID</th> <th>Frage</th> <th>Datenbank Name</th> <th style='max-width:2em' >Pflicht</th> <th style='max-width:2em'>Bearbeiten</th> </tr>";
132 echo
"<tr> <th>ID</th> <th>Frage</th> <th style='max-width:2em' >Pflicht</th> <th style='max-width:2em'>Bearbeiten</th> </tr>";
134 if(
sizeof($this->widget_list) != 0 ){
135 foreach($this->widget_list as $opt){
136 $opt->display_option_edit($polltype);
140 <td> <input type='submit' name='addq_option_ID{$this->ID}' title='Option Einfügen' value='' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT.
"/icons/22/list-add.png );background-repeat:no-repeat;width:26px;height:26px;' /> </td>";
148 $options_seen = array();
150 $post_keys = array_keys($_POST);
151 foreach($post_keys as $post){
153 if( substr($post,0,strlen(
"question_ID")) ==
"question_ID"){
155 if( substr($post,-1*strlen(
"name")) ==
"name"){
157 }
else if( substr($post,-1*strlen(
"name2")) ==
"name2" ){
159 }
else if( substr($post,-1*strlen(
"required")) ==
"required" ){
165 $id = substr( $post , strlen(
"question_ID") , strlen($post)-strlen(
"question_ID")-strlen(
"_".$prop) );
167 if( ($id !=
false) AND (is_numeric($id)) AND (!in_array(intval($id),$options_seen) ) ){
173 $options_seen[] = $id;
177 if($all_errs !==
""){
186 $allowed = array(
"barChart",
"barChart2",
"pieChart");
187 $allowed_names = array(
"Säulendiagramm Fragen",
"Säulendiagramm Antworten",
"Kreisdiagramm pro Frage");
192 $allowed = array(
"barChart",
"barChart2",
"pieChart");
200 if($cnf ==
true ){ $ckd =
"checked='checked'"; }
201 echo
"<input type='checkbox' name='show_charts' value='true' id='show_charts' $ckd/>
202 <label for='show_charts'>Aswertung der Frage nach dem Ausfüllen der Umfrage anzeigen</label>";
206 if( (isset($_POST[
"show_charts"])) AND ($_POST[
"show_charts"]==
"true") ){
221 if( $this->dispName ==
"-" ){
226 echo
"<label for='widget_dispname'>Gemeinsame Beschreibung der Antworten</label> <br/>
227 <input type='text' name='widget_dispname' id='widget_dispname' value='{$value}' placeholder='Optionaler Beschreibungstext für alle Antworten' size='40' style='margin-left:1.5em' />";
231 if( (isset($_POST[
"widget_dispname"])) AND ($_POST[
"widget_dispname"] !=
"") ){
248 $checked =
"checked='checked'";
252 echo
"<input type='checkbox' name='widget_numberQuestion' id='widget_numberQuestion' value='true' $checked /> <label for='bumberQuestion'>Fragen numerieren</label>";
256 if( isset($_POST[
"widget_numberQuestion"]) AND ($_POST[
"widget_numberQuestion"] ==
"true") ){
257 return $this->
set_config(
"numberQuestion",
true);
259 return $this->
set_config(
"numberQuestion",
false);
266 if($question->is_required){
267 $required =
"<span class='required_asterisk'>*</span>";
269 echo
"<td style='$bold' class='matrix_question_question' >$required {$question->dispName}</td>";
271 foreach( $this->option_list as $option){
273 if( $option->value == $question->value ){
274 $selected =
"checked='checked'";
276 echo
"<td style='min-width:{$option_len}em;max-width:{$option_len};text-align:center' onclick='set_matrix_radioButton(\"{$question->ID}_{$option->ID}\");'>";
277 echo
"<label for='{$question->ID}_{$option->ID}' style='width:100%;height:100%'>";
278 echo
"<input type='radio' name='{$question->name}' id='{$question->ID}_{$option->ID}' value='{$option->value}' $selected /> ";
287 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
291 echo
"<table style='' class='matrix_table' >";
294 if( $this->dispName !=
"-" ){
297 echo
"<tr><td colspan='2'></td> <td colspan='$colspan' style='max-width:{$w}em;word-wrap:break-word;border-bottom:1px solid #CCCCCC'>{$this->dispName}</td></tr>";
299 echo
"<tr class='matrix_answer_desc_row'> <td colspan='2'></td>";
300 foreach( $this->option_list as $option ){
301 echo
"<td style='max-width:{$len}em'>{$option->dispName}</td>";
306 echo
"<tr> <td colspan='2'></td>";
307 foreach( $this->option_list as $option ){
308 echo
"<td style='max-width:{$len}em' class='matrix_option_val_td' >{$option->value}</td>";
314 foreach( $this->widget_list as $question ){
316 echo
"<tr class='matrix_question_row row$r' >";
319 echo
"<td>{$l}.</td>";
333 $font_family= $this->
get_config(
"font-family");
337 if( $font_family !=
""){ $font_family =
"font-family:".$font_family; }
338 if( $font_size !=
""){ $font_size =
"font-size:".$font_size; }
339 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
341 echo
"<div class='widget_container matrix_widget' style='$font_family;$font_size'>";
343 echo
"<table style='' class='matrix_table' >";
346 if( $this->dispName !=
"-" ){
349 echo
"<tr><td colspan='2'></td> <td colspan='$colspan' style='max-width:{$w}em;word-wrap:break-word;border-bottom:1px solid #CCCCCC'>{$this->dispName}</td></tr>";
351 echo
"<tr class='matrix_answer_desc_row'> <td colspan='2'></td>";
352 foreach( $this->option_list as $option ){
353 echo
"<td style='max-width:{$len}em'>{$option->dispName}</td>";
358 echo
"<tr> <td colspan='2'></td>";
359 foreach( $this->option_list as $option ){
360 echo
"<td style='max-width:{$len}em' class='matrix_option_val_td' >{$option->value}</td>";
366 foreach( $this->widget_list as $question ){
368 echo
"<tr class='matrix_question_row row$r' >";
371 echo
"<td>{$l}.</td>";
385 foreach( $this->widget_list as $question ){
387 $req = $question->check_required();
388 if( $question->value !=
"" ){
398 if ( isset($_POST[$question->name]) ){
400 if( ($question->value !=
"") AND ($question->value == $_POST[$question->name]) AND ($this->option_list[
$i]->
value == $_POST[$question->name]) ){
403 }
else if ($this->option_list[
$i]->
value == $_POST[$question->name]) {
411 $question->value = $this->option_list[
$value]->value;
415 if(
sizeof(
$err) == 0){
427 foreach( $this->widget_list as $child ){
428 foreach( $this->option_list as $opt ){
429 $this->
set_data(
"count_".$opt->ID,0);
433 foreach( $this->widget_list as $child ){
436 SELECT `{$pollID}_results`.`$name`,
440 FROM `{$pollID}_results`
442 `$pollID`.`value`=`{$pollID}_results`.`$name`
443 AND `$pollID`.`parent`='$ID'
444 GROUP BY `$pollID`.`ID`;";
445 $res =
$db->get_sql_all_assoc($sql);
448 if( is_array($res) ){
449 foreach( $res as $row ){
452 $child->set_data(
"count_{$opt->ID}",intval($row[
"count"]));
467 $required_classes = array(
"pieChart",
"barChart");
468 foreach($required_classes as
$c ){
469 if( !class_exists($c) ){
470 throw new exception(
"Chart classes not loaded. Please include chart.class.php");
475 if( $type ==
"barChart" ){
478 }
else if( $type ==
"barChart2" ){
481 }
else if( $type ==
"pieChart" ){
482 $this->chart_list = array();
483 foreach(
$data[0] as $d ){
485 $chart->set_config(
"width",200);
486 $chart->set_config(
"height",200);
487 $this->chart_list[] = $chart;
489 $this->charted_widget_list =
$data[1];
501 $data = array(
"labels" => array() ,
"datasets" => array( array() ) );
504 foreach( $this->widget_list as $question){
505 $data[
"labels"][] =
"Frage".($i+1);
507 foreach( $this->option_list as $option ){
508 $data[
"datasets"][$ii][] = $question->get_data(
"count_{$option->ID}");
521 $data = array(
"labels" => array() ,
"datasets" => array( array() ) );
524 foreach( $this->option_list as $option){
525 $data[
"labels"][] =
"Antwort".($i+1);
527 foreach( $this->widget_list as $question ){
528 $data[
"datasets"][$ii][] = $question->get_data(
"count_{$option->ID}");
543 foreach( $this->widget_list as $question ){
545 foreach( $this->option_list as $option){
546 $dd[] = $question->get_data(
"count_{$option->ID}");
549 $charted_widget_list[] = $question;
551 return array(
$data,$charted_widget_list);
559 if( $type ==
"barChart" ){
561 }
else if( $type ==
"barChart2" ){
563 }
else if( $type ==
"pieChart" ){
577 if( isset($this->
chart) ){
578 echo
"<table style='border-collapse:collapse'>";
580 echo
"<tr><th colspan='2'>Legende Fragen (v.l.n.r.)</th></tr>";
581 if( $this->dispName !=
"-" ){
582 echo
"<tr style='border-bottom:1px solid #949494'> <td> </td><td style='padding-right:1em' >{$this->dispName}</td></tr>";
584 foreach( $this->widget_list as $question ){
585 echo
"<tr style='border-bottom:1px solid #D0D0D0'>";
587 echo
"<td style='border-right:1px solid #949494;padding-right:1em'>Frage$n</td>";
588 echo
"<td style='padding-left:1em'>{$question->dispName}</td>";
594 echo
"<table style='border-collapse:collapse'>";
595 echo
"<tr><th colspan='2'>Legende Antworten</th></tr>";
597 foreach( $this->option_list as $option ){
598 echo
"<tr style='border-bottom:1px solid #D0D0D0;'>";
600 echo
"<td style='background-color:$color;width:1em;height:1em;border: 2px solid white'> </td>";
601 echo
"<td >{$option->value}</td>";
613 if( isset($this->
chart) ){
618 echo
"<table style='border-collapse:collapse'>";
619 echo
"<tr><th colspan='2'>Legende Antworten (v.l.n.r.)</th></tr>";
620 foreach( $this->option_list as $option ){
621 echo
"<tr style='border-bottom:1px solid #D0D0D0'>";
623 echo
"<td style='border-right:1px solid #949494;padding-right:1em'>Antwort$n</td>";
624 echo
"<td style='padding-left:1em'>{$option->value}</td>";
631 echo
"<table style='border-collapse:collapse'>";
632 echo
"<tr><th colspan='2'>Legende Fragen</th></tr>";
633 foreach( $this->widget_list as $question ){
634 echo
"<tr style='border-bottom:1px solid #D0D0D0;'>";
636 echo
"<td style='background-color:$color;width:1em;height:1em;border: 2px solid white'> </td>";
637 echo
"<td>{$question->dispName}</td>";
651 echo
"<table style='border-collapse:collapse'>";
653 echo
"<tr><th colspan='2'>Legende</th></tr>";
654 foreach( $this->option_list as $option ){
655 echo
"<tr style='border-bottom:1px solid #D0D0D0;'>";
658 echo
"<td style='background-color:$color;width:1em;height:1em;border: 2px solid white'> </td>";
659 echo
"<td>{$option->value} <span style='color:#810000'>({$widget->get_data("count_
".$option->ID)})</span></td>";
668 if( isset($this->
chart) ){
669 if( $chartType ==
"barChart" ){
672 }
else if( $chartType ==
"barChart2" ){
683 if( !isset($this->
chart) ){
686 if( isset($this->
chart) ){
687 $this->
chart->display();
692 if( !isset($this->
chart) ){
697 if( $chartType !=
"pieChart" ){
698 if( isset($this->
chart) ){
699 echo
"<h3>Fragenmatrix ID{$this->ID}</h3>";
702 $this->
chart->display();
704 echo
"<td style='padding-left:30px'>";
707 echo
"</tr></table>";
710 echo
"<h3>Fragenmatrix ID{$this->ID}</h3>";
713 foreach( $this->chart_list as $chart ){
714 echo
"<tr> <td colspan='2'> <h4>{$this->charted_widget_list[$c]->dispName}</h4> </td> </tr>";
719 echo
"<td style='padding-left:30px'>";