function showTest($content = "")
 {
     $returnStr = $this->showToolsHeader(Language::headerToolsTester());
     $returnStr .= $content;
     $surveys = new Surveys();
     $surveys = $surveys->getSurveys();
     if (sizeof($surveys) > 0) {
         $returnStr .= "<form id=refreshform method=post>";
         $returnStr .= '<input type=hidden name=page value="translator.tools.test">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">';
         $returnStr .= "</form>";
         $returnStr .= "<form method=post>";
         $returnStr .= '<input type=hidden name=' . POST_PARAM_SE . ' value="' . addslashes(USCIC_SURVEY) . '">';
         $returnStr .= '<input type=hidden name=' . POST_PARAM_PRIMKEY . ' value="' . addslashes(encryptC(generateRandomPrimkey(8), Config::directLoginKey())) . '">';
         $returnStr .= '<input type=hidden name=' . POST_PARAM_NEW_PRIMKEY . ' value="1">';
         $returnStr .= '<input type=hidden name=' . POST_PARAM_SURVEY_EXECUTION_MODE . ' value="' . SURVEY_EXECUTION_MODE_TEST . '">';
         $returnStr .= '<span class="label label-default">' . Language::labelToolsTestSettings() . '</span>';
         $returnStr .= '<div class="well well-sm">';
         $returnStr .= $this->displayComboBox();
         $returnStr .= '<table>';
         $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>";
         $current = new Survey(getSurvey());
         foreach ($surveys as $survey) {
             $selected = "";
             if ($survey->getSuid() == $current->getSuid()) {
                 $selected = "SELECTED";
             }
             $returnStr .= "<option {$selected} value=" . $survey->getSuid() . '>' . $survey->getName() . '</option>';
         }
         $returnStr .= "</select></td></tr>";
         $user = new User($_SESSION['URID']);
         $cm = getSurveyMode();
         $cl = getSurveyLanguage();
         $modes = $user->getModes(getSurvey());
         $langs = explode("~", $user->getLanguages(getSurvey(), getSurveyMode()));
         $default = $current->getDefaultLanguage();
         if (!inArray($default, $langs)) {
             $langs[] = $default;
         }
         $returnStr .= "<tr><td>" . Language::labelTestModeInput() . "</td><td>" . $this->displayModesAdmin(POST_PARAM_MODE, POST_PARAM_MODE, getSurveyMode(), "", implode("~", $modes), "onchange='document.getElementById(\"" . SMS_POST_MODE . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();'") . "</td></tr>";
         $returnStr .= "<tr><td>" . Language::labelTestLanguage() . "</td><td>" . $this->displayLanguagesAdmin(POST_PARAM_LANGUAGE, POST_PARAM_LANGUAGE, getSurveyLanguage(), true, true, false, "", implode("~", $langs)) . "</td></tr>";
         $returnStr .= '</table>';
         $returnStr .= '</div>';
         $returnStr .= '<button type="submit" class="btn btn-default navbar-btn">' . Language::buttonTest() . '</button>';
         $returnStr .= "</form>";
     } else {
         $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable());
     }
     $returnStr .= '</p></div></div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }
Beispiel #2
0
 function handleGroupAction($selected, $action, &$groupcookievalue)
 {
     $surveys = array();
     $displaySysAdmin = new DisplaySysAdmin();
     switch ($action) {
         case 'edit':
             $settings = $this->getBatchEditorGroupProperties();
             $tosave = array();
             $tocompile = array();
             $changed = array();
             foreach ($settings as $set) {
                 if (loadvar($set . "_checkbox") == 1) {
                     $val = loadvarAllowHTML($set);
                     if ($val != "") {
                         foreach ($selected as $sel) {
                             $s = explode("~", $sel);
                             if (isset($surveys[$s[0]])) {
                                 $survey = $surveys[$s[0]];
                             } else {
                                 $survey = new Survey($s[0]);
                                 $surveys[$s[0]] = $survey;
                                 $tocompile[] = $s[0];
                             }
                             if (isset($tosave[$sel])) {
                                 $group = $tosave[$sel];
                             } else {
                                 $group = $survey->getGroup($s[1]);
                                 $tosave[$sel] = $group;
                             }
                             if (isset($changed[$s[0]])) {
                                 $arr = $changed[$s[0]];
                                 if (isset($arr[$sel]) == false) {
                                     $arr[$sel] = $group;
                                     $changed[$s[0]] = $arr;
                                 }
                             } else {
                                 $arr = array();
                                 $arr[$sel] = $group;
                                 $changed[$s[0]] = $arr;
                             }
                             $group->setSettingValue($set, $val);
                             if ($set == SETTING_GROUP_TEMPLATE && $val == TABLE_TEMPLATE_CUSTOM) {
                                 $group->setSettingValue(SETTING_GROUP_CUSTOM_TEMPLATE, loadvarAllowHTML(SETTING_GROUP_CUSTOM_TEMPLATE));
                             }
                         }
                     }
                 }
             }
             /* save */
             foreach ($tosave as $to) {
                 $to->save();
             }
             /* compile */
             foreach ($tocompile as $comp) {
                 if (isset($surveys[$comp])) {
                     $survey = $surveys[$comp];
                 } else {
                     $survey = new Survey($comp);
                     $surveys[$comp] = $survey;
                 }
                 $compiler = new Compiler($comp, getSurveyVersion($surveys[$comp]));
                 $mess = $compiler->generateGroups($changed[$comp]);
                 $mess = $compiler->generateGetFillsGroups($changed[$comp]);
                 $mess = $compiler->generateInlineFieldsGroups($changed[$comp]);
             }
             if ($changed) {
                 $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorEdited(Language::labelGroupsLower()));
             } else {
                 $content = $displaySysAdmin->displayWarning(Language::messageToolsBatchEditorNotEdited());
             }
             break;
             break;
         case 'copy':
             // determine survey
             $suid = loadvar('suid');
             foreach ($selected as $sel) {
                 $s = explode("~", $sel);
                 if (isset($surveys[$s[0]])) {
                     $survey = $surveys[$s[0]];
                 } else {
                     $survey = new Survey($s[0]);
                     $surveys[$s[0]] = $survey;
                 }
                 $group = $survey->getGroup($s[1]);
                 $oldgroup = $group;
                 $group->copy($suid);
                 $newgroups[] = $group;
             }
             /* compile new */
             $compiler = new Compiler($suid, getSurveyVersion($survey));
             $mess = $compiler->generateGroups($newgroups);
             $mess = $compiler->generateGetFillsGroups($newgroups);
             $mess = $compiler->generateInlineFieldsGroups($newgroups);
             $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorCopied(Language::labelGroupsLower()));
             break;
         case 'move':
             $tocompile = array();
             $moved = array();
             $newgroups = array();
             // determine survey
             $suid = loadvar('suid');
             $cookiearr = explode("-", $groupcookievalue);
             foreach ($selected as $sel) {
                 $s = explode("~", $sel);
                 if (isset($surveys[$s[0]])) {
                     $survey = $surveys[$s[0]];
                 } else {
                     $survey = new Survey($s[0]);
                     $surveys[$s[0]] = $survey;
                     $tocompile[] = $s[0];
                 }
                 $group = $survey->getGroup($s[1]);
                 $oldgroup = $group;
                 $group->move($suid);
                 if (isset($moved[$s[0]])) {
                     $arr = $moved[$s[0]];
                 } else {
                     $arr = array();
                 }
                 $arr[] = $oldgroup;
                 $moved[$s[0]] = $arr;
                 $newgroups[] = $group;
                 /* update cookie */
                 $ind = array_search($sel, $cookiearr);
                 $cookiearr[$ind] = $group->getSuid() . '~' . $group->getGid();
             }
             /* update cookie */
             setcookie('uscicgroupcookie', implode("-", $cookiearr));
             //implode("-", $arr));
             $groupcookievalue = implode("-", $cookiearr);
             /* compile old */
             foreach ($tocompile as $comp) {
                 if (isset($surveys[$comp])) {
                     $survey = $surveys[$comp];
                 } else {
                     $survey = new Survey($comp);
                     $surveys[$comp] = $survey;
                 }
                 /* we moved across survey for one or more groups in this survey */
                 if ($suid != $comp) {
                     $compiler = new Compiler($comp, getSurveyVersion($surveys[$comp]));
                     $mess = $compiler->generateGroups($moved[$comp], true);
                 }
             }
             /* compile new */
             $compiler = new Compiler($suid, getSurveyVersion($survey));
             $mess = $compiler->generateGroups($newgroups);
             $mess = $compiler->generateGetFillsGroups($newgroups);
             $mess = $compiler->generateInlineFieldsGroups($newgroups);
             $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorMoved(Language::labelGroupsLower()));
             break;
         case 'remove':
             $removed = array();
             $cookiearr = explode("-", $groupcookievalue);
             foreach ($selected as $sel) {
                 $s = explode("~", $sel);
                 if (isset($surveys[$s[0]])) {
                     $survey = $surveys[$s[0]];
                 } else {
                     $survey = new Survey($s[0]);
                     $surveys[$s[0]] = $survey;
                 }
                 $group = $survey->getGroup($s[1]);
                 $group->remove();
                 $removed[] = $group;
                 /* update cookie */
                 $ind = array_search($sel, $cookiearr);
                 unset($cookiearr[$ind]);
             }
             /* update cookie */
             setcookie('uscicgroupcookie', implode("-", $cookiearr));
             //implode("-", $arr));
             $groupcookievalue = implode("-", $cookiearr);
             /* compile */
             foreach ($surveys as $survey) {
                 $compiler = new Compiler($survey->getSuid(), getSurveyVersion($survey));
                 $mess = $compiler->generateGroups($removed, true);
             }
             $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorRemoved(Language::labelGroupsLower()));
             break;
         default:
             $content = $displaySysAdmin->displayWarning(Language::messageToolsBatchEditorUnrecognizedAction());
             break;
     }
     return $content;
 }
