18 require_once dirname(__FILE__).
'/../../form_question_rule/form_question_rule.inc';
43 parent::__construct($assetid);
58 '==' => translate(
'core_form_rule_comparison_=='),
59 '!=' => translate(
'core_form_rule_comparison_!='),
60 '>' => translate(
'core_form_rule_comparison_>'),
61 '<' => translate(
'core_form_rule_comparison_<'),
62 '>=' => translate(
'core_form_rule_comparison_>='),
63 '<=' => translate(
'core_form_rule_comparison_<='),
85 $operator = array_get_index($rule_data,
'operator', 1);
86 $cq_id = array_get_index($rule_data,
'comparison_question_id', 0);
87 $value = array_get_index($rule_data,
'value',
'');
92 $comparison =
'form.elements["q'.$cq_id.
'"].value';
94 $comparison =
'"'.addslashes($value).
'"';
100 ?>
if (!(parseFloat(form.elements[
"q<?php echo $q_asset->id; ?>"].value) <?php echo $operator ?> parseFloat(<?php echo $comparison ?>))) {<?php
102 ?>
if (!(form.elements[
"q<?php echo $q_asset->id; ?>"].value <?php echo $operator ?> <?php echo $comparison ?>)) {<?php
104 ?>submission_errors[submission_errors.length] =
"<?php
105 if (empty($rule_data['custom_text'])) {
106 echo addslashes($this->defaultError($q_asset, $rule_data));
108 echo addslashes($rule_data['custom_text']);
114 $contents = ob_get_contents();
137 function evaluate($answer, $rule_data)
139 $operator = array_get_index($rule_data,
'operator',
'==');
140 $cq_id = array_get_index($rule_data,
'comparison_question_id', 0);
141 $value = array_get_index($rule_data,
'value',
'');
144 $comparison_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($cq_id);
145 $value = $comparison_asset->getValue();
150 $valid = ($answer == $value);
154 $valid = ($answer != $value);
158 $valid = ($answer > $value);
162 $valid = ($answer >= $value);
166 $valid = ($answer < $value);
170 $valid = ($answer <= $value);
190 $operator = array_get_index($rule_data,
'operator',
'==');
191 $cq_id = array_get_index($rule_data,
'comparison_question_id', 0);
192 $value = array_get_index($rule_data,
'value',
'');
194 if (($value ==
'') && ($operator ==
'!=')) {
195 if (strlen($q_asset->attr(
'cust_required_error'))) {
196 $error_str = $q_asset->attr(
'cust_required_error');
198 $error_str = translate(
'core_form_rule_comparison_required', $q_asset->attr(
'name'));
202 $string_code =
'core_form_rule_comparison_desc_'.$operator;
205 $string_code .=
'_q';
206 $comparison = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($cq_id);
207 $value = $comparison->name;
209 $value = array_get_index($rule_data,
'value',
'');
212 $error_str = translate($string_code, $q_asset->name, $value);