/**
  * Parse the data for the variables
  * @param  array $data Data describing the variables indexed by the variable label
  */
 private function unserialize_vars($data)
 {
     $i = 1;
     $this->vars[] = array();
     foreach ($data as $label => $fields) {
         if (!isset($this->options[$i])) {
             $opt = new OptionENHANCEDCALC($this->_mysqli, $this->_user_id, $this, $i, $this->_lang_strings, array('min' => $fields['min'], 'max' => $fields['max'], 'decimals' => $fields['dec'], 'increment' => $fields['inc']));
             $opt->set_variable($label);
             $this->options[$i] = $opt;
         } else {
             $old_opt = $this->options[$i];
             $opt = new OptionENHANCEDCALC($this->_mysqli, $this->_user_id, $this, $i, $this->_lang_strings, array('formula' => $old_opt->get_formula(), 'units' => $old_opt->get_units(), 'min' => $fields['min'], 'max' => $fields['max'], 'decimals' => $fields['dec'], 'increment' => $fields['inc']));
             $opt->set_variable($label);
             $this->options[$i] = $opt;
         }
         $opt->id = $i;
         $this->vars[] = $i;
         $this->_variable_map[$label] = $i;
         $i++;
     }
 }
Esempio n. 2
0
?>
</th>
            </tr>
          </thead>
<?php 
$index = 1;
$options = array_filter($question->options, function ($var) {
    return $var->get_variable() != '';
});
foreach ($options as $variable) {
    include 'options/opt_enhancedcalc.php';
    $index++;
}
for ($index; $index <= count($labels); $index++) {
    $variable = new OptionENHANCEDCALC($mysqli, $userObject->get_user_ID(), $question, $index, $string, array());
    $variable->set_variable('$' . $labels[$index - 1]);
    include 'options/opt_enhancedcalc.php';
}
if ($question->get_locked() == '') {
    ?>
          <tbody class="add-option-holder">
            <tr>
              <th>&nbsp;</th>
              <td colspan="4">
                <input name="next-option" class="next-option" value="<?php 
    echo $string['addoptions'];
    ?>
" type="button">
              </td>
            </tr>
          </tbody>