Example #1
0
function do_hugefreetext($ia)
{
    global $thissurvey;
    $extraclass = "";
    if ($thissurvey['nokeyboard'] == 'Y') {
        includeKeypad();
        $kpclass = "text-keypad";
        $extraclass .= " inputkeypad";
    } else {
        $kpclass = "";
    }
    $checkconditionFunction = "checkconditions";
    $aQuestionAttributes = getQuestionAttributeValues($ia[0]);
    if (intval(trim($aQuestionAttributes['maximum_chars'])) > 0) {
        // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea
        $maximum_chars = intval(trim($aQuestionAttributes['maximum_chars']));
        $maxlength = "maxlength='{$maximum_chars}' ";
        $extraclass .= " maxchars maxchars-" . $maximum_chars;
    } else {
        $maxlength = "";
    }
    // --> START ENHANCEMENT - DISPLAY ROWS
    if (trim($aQuestionAttributes['display_rows']) != '') {
        $drows = $aQuestionAttributes['display_rows'];
    } else {
        $drows = 30;
    }
    // <-- END ENHANCEMENT - DISPLAY ROWS
    // --> START ENHANCEMENT - TEXT INPUT WIDTH
    if (trim($aQuestionAttributes['text_input_width']) != '') {
        $tiwidth = $aQuestionAttributes['text_input_width'];
        $extraclass .= " inputwidth-" . trim($aQuestionAttributes['text_input_width']);
    } else {
        $tiwidth = 70;
    }
    // <-- END ENHANCEMENT - TEXT INPUT WIDTH
    // --> START NEW FEATURE - SAVE
    $answer = "<p class=\"question answer-item text-item {$extraclass}\"><label for='answer{$ia[1]}' class='hide label'>" . gT('Your answer') . "</label>";
    $answer .= '<textarea class="textarea ' . $kpclass . '" name="' . $ia[1] . '" id="answer' . $ia[1] . '" ' . 'rows="' . $drows . '" cols="' . $tiwidth . '" ' . $maxlength . ' onkeyup="' . $checkconditionFunction . '(this.value, this.name, this.type)" >';
    // --> END NEW FEATURE - SAVE
    if ($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]) {
        $answer .= str_replace("\\", "", $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]);
    }
    $answer .= "</textarea>\n";
    $answer .= "</p>";
    if (trim($aQuestionAttributes['time_limit']) != '') {
        $answer .= return_timer_script($aQuestionAttributes, $ia, "answer" . $ia[1]);
    }
    $inputnames[] = $ia[1];
    return array($answer, $inputnames);
}
Example #2
0
function do_hugefreetext($ia)
{
    global $thissurvey;
    $extraclass = "";
    if ($thissurvey['nokeyboard'] == 'Y') {
        includeKeypad();
        $kpclass = "text-keypad";
        $extraclass .= " inputkeypad";
    } else {
        $kpclass = "";
    }
    $checkconditionFunction = "checkconditions";
    $aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]);
    if (intval(trim($aQuestionAttributes['maximum_chars'])) > 0) {
        // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea
        $maximum_chars = intval(trim($aQuestionAttributes['maximum_chars']));
        $maxlength = "maxlength='{$maximum_chars}' ";
        $extraclass .= " maxchars maxchars-" . $maximum_chars;
    } else {
        $maxlength = "";
    }
    if (trim($aQuestionAttributes['display_rows']) != '') {
        $drows = $aQuestionAttributes['display_rows'];
    } else {
        $drows = 30;
    }
    if (trim($aQuestionAttributes['text_input_width']) != '') {
        $tiwidth = $aQuestionAttributes['text_input_width'];
        $extraclass .= " inputwidth-" . trim($aQuestionAttributes['text_input_width']);
        $col = $aQuestionAttributes['text_input_width'] <= 12 ? $aQuestionAttributes['text_input_width'] : 12;
        $extraclass .= " col-sm-" . trim($col);
    } else {
        $tiwidth = 70;
    }
    $dispVal = "";
    if ($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]) {
        $dispVal = htmlspecialchars($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]);
    }
    $itemDatas = array('extraclass' => $extraclass, 'kpclass' => $kpclass, 'name' => $ia[1], 'drows' => $drows, 'checkconditionFunction' => $checkconditionFunction . '(this.value, this.name, this.type)', 'dispVal' => $dispVal, 'tiwidth' => $tiwidth, 'maxlength' => $maxlength);
    $answer = doRender('/survey/questions/longfreetext/answer', $itemDatas, true);
    if (trim($aQuestionAttributes['time_limit']) != '') {
        $answer .= return_timer_script($aQuestionAttributes, $ia, "answer" . $ia[1]);
    }
    $inputnames = array();
    $inputnames[] = $ia[1];
    return array($answer, $inputnames);
}
Example #3
0
 public function doQuestion($ia)
 {
     global $thissurvey;
     if ($thissurvey['nokeyboard'] == 'Y') {
         includeKeypad();
         $kpclass = "text-keypad";
     } else {
         $kpclass = "";
     }
     $checkconditionFunction = "checkconditions";
     $aQuestionAttributes = getQuestionAttributeValues($ia[0]);
     $query = "SELECT other FROM {{questions}} WHERE qid=" . $ia[0] . " AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ";
     $result = Yii::app()->db->createCommand($query)->query();
     foreach ($result->readAll() as $row) {
         $other = $row['other'];
     }
     //question attribute random order set?
     if ($aQuestionAttributes['random_order'] == 1) {
         $ansquery = "SELECT * FROM {{answers}} WHERE qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY " . dbRandom();
     } elseif ($aQuestionAttributes['alphasort'] == 1) {
         $ansquery = "SELECT * FROM {{answers}} WHERE qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY answer";
     } else {
         $ansquery = "SELECT * FROM {{answers}} WHERE qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY sortorder, answer";
     }
     $ansresult = dbExecuteAssoc($ansquery)->readAll();
     //Checked
     $anscount = count($ansresult);
     if (trim($aQuestionAttributes['display_columns']) != '') {
         $dcols = $aQuestionAttributes['display_columns'];
     } else {
         $dcols = 1;
     }
     if (trim($aQuestionAttributes['other_replace_text'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '') {
         $othertext = $aQuestionAttributes['other_replace_text'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']];
     } else {
         $othertext = gT('Other:');
     }
     if (isset($other) && $other == 'Y') {
         $anscount++;
     }
     //Count up for the Other answer
     if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {
         $anscount++;
     }
     //Count up if "No answer" is showing
     $wrapper = setupColumns($dcols, $anscount, "answers-list radio-list", "answer-item radio-item");
     $iBootCols = round(12 / $dcols);
     $ansByCol = round($anscount / $dcols);
     $ansByCol = $ansByCol > 0 ? $ansByCol : 1;
     //$answer = 'IKI: '.$iBootCols.' '.$ansByCol.' '.$wrapper['whole-start'];
     $answer = '<div class="row">';
     $answer .= '    <div class="col-xs-' . $iBootCols . '">AAAAAAAAAAAAAA';
     //Time Limit Code
     if (trim($aQuestionAttributes['time_limit']) != '') {
         $answer .= return_timer_script($aQuestionAttributes, $ia);
     }
     //End Time Limit Code
     // Get array_filter stuff
     $rowcounter = 0;
     $colcounter = 1;
     $trbc = '';
     foreach ($ansresult as $key => $ansrow) {
         $myfname = $ia[1] . $ansrow['code'];
         $check_ans = '';
         if ($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] == $ansrow['code']) {
             $check_ans = CHECKED;
         }
         list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "div", "form-group answer-item radio-item");
         /*    if(substr($wrapper['item-start'],0,4) == "\t<li")
                     {
                         $startitem = "\t$htmltbody2\n";
                     } else {
                         $startitem = $wrapper['item-start'];
                     }
         
                     $answer .= $startitem;*/
         $answer .= "\t{$hiddenfield}\n";
         $answer .= '<div  class="form-group">';
         $answer .= '    <label for="answer' . $ia[1] . $ansrow['code'] . '" class="answertext control-label">' . $ansrow['answer'] . '</label>';
         $answer .= '        <input class="radio" type="radio" value="' . $ansrow['code'] . '" name="' . $ia[1] . '" id="answer' . $ia[1] . $ansrow['code'] . '"' . $check_ans . ' onclick="if (document.getElementById(\'answer' . $ia[1] . 'othertext\') != null) document.getElementById(\'answer' . $ia[1] . 'othertext\').value=\'\';' . $checkconditionFunction . '(this.value, this.name, this.type)" />';
         $answer .= $wrapper['item-end'];
         $answer .= '</div>';
         ++$rowcounter;
         //if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols'] || (count($ansresult)-$key)==$wrapper['cols']-$colcounter)
         if ($rowcounter == $ansByCol && $colcounter < $wrapper['cols']) {
             if ($colcounter == $wrapper['cols']) {
                 //$answer .= 'là '.$wrapper['col-devide-last'];
                 $answer .= '    </div><!-- last -->';
             } else {
                 //$answer .= 'et là '.$wrapper['col-devide'];
                 $answer .= '    </div><!-- devide --> ';
                 $answer .= '    <div class="col-xs-' . $iBootCols . '">';
             }
             $rowcounter = 0;
             ++$colcounter;
         }
     }
     if (isset($other) && $other == 'Y') {
         $sSeparator = getRadixPointData($thissurvey['surveyls_numberformat']);
         $sSeparator = $sSeparator['separator'];
         if ($aQuestionAttributes['other_numbers_only'] == 1) {
             $oth_checkconditionFunction = 'fixnum_checkconditions';
         } else {
             $oth_checkconditionFunction = 'checkconditions';
         }
         if ($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] == '-oth-') {
             $check_ans = CHECKED;
         } else {
             $check_ans = '';
         }
         $thisfieldname = $ia[1] . 'other';
         if (isset($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$thisfieldname])) {
             $dispVal = $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$thisfieldname];
             if ($aQuestionAttributes['other_numbers_only'] == 1) {
                 $dispVal = str_replace('.', $sSeparator, $dispVal);
             }
             $answer_other = ' value="' . htmlspecialchars($dispVal, ENT_QUOTES) . '"';
         } else {
             $answer_other = ' value=""';
         }
         list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, array("code" => "other"), $thisfieldname, $trbc, $myfname, "div", "form-group answer-item radio-item other-item other");
         $answer .= "\t{$hiddenfield}\n";
         $answer .= '<div  class="form-group">';
         $answer .= '    <label for="SOTH' . $ia[1] . '" class="answertext control-label">' . $othertext . '</label>';
         $answer .= '    <input class="radio" type="radio" value="-oth-" name="' . $ia[1] . '" id="SOTH' . $ia[1] . '"' . $check_ans . ' onclick="' . $checkconditionFunction . '(this.value, this.name, this.type)" />';
         $answer .= '    <input type="text" class="text ' . $kpclass . '" id="answer' . $ia[1] . 'othertext" name="' . $ia[1] . 'other" title="' . gT('Other') . '"' . $answer_other . ' onkeyup="if($.trim($(this).val())!=\'\'){ $(\'#SOTH' . $ia[1] . '\').click(); }; ' . $oth_checkconditionFunction . '(this.value, this.name, this.type);" />';
         $answer .= $wrapper['item-end'];
         $answer .= '</div>';
         $inputnames[] = $thisfieldname;
         ++$rowcounter;
         if ($rowcounter == $ansByCol && $colcounter < $wrapper['cols']) {
             if ($colcounter == $wrapper['cols']) {
                 $answer .= '    </div><!-- last -->';
             } else {
                 $answer .= '    </div><!-- devide -->';
                 $answer .= '    <div class="col-xs-' . $iBootCols . '">';
             }
             $rowcounter = 0;
             ++$colcounter;
         }
     }
     if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {
         if (!isset($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]]) || $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] == '' || $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] == ' ') {
             $check_ans = CHECKED;
             //Check the "no answer" radio button if there is no answer in session.
         } else {
             $check_ans = '';
         }
         $answer .= '<div  class="form-group">';
         $answer .= '    <label for="answer' . $ia[1] . 'NANS" class="answertext control-label">' . gT('No answer') . '</label>';
         $answer .= '        <input class="radio" type="radio" name="' . $ia[1] . '" id="answer' . $ia[1] . 'NANS" value=""' . $check_ans . ' onclick="if (document.getElementById(\'answer' . $ia[1] . 'othertext\') != null) document.getElementById(\'answer' . $ia[1] . 'othertext\').value=\'\';' . $checkconditionFunction . '(this.value, this.name, this.type)" />';
         $answer .= $wrapper['item-end'];
         $answer .= '</div>';
         // --> END NEW FEATURE - SAVE
         ++$rowcounter;
         //if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols'])
         if ($rowcounter == $ansByCol && $colcounter < $wrapper['cols']) {
             if ($colcounter == $wrapper['cols']) {
                 //$answer .= $wrapper['col-devide-last'];
                 $answer .= '    </div><!-- last -->';
             } else {
                 //$answer .= $wrapper['col-devide'];
                 $answer .= '    </div><!-- devide -->';
                 $answer .= '    <div class="col-xs-' . $iBootCols . '">';
             }
             $rowcounter = 0;
             ++$colcounter;
         }
     }
     //END OF ITEMS
     //$answer .= $wrapper['whole-end'].'
     $answer .= '    <input type="hidden" name="java' . $ia[1] . '" id="java' . $ia[1] . "\" value=\"" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$ia[1]] . "\" />\n";
     $answer .= '</div> <!-- wrapper row -->';
     $inputnames[] = $ia[1];
     return array($answer, $inputnames);
 }
Example #4
0
function do_hugefreetext($ia)
{
    global $clang;

    if ($ia[8] == 'Y')
    {
        $checkconditionFunction = "checkconditions";
    }
    else
    {
        $checkconditionFunction = "noop_checkconditions";
    }

    $qidattributes=getQuestionAttributes($ia[0],$ia[4]);

    if (trim($qidattributes['maximum_chars'])!='')
    {
        $maxsize=$qidattributes['maximum_chars'];
    }
    else
    {
        $maxsize=65525;
    }

    // --> START ENHANCEMENT - DISPLAY ROWS
    if (trim($qidattributes['display_rows'])!='')
    {
        $drows=$qidattributes['display_rows'];
    }
    else
    {
        $drows=30;
    }
    // <-- END ENHANCEMENT - DISPLAY ROWS

    // --> START ENHANCEMENT - TEXT INPUT WIDTH
    if (trim($qidattributes['text_input_width'])!='')
    {
        $tiwidth=$qidattributes['text_input_width'];
    }
    else
    {
        $tiwidth=70;
    }
    // <-- END ENHANCEMENT - TEXT INPUT WIDTH

    $answer = "<script type='text/javascript'>
               <!--
               function textLimit(field, maxlen) {
                if (document.getElementById(field).value.length > maxlen)
                document.getElementById(field).value = document.getElementById(field).value.substring(0, maxlen);
                }
               //-->
               </script>\n";
    // --> START ENHANCEMENT - DISPLAY ROWS
    // --> START ENHANCEMENT - TEXT INPUT WIDTH

    // --> START NEW FEATURE - SAVE
    $answer .= '<textarea class="textarea" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
    .'rows="'.$drows.'" cols="'.$tiwidth.'" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
    // --> END NEW FEATURE - SAVE

    // <-- END ENHANCEMENT - TEXT INPUT WIDTH
    // <-- END ENHANCEMENT - DISPLAY ROWS

    if ($_SESSION[$ia[1]]) {$answer .= str_replace("\\", "", $_SESSION[$ia[1]]);}

    $answer .= "</textarea>\n";

    if (trim($qidattributes['time_limit']) != '')
    {
		$js_header_includes[] = '/scripts/coookies.js';
        $answer .= return_timer_script($qidattributes, $ia, "answer".$ia[1]);
    }

    $inputnames[]=$ia[1];
    return array($answer, $inputnames);
}
Example #5
0
function do_hugefreetext($ia)
{
    global $clang, $js_header_includes, $thissurvey;
    if ($thissurvey['nokeyboard'] == 'Y') {
        vIncludeKeypad();
        $kpclass = "text-keypad";
    } else {
        $kpclass = "";
    }
    $checkconditionFunction = "checkconditions";
    $qidattributes = getQuestionAttributes($ia[0], $ia[4]);
    if (intval(trim($qidattributes['maximum_chars'])) > 0) {
        // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea
        $maximum_chars = intval(trim($qidattributes['maximum_chars']));
        $maxlength = "maxlength='{$maximum_chars}' ";
    } else {
        $maxlength = "";
    }
    // --> START ENHANCEMENT - DISPLAY ROWS
    if (trim($qidattributes['display_rows']) != '') {
        $drows = $qidattributes['display_rows'];
    } else {
        $drows = 30;
    }
    // <-- END ENHANCEMENT - DISPLAY ROWS
    // --> START ENHANCEMENT - TEXT INPUT WIDTH
    if (trim($qidattributes['text_input_width']) != '') {
        $tiwidth = $qidattributes['text_input_width'];
    } else {
        $tiwidth = 70;
    }
    // <-- END ENHANCEMENT - TEXT INPUT WIDTH
    // --> START NEW FEATURE - SAVE
    $answer = '<label for="answer' . $ia[1] . '" class="hide label">' . $clang->gT('Answer') . '</label><textarea class="textarea ' . $kpclass . '" name="' . $ia[1] . '" id="answer' . $ia[1] . '" ' . 'rows="' . $drows . '" cols="' . $tiwidth . '" ' . $maxlength . ' onchange="' . $checkconditionFunction . '(this.value, this.name, this.type)" >';
    // --> END NEW FEATURE - SAVE
    if ($_SESSION[$ia[1]]) {
        $answer .= str_replace("\\", "", $_SESSION[$ia[1]]);
    }
    $answer .= "</textarea>\n";
    if (trim($qidattributes['time_limit']) != '') {
        $js_header_includes[] = '/scripts/coookies.js';
        $answer .= return_timer_script($qidattributes, $ia, "answer" . $ia[1]);
    }
    $inputnames[] = $ia[1];
    return array($answer, $inputnames);
}
Example #6
0
function do_hugefreetext($ia)
{
    global $clang, $js_header_includes, $thissurvey;
    if ($thissurvey['nokeyboard'] == 'Y') {
        vIncludeKeypad();
        $kpclass = "text-keypad";
    } else {
        $kpclass = "";
    }
    if ($ia[8] == 'Y') {
        $checkconditionFunction = "checkconditions";
    } else {
        $checkconditionFunction = "noop_checkconditions";
    }
    $qidattributes = getQuestionAttributes($ia[0], $ia[4]);
    if (trim($qidattributes['maximum_chars']) != '') {
        $maxsize = $qidattributes['maximum_chars'];
    } else {
        $maxsize = 65525;
    }
    // --> START ENHANCEMENT - DISPLAY ROWS
    if (trim($qidattributes['display_rows']) != '') {
        $drows = $qidattributes['display_rows'];
    } else {
        $drows = 30;
    }
    // <-- END ENHANCEMENT - DISPLAY ROWS
    // --> START ENHANCEMENT - TEXT INPUT WIDTH
    if (trim($qidattributes['text_input_width']) != '') {
        $tiwidth = $qidattributes['text_input_width'];
    } else {
        $tiwidth = 70;
    }
    // <-- END ENHANCEMENT - TEXT INPUT WIDTH
    // --> START NEW FEATURE - SAVE
    $answer = '<textarea class="textarea ' . $kpclass . '" name="' . $ia[1] . '" id="answer' . $ia[1] . '" alt="' . $clang->gT('Answer') . '" ' . 'rows="' . $drows . '" cols="' . $tiwidth . '" maxlength="' . $maxsize . '" onchange="textLimit(\'answer' . $ia[1] . '\', ' . $maxsize . ');" onkeyup="textLimit(\'answer' . $ia[1] . '\', ' . $maxsize . '); ' . $checkconditionFunction . '(this.value, this.name, this.type)">';
    // --> END NEW FEATURE - SAVE
    if ($_SESSION[$ia[1]]) {
        $answer .= str_replace("\\", "", $_SESSION[$ia[1]]);
    }
    $answer .= "</textarea>\n";
    if (trim($qidattributes['time_limit']) != '') {
        $js_header_includes[] = '/scripts/coookies.js';
        $answer .= return_timer_script($qidattributes, $ia, "answer" . $ia[1]);
    }
    $inputnames[] = $ia[1];
    return array($answer, $inputnames);
}