Beispiel #3
0
 function showOutputStatisticsParadata($content = "")
 {
     $survey = new Survey($_SESSION['SUID']);
     //echo $_SESSION["SUID"] . '----';
     $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output'), Language::headerOutput()), 'label' => Language::headerOutputData());
     $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics'), Language::headerOutputStatistics()), 'label' => Language::headerOutputStatistics());
     $headers[] = array('link' => '', 'label' => Language::headerOutputStatisticsParadata());
     $returnStr = $this->showOutputHeader($headers);
     $returnStr .= $content;
     $returnStr .= $this->displayComboBox();
     $surveys = new Surveys();
     $surveys = $surveys->getSurveys();
     if (sizeof($surveys) > 0) {
         $returnStr .= "<form id=refreshform method=post>";
         $returnStr .= '<input type=hidden name=page value="sysadmin.output.statistics.paradata">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">';
         $returnStr .= "</form>";
         $returnStr .= '<div class="well well-sm">';
         $returnStr .= '<table>';
         $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>";
         $current = new Survey(getSurvey());
         foreach ($surveys as $s) {
             $selected = "";
             if ($s->getSuid() == $current->getSuid()) {
                 $selected = "SELECTED";
             }
             $returnStr .= "<option {$selected} value=" . $s->getSuid() . '>' . $s->getName() . '</option>';
         }
         $returnStr .= "</select></td></tr>";
         $returnStr .= '</table><br/><br/>';
         $sections = $survey->getSections();
         foreach ($sections as $section) {
             $returnStr .= '<a href="index.php?r=' . setSessionsParamString(array('page' => 'sysadmin.output.statistics.paradata.section', 'seid' => $section->getSeid())) . '" class="list-group-item">' . $section->getName() . ' ' . $section->getDescription() . '</a>';
         }
         $returnStr .= "</div>";
     } else {
         $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable());
     }
     $returnStr .= '</p></div>    </div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }
 function showIssues($content = "")
 {
     $returnStr = $this->showToolsHeader(Language::linkReported());
     $returnStr .= $content;
     $surveys = new Surveys();
     $surveys = $surveys->getSurveys();
     if (sizeof($surveys) > 0) {
         $returnStr .= "<form id=refreshform method=post>";
         $returnStr .= '<input type=hidden name=page value="sysadmin.tools.issues">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">';
         $returnStr .= "</form>";
         // get reported issues for survey
         global $survey;
         $issues = $survey->getReportedIssues();
         // no problems reported
         if (sizeof($issues) == 0) {
             $returnStr .= "<br/>" . '<div class="alert alert-warning">' . 'No reported problems found' . '</div>';
         } else {
             $returnStr .= $this->displayComboBox();
             $returnStr .= '<span class="label label-default">Filter by</span>';
             $returnStr .= '<div class="well well-sm">';
             $returnStr .= '<table>';
             $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>";
             $current = new Survey(getSurvey());
             foreach ($surveys as $survey) {
                 $selected = "";
                 if ($survey->getSuid() == $current->getSuid()) {
                     $selected = "SELECTED";
                 }
                 $returnStr .= "<option {$selected} value=" . $survey->getSuid() . '>' . $survey->getName() . '</option>';
             }
             $returnStr .= "</select></td></tr></table></div>";
             $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder"));
             $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#issuetable').dataTable(\n                                {\n                                    \"iDisplayLength\": " . sizeof($issues) . ",\n                                    dom: 'C<\"clear\">lfrtip',\n                                    searching: false,\n                                    paging: false\n                                    }    \n                                );\n                                         \n                       });</script>\n\n                        ";
             //
             $returnStr .= "<br/><table id='issuetable' class='table table-bordered table-striped'><thead>";
             $returnStr .= "<th>Reported by</th><th>Reported on</th><th>Category</th><th>Description</th><th>Primary key</th><th>Interview mode</th><th>Language</th>";
             $returnStr .= "</thead><tbody>";
             $modes = Common::surveyModes();
             $languages = Language::getLanguagesArray();
             $cats = Language::reportProblemCategories();
             foreach ($issues as $is) {
                 $us = new User($is['urid']);
                 $returnStr .= "<tr>";
                 $returnStr .= "<td>" . $us->getUsername() . "</td>";
                 $returnStr .= "<td>" . $is["ts"] . "</td>";
                 $returnStr .= "<td>" . $cats[$is["category"]] . "</td>";
                 $returnStr .= "<td>" . $is["comment"] . "</td>";
                 $returnStr .= "<td>" . $is["primkey"] . "</td>";
                 $returnStr .= "<td>" . $modes[$is["mode"]] . "</td>";
                 $returnStr .= "<td>" . $languages[str_replace("_", "", getSurveyLanguagePostFix($is["language"]))]['name'] . "</td>";
                 $returnStr .= "</tr>";
             }
             $returnStr .= "</tbody></table>";
         }
     } else {
         $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable());
     }
     $returnStr .= '</p></div></div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }