ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.SurveyMetricQuestion.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
25 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
26 
27 define("SUBTYPE_NON_RATIO", 3);
28 define("SUBTYPE_RATIO_NON_ABSOLUTE", 4);
29 define("SUBTYPE_RATIO_ABSOLUTE", 5);
30 
43 {
51  var $subtype;
52 
58  var $minimum;
59 
65  var $maximum;
66 
79  $title = "",
80  $description = "",
81  $author = "",
82  $questiontext = "",
83  $owner = -1,
85  )
86  {
88  $this->subtype = $subtype;
89  $this->minimum = "";
90  $this->maximum = "";
91  }
92 
101  {
102  $this->subtype = $subtype;
103  }
104 
112  function setMinimum($minimum = 0)
113  {
114  $this->minimum = $minimum;
115  }
116 
124  function setMaximum($maximum = "")
125  {
126  $this->maximum = $maximum;
127  }
128 
136  function getSubtype()
137  {
138  return $this->subtype;
139  }
140 
148  function getMinimum()
149  {
150  if ((strlen($this->minimum) == 0) && ($this->getSubtype() > 3))
151  {
152  $this->minimum = 0;
153  }
154  return (strlen($this->minimum)) ? $this->minimum : NULL;
155  }
156 
164  function getMaximum()
165  {
166  return (strlen($this->maximum)) ? $this->maximum : NULL;
167  }
168 
177  {
178  global $ilDB;
179 
180  $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question, " . $this->getAdditionalTableName() . " WHERE svy_question.question_id = %s AND svy_question.question_id = " . $this->getAdditionalTableName() . ".question_fi",
181  array('integer'),
182  array($id)
183  );
184  if ($result->numRows() == 1)
185  {
186  return $ilDB->fetchAssoc($result);
187  }
188  else
189  {
190  return array();
191  }
192  }
193 
200  function loadFromDb($id)
201  {
202  global $ilDB;
203 
204  $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = svy_question.question_id WHERE svy_question.question_id = %s",
205  array('integer'),
206  array($id)
207  );
208  if ($result->numRows() == 1)
209  {
210  $data = $ilDB->fetchAssoc($result);
211  $this->setId($data["question_id"]);
212  $this->setTitle($data["title"]);
213  $this->setDescription($data["description"]);
214  $this->setObjId($data["obj_fi"]);
215  $this->setAuthor($data["author"]);
216  $this->setOwner($data["owner_fi"]);
217  $this->label = $data['label'];
218  include_once("./Services/RTE/classes/class.ilRTE.php");
219  $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
220  $this->setObligatory($data["obligatory"]);
221  $this->setComplete($data["complete"]);
222  $this->setOriginalId($data["original_id"]);
223  $this->setSubtype($data["subtype"]);
224 
225  $result = $ilDB->queryF("SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s",
226  array('integer'),
227  array($id)
228  );
229  if ($result->numRows() > 0)
230  {
231  if ($data = $ilDB->fetchAssoc($result))
232  {
233  $this->minimum = $data["value1"];
234  if (($data["value2"] < 0) or (strcmp($data["value2"], "") == 0))
235  {
236  $this->maximum = "";
237  }
238  else
239  {
240  $this->maximum = $data["value2"];
241  }
242  }
243  }
244  }
246  }
247 
254  function isComplete()
255  {
256  if ($this->title and $this->author and $this->questiontext)
257  {
258  return 1;
259  }
260  else
261  {
262  return 0;
263  }
264  }
265 
271  function saveToDb($original_id = "")
272  {
273  global $ilDB;
274 
275  $affectedRows = parent::saveToDb($original_id);
276  if ($affectedRows == 1)
277  {
278  $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
279  array('integer'),
280  array($this->getId())
281  );
282  $affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, subtype) VALUES (%s, %s)",
283  array('integer', 'text'),
284  array($this->getId(), $this->getSubType())
285  );
286 
287  // saving material uris in the database
288  $this->saveMaterial();
289 
290  // save categories
291  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
292  array('integer'),
293  array($this->getId())
294  );
295 
296  if (preg_match("/[\D]/", $this->maximum) or (strcmp($this->maximum, "&infin;") == 0))
297  {
298  $max = -1;
299  }
300  else
301  {
302  $max = $this->getMaximum();
303  }
304  $next_id = $ilDB->nextId('svy_variable');
305  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, value2, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
306  array('integer','integer','integer','float','float','integer','integer'),
307  array($next_id, 0, $this->getId(), $this->getMinimum(), $max, 0, time())
308  );
309  }
310  }
311 
318  function toXML($a_include_header = TRUE, $obligatory_state = "")
319  {
320  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
321  $a_xml_writer = new ilXmlWriter;
322  $a_xml_writer->xmlHeader();
323  $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
324  $xml = $a_xml_writer->xmlDumpMem(FALSE);
325  if (!$a_include_header)
326  {
327  $pos = strpos($xml, "?>");
328  $xml = substr($xml, $pos + 2);
329  }
330  return $xml;
331  }
332 
341  function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state = "")
342  {
343  $attrs = array(
344  "id" => $this->getId(),
345  "title" => $this->getTitle(),
346  "type" => $this->getQuestiontype(),
347  "subtype" => $this->getSubtype(),
348  "obligatory" => $this->getObligatory()
349  );
350  $a_xml_writer->xmlStartTag("question", $attrs);
351 
352  $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
353  $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
354  $a_xml_writer->xmlStartTag("questiontext");
355  $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
356  $a_xml_writer->xmlEndTag("questiontext");
357 
358  $a_xml_writer->xmlStartTag("responses");
359  switch ($this->getSubtype())
360  {
361  case 3:
362  $attrs = array(
363  "id" => "0",
364  "format" => "double"
365  );
366  if (strlen($this->getMinimum()))
367  {
368  $attrs["min"] = $this->getMinimum();
369  }
370  if (strlen($this->getMaximum()))
371  {
372  $attrs["max"] = $this->getMaximum();
373  }
374  break;
375  case 4:
376  $attrs = array(
377  "id" => "0",
378  "format" => "double"
379  );
380  if (strlen($this->getMinimum()))
381  {
382  $attrs["min"] = $this->getMinimum();
383  }
384  if (strlen($this->getMaximum()))
385  {
386  $attrs["max"] = $this->getMaximum();
387  }
388  break;
389  case 5:
390  $attrs = array(
391  "id" => "0",
392  "format" => "integer"
393  );
394  if (strlen($this->getMinimum()))
395  {
396  $attrs["min"] = $this->getMinimum();
397  }
398  if (strlen($this->getMaximum()))
399  {
400  $attrs["max"] = $this->getMaximum();
401  }
402  break;
403  }
404  $a_xml_writer->xmlStartTag("response_num", $attrs);
405  $a_xml_writer->xmlEndTag("response_num");
406 
407  $a_xml_writer->xmlEndTag("responses");
408 
409  if (count($this->material))
410  {
411  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
412  {
413  $attrs = array(
414  "label" => $this->material["title"]
415  );
416  $a_xml_writer->xmlStartTag("material", $attrs);
417  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
418  if (strcmp($matches[1], "") != 0)
419  {
420  $intlink = $this->material["internal_link"];
421  }
422  $a_xml_writer->xmlElement("mattext", NULL, $intlink);
423  $a_xml_writer->xmlEndTag("material");
424  }
425  }
426 
427  $a_xml_writer->xmlEndTag("question");
428  }
429 
436  function getQuestionTypeID()
437  {
438  global $ilDB;
439  $result = $ilDB->queryF("SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
440  array('text'),
441  array($this->getQuestionType())
442  );
443  $row = $ilDB->fetchAssoc($result);
444  return $row["questiontype_id"];
445  }
446 
453  function getQuestionType()
454  {
455  return "SurveyMetricQuestion";
456  }
457 
465  {
466  return "svy_qst_metric";
467  }
468 
475  function &getWorkingDataFromUserInput($post_data)
476  {
477  $entered_value = $post_data[$this->getId() . "_metric_question"];
478  $data = array();
479  if (strlen($entered_value))
480  {
481  array_push($data, array("value" => $entered_value));
482  }
483  return $data;
484  }
485 
495  function checkUserInput($post_data, $survey_id)
496  {
497  $entered_value = $post_data[$this->getId() . "_metric_question"];
498  // replace german notation with international notation
499  $entered_value = str_replace(",", ".", $entered_value);
500 
501  if ((!$this->getObligatory($survey_id)) && (strlen($entered_value) == 0)) return "";
502 
503  if (strlen($entered_value) == 0) return $this->lng->txt("survey_question_obligatory");
504 
505  if (strlen($this->getMinimum()))
506  {
507  if ($entered_value < $this->getMinimum())
508  {
509  return $this->lng->txt("metric_question_out_of_bounds");
510  }
511  }
512 
513  if (strlen($this->getMaximum()))
514  {
515  if (($this->getMaximum() == 1) && ($this->getMaximum() < $this->getMinimum()))
516  {
517  // old &infty; values as maximum
518  }
519  else
520  {
521  if ($entered_value > $this->getMaximum())
522  {
523  return $this->lng->txt("metric_question_out_of_bounds");
524  }
525  }
526  }
527 
528  if (!is_numeric($entered_value))
529  {
530  return $this->lng->txt("metric_question_not_a_value");
531  }
532 
533  if (($this->getSubType() == SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value)))
534  {
535  return $this->lng->txt("metric_question_floating_point");
536  }
537  return "";
538  }
539 
545  public function saveRandomData($active_id)
546  {
547  global $ilDB;
548  // single response
549  $number = rand($this->getMinimum(), (strlen($this->getMaximum())) ? $this->getMaximum() : 100);
550  $next_id = $ilDB->nextId('svy_answer');
551  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
552  array('integer','integer','integer','float','text','integer'),
553  array($next_id, $this->getId(), $active_id, $number, NULL, time())
554  );
555  }
556 
557  function saveUserInput($post_data, $active_id)
558  {
559  global $ilDB;
560 
561  $entered_value = $post_data[$this->getId() . "_metric_question"];
562  if (strlen($entered_value) == 0) return;
563  // replace german notation with international notation
564  $entered_value = str_replace(",", ".", $entered_value);
565  $next_id = $ilDB->nextId('svy_answer');
566  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
567  array('integer','integer','integer','float','text','integer'),
568  array($next_id, $this->getId(), $active_id, (strlen($entered_value)) ? $entered_value : NULL, NULL, time())
569  );
570  }
571 
572  function &getCumulatedResults($survey_id, $nr_of_users)
573  {
574  global $ilDB;
575 
576  $question_id = $this->getId();
577 
578  $result_array = array();
579  $cumulated = array();
580 
581  $result = $ilDB->queryF("SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_answer.question_fi = %s AND svy_finished.survey_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
582  array('integer', 'integer'),
583  array($question_id, $survey_id)
584  );
585 
586  while ($row = $ilDB->fetchAssoc($result))
587  {
588  $cumulated[$row["value"]]++;
589  }
590  asort($cumulated, SORT_NUMERIC);
591  end($cumulated);
592  $numrows = $result->numRows();
593  $result_array["USERS_ANSWERED"] = $result->numRows();
594  $result_array["USERS_SKIPPED"] = $nr_of_users - $result->numRows();
595  $result_array["MODE"] = key($cumulated);
596  $result_array["MODE_VALUE"] = key($cumulated);
597  $result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
598  ksort($cumulated, SORT_NUMERIC);
599  $counter = 0;
600  foreach ($cumulated as $value => $nr_of_users)
601  {
602  $percentage = 0;
603  if ($numrows > 0)
604  {
605  $percentage = (float)($nr_of_users/$numrows);
606  }
607  $result_array["values"][$counter++] = array("value" => $value, "selected" => (int)$nr_of_users, "percentage" => $percentage);
608  }
609  $median = array();
610  $total = 0;
611  $x_i = 0;
612  $p_i = 1;
613  $x_i_inv = 0;
614  $sum_part_zero = false;
615  foreach ($cumulated as $value => $key)
616  {
617  $total += $key;
618  for ($i = 0; $i < $key; $i++)
619  {
620  array_push($median, $value);
621  $x_i += $value;
622  $p_i *= $value;
623  if ($value != 0)
624  {
625  $sum_part_zero = true;
626  $x_i_inv += 1/$value;
627  }
628  }
629  }
630  if ($total > 0)
631  {
632  if (($total % 2) == 0)
633  {
634  $median_value = 0.5 * ($median[($total/2)-1] + $median[($total/2)]);
635  }
636  else
637  {
638  $median_value = $median[(($total+1)/2)-1];
639  }
640  }
641  else
642  {
643  $median_value = "";
644  }
645  if ($total > 0)
646  {
647  if (($x_i/$total) == (int)($x_i/$total))
648  {
649  $result_array["ARITHMETIC_MEAN"] = $x_i/$total;
650  }
651  else
652  {
653  $result_array["ARITHMETIC_MEAN"] = sprintf("%.2f", $x_i/$total);
654  }
655  }
656  else
657  {
658  $result_array["ARITHMETIC_MEAN"] = "";
659  }
660  $result_array["MEDIAN"] = $median_value;
661  $result_array["QUESTION_TYPE"] = "SurveyMetricQuestion";
662  return $result_array;
663  }
664 
672  function setExportDetailsXLS(&$adapter, &$eval_data, $export_label)
673  {
674  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
675  $adapter->addWorksheet($this->getTitle());
676  $adapter->setActiveWorksheet($adapter->getWorksheetCount()-1);
677  $rowcounter = 0;
678  switch ($export_label)
679  {
680  case 'label_only':
681  $adapter->setCellValue(0, 0, $this->lng->txt("label"), CELL_FORMAT_BOLD);
682  $adapter->setCellValue(0, 1, $this->label);
683  break;
684  case 'title_only':
685  $adapter->setCellValue(0, 0, $this->lng->txt("title"), CELL_FORMAT_BOLD);
686  $adapter->setCellValue(0, 1, $this->getTitle());
687  break;
688  default:
689  $adapter->setCellValue(0, 0, $this->lng->txt("title"), CELL_FORMAT_BOLD);
690  $adapter->setCellValue(0, 1, $this->getTitle());
691  $rowcounter++;
692  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("label"), CELL_FORMAT_BOLD);
693  $adapter->setCellValue($rowcounter, 1, $this->label);
694  break;
695  }
696  $rowcounter++;
697  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("question"), CELL_FORMAT_BOLD);
698  $adapter->setCellValue($rowcounter, 1, $this->getQuestiontext());
699  $rowcounter++;
700  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("question_type"), CELL_FORMAT_BOLD);
701  $adapter->setCellValue($rowcounter, 1, $this->lng->txt($this->getQuestionType()));
702  $rowcounter++;
703  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("users_answered"), CELL_FORMAT_BOLD);
704  $adapter->setCellValue($rowcounter, 1, $eval_data["TOTAL"]["USERS_ANSWERED"]);
705  $rowcounter++;
706  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("users_skipped"), CELL_FORMAT_BOLD);
707  $adapter->setCellValue($rowcounter, 1, $eval_data["TOTAL"]["USERS_SKIPPED"]);
708  $rowcounter++;
709 
710  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("subtype"), CELL_FORMAT_BOLD);
711  switch ($this->getSubtype())
712  {
713  case SUBTYPE_NON_RATIO:
714  $adapter->setCellValue($rowcounter++, 1, $this->lng->txt("non_ratio"), CELL_FORMAT_BOLD);
715  break;
717  $adapter->setCellValue($rowcounter++, 1, $this->lng->txt("ratio_non_absolute"), CELL_FORMAT_BOLD);
718  break;
720  $adapter->setCellValue($rowcounter++, 1, $this->lng->txt("ratio_absolute"), CELL_FORMAT_BOLD);
721  break;
722  }
723  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("mode"), CELL_FORMAT_BOLD);
724  $adapter->setCellValue($rowcounter++, 1, $eval_data["MODE"]);
725  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("mode_text"), CELL_FORMAT_BOLD);
726  $adapter->setCellValue($rowcounter++, 1, $eval_data["MODE"]);
727  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("mode_nr_of_selections"), CELL_FORMAT_BOLD);
728  $adapter->setCellValue($rowcounter++, 1, $eval_data["MODE_NR_OF_SELECTIONS"]);
729  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("median"), CELL_FORMAT_BOLD);
730  $adapter->setCellValue($rowcounter++, 1, $eval_data["MEDIAN"]);
731  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("arithmetic_mean"), CELL_FORMAT_BOLD);
732  $adapter->setCellValue($rowcounter++, 1, $eval_data["ARITHMETIC_MEAN"]);
733  $adapter->setCellValue($rowcounter, 0, $this->lng->txt("values"), CELL_FORMAT_BOLD);
734  $adapter->setCellValue($rowcounter, 1, $this->lng->txt("value"), CELL_FORMAT_TITLE);
735  $adapter->setCellValue($rowcounter, 2, $this->lng->txt("category_nr_selected"), CELL_FORMAT_TITLE);
736  $adapter->setCellValue($rowcounter++, 3, $this->lng->txt("percentage_of_selections"), CELL_FORMAT_TITLE);
737  $values = "";
738  if (is_array($eval_data["values"]))
739  {
740  foreach ($eval_data["values"] as $key => $value)
741  {
742  $adapter->setCellValue($rowcounter, 1, $value["value"]);
743  $adapter->setCellValue($rowcounter, 2, $value["selected"]);
744  $adapter->setCellValue($rowcounter++, 3, $value["percentage"], CELL_FORMAT_PERCENT);
745  }
746  }
747  }
748 
756  function addUserSpecificResultsData(&$a_array, &$resultset)
757  {
758  if (count($resultset["answers"][$this->getId()]))
759  {
760  foreach ($resultset["answers"][$this->getId()] as $key => $answer)
761  {
762  array_push($a_array, $answer["value"]);
763  }
764  }
765  else
766  {
767  array_push($a_array, $this->lng->txt("skipped"));
768  }
769  }
770 
779  {
780  global $ilDB;
781 
782  $answers = array();
783 
784  $result = $ilDB->queryF("SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_finished.survey_fi = %s AND svy_answer.question_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
785  array('integer','integer'),
786  array($survey_id, $this->getId())
787  );
788  while ($row = $ilDB->fetchAssoc($result))
789  {
790  $answers[$row["active_fi"]] = $row["value"];
791  }
792  return $answers;
793  }
794 
801  function importResponses($a_data)
802  {
803  foreach ($a_data as $id => $data)
804  {
805  $this->setMinimum($data["min"]);
806  $this->setMaximum($data["max"]);
807  }
808  }
809 
817  {
818  return TRUE;
819  }
820 
828  {
829  return array("<", "<=", "=", "<>", ">=", ">");
830  }
831 
838  function outPreconditionSelectValue(&$template)
839  {
840  $template->setCurrentBlock("textfield");
841  $template->setVariable("TEXTFIELD_VALUE", "");
842  $template->parseCurrentBlock();
843  }
844 
851  public function getPreconditionSelectValue($default = "", $title, $variable)
852  {
853  include_once "./Services/Form/classes/class.ilNumberInputGUI.php";
854  $step3 = new ilNumberInputGUI($title, $variable);
855  $step3->setValue($default);
856  return $step3;
857  }
858 
867  function outChart($survey_id, $type = "")
868  {
869  if (count($this->cumulated) == 0)
870  {
871  include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
873  $this->cumulated =& $this->getCumulatedResults($survey_id, $nr_of_users);
874  }
875 
876  foreach ($this->cumulated["values"] as $key => $value)
877  {
878  foreach ($value as $key2 => $value2)
879  {
880  $this->cumulated["variables"][$key][$key2] = utf8_decode($value2);
881  }
882  }
883  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyChart.php";
884  $b1 = new SurveyChart("bars",400,250,utf8_decode($this->getTitle()),utf8_decode($this->lng->txt("answers")),utf8_decode($this->lng->txt("users_answered")),$this->cumulated["values"]);
885  }
886 
893  function getMinMaxText()
894  {
895  $min = $this->getMinimum();
896  $max = $this->getMaximum();
897  if (strlen($min) && strlen($max))
898  {
899  return "(" . $min . " " . strtolower($this->lng->txt("to")) . " " . $max . ")";
900  }
901  else if (strlen($min))
902  {
903  return "(&gt;= " . $min . ")";
904  }
905  else if (strlen($max))
906  {
907  return "(&lt;= " . $max . ")";
908  }
909  else
910  {
911  return "";
912  }
913  }
914 }
915 ?>