function showSection($seid, $message = '') { $user = new User($_SESSION['URID']); $survey = new Survey($_SESSION['SUID']); $section = $survey->getSection($seid); $returnStr = $this->showTranslatorHeader(Language::messageSMSTitle()); $returnStr .= '<div id="wrap">'; $returnStr .= $this->showNavBar(); $returnStr .= '<div class="container">'; $returnStr .= '<ol class="breadcrumb">'; $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'translator.surveys'), Language::headerSurveys()) . '</li>'; $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'translator.survey'), $survey->getName()) . '</li>'; $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'translator.survey.section', 'seid' => $seid), $section->getName()) . '</li>'; //if (!$user->hasNavigationInBreadCrumbs()) { if ($_SESSION['VRFILTERMODE_SECTION'] == 0) { $returnStr .= '<li class="active">' . Language::labelVariables() . '</li>'; } elseif ($_SESSION['VRFILTERMODE_SECTION'] == 3) { $returnStr .= '<li class="active">' . Language::labelGroups() . '</li>'; } else { $returnStr .= '<li class="active">' . Language::labelVariables() . '</li>'; } //} $returnStr .= '</ol>'; $returnStr .= $message; $returnStr .= '<div class="row row-offcanvas row-offcanvas-right">'; $returnStr .= '<div style="" class="col-xs-12 col-sm-9">'; if ($user->hasNavigationInBreadCrumbs()) { $active = array_fill(0, 16, 'label-primary'); $active[$_SESSION['VRFILTERMODE_SECTION']] = 'label-default'; $show = false; if (getSurveyLanguage() != $survey->getDefaultLanguage(getSurveyMode())) { $show = true; } $span = ""; if ($show) { $status = "glyphicon glyphicon-remove"; $statustext = Language::messageTranslationStatusIncomplete(); if ($section->isTranslatedVariables()) { $status = "glyphicon glyphicon-ok"; $statustext = Language::messageTranslationStatusComplete(); } $span = '<span style="padding-right: 5px;" title="' . $statustext . '" class="' . $status . '"></span>'; } if ($_SESSION['VRFILTERMODE_SECTION'] == 0) { $returnStr .= ' <span class="label ' . $active[0] . '">' . $span . Language::labelVariables() . '</span>'; } else { $returnStr .= ' <a onclick="$(\'#vrfiltermode_section\').val(0);$(\'#sectionsidebar\').submit(); return false;" style="text-decoration:none;"><span class="label ' . $active[0] . '">' . $span . Language::labelVariables() . '</span></a>'; } } $returnStr .= '<div class="well" style="background-color:white;">'; if ($_SESSION['VRFILTERMODE_SECTION'] == 0) { //show variables $returnStr .= $this->showVariables($survey->getVariableDescriptives($seid, "position", "asc")); } else { $returnStr .= $this->showVariables($survey->getVariableDescriptives($seid, "position", "asc")); } $returnStr .= '</div>'; //end well //END CONTENT $returnStr .= '</div>'; $returnStr .= $this->showSurveySideBar($survey, $_SESSION['VRFILTERMODE_SURVEY']); $returnStr .= $this->showSectionSideBar($survey, $_SESSION['VRFILTERMODE_SECTION']); $returnStr .= '</div>'; $returnStr .= '</div></div>'; //container and wrap $returnStr .= $this->showBottomBar(); $returnStr .= $this->showFooter(false); return $returnStr; }
function showOutputStatisticsParadataSection($seid) { $survey = new Survey($_SESSION['SUID']); $section = $survey->getSection($seid); $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' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics.paradata'), Language::headerOutputStatisticsParadata()), 'label' => Language::headerOutputStatisticsParadata()); $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics.paradata', 'suid' => $suid), $survey->getName()), 'label' => $survey->getName()); $headers[] = array('link' => '', 'label' => $section->getName()); $returnStr = $this->showOutputHeader($headers); $returnStr .= $content; $variables = $survey->getVariableDescriptives($seid); foreach ($variables as $variable) { if (!inArray($variable->getAnswerType(), array(ANSWER_TYPE_NONE, ANSWER_TYPE_SECTION))) { $returnStr .= '<a href="index.php?r=' . setSessionsParamString(array('page' => 'sysadmin.output.statistics.paradata.variable', 'seid' => $seid, 'vsid' => $variable->getVsid())) . '" class="list-group-item">' . $variable->getName() . ' ' . $variable->getDescription() . '</a>'; } } $returnStr .= '</p></div> </div>'; //container and wrap $returnStr .= $this->showBottomBar(); $returnStr .= $this->showFooter(false); return $returnStr; }
function showRemoveSectionRes() { $_SESSION['LASTPAGE'] = 'sysadmin.survey'; $displaySysAdmin = new DisplaySysAdmin(); $survey = new Survey($_SESSION['SUID']); $seid = getFromSessionParams('seid'); if ($seid != '') { //edit $section = $survey->getSection($seid); $section->remove(); $variables = $survey->getVariableDescriptives($seid); foreach ($variables as $variable) { $variable->remove(); } /* compile */ $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey)); $mess = $compiler->generateVariableDescriptives($variables, true); $mess = $compiler->generateSections(array($section), true); return $displaySysAdmin->showSurvey($displaySysAdmin->displaySuccess(Language::messageSectionRemoved($section->getName()))); } else { return $displaySysAdmin->showSurvey(); } }
function showRouting($seid) { $returnStr .= '<form id="hiddenform" name="hiddenform" method="post">'; $returnStr .= setSessionParamsPost(array('page' => 'sysadmin.survey.clickrouting')); $returnStr .= "<input type=hidden name=action id=action />"; $returnStr .= '</form>'; $returnStr .= '<form id="editform" method="post">'; $returnStr .= setSessionParamsPost(array('page' => 'sysadmin.survey.editrouting')); $survey = new Survey($_SESSION['SUID']); $_SESSION["SEID"] = $seid; $section = $survey->getSection($seid); $returnStr .= '<textarea style="width: 100%; height: 350px;" id="routing" name="routing">'; $returnStr .= $section->getRouting(); $returnStr .= '</textarea>'; $returnStr .= '<input type="submit" class="btn btn-default" value="Save"/>'; $returnStr .= '<span class="pull-right">'; $returnStr .= '<button class="btn btn-default" data-toggle="modal" data-target="#listModal">' . Language::labelVariables() . '</button>'; $track = new Track($_SESSION['SUID'], $seid, OBJECT_SECTION); $history = $track->getEntries(SETTING_ROUTING); if (sizeof($history) > 0) { $returnStr .= '<div class="btn-group"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> ' . Language::labelHistory() . ' <span class="caret"></span> </button> <ul class="dropdown-menu">'; foreach ($history as $h) { $us = new User($h["urid"]); $returnStr .= '<li><a href="#" data-toggle="modal" data-target="#historyModal" data-trackid="' . $h["trid"] . '">' . $h["ts"] . ' (' . $us->getUsername() . ')</a></li>'; } $returnStr .= '</ul> </div>'; } $returnStr .= '<button class="btn btn-default" data-toggle="modal" data-target="#compiledModal">' . Language::labelCompiledCode() . '</button>'; $returnStr .= '</span>'; $returnStr .= '</form>'; $user = new User($_SESSION['URID']); if ($user->hasRoutingAutoIndentation()) { $returnStr .= $this->getCodeMirror("height: 400px;"); $line = getFromSessionParams('routingline'); $extra = ''; if ($line > 0) { // coming in from search result $extra .= "jumpToLine(" . $line . ");"; } $returnStr .= '<link rel="stylesheet" href="js/codemirror/addon/hint/show-hint.css"/> <script src="js/codemirror/addon/hint/show-hint.js"></script> <script src="js/codemirror/addon/hint/nubis-hint.js"></script>'; $returnStr .= '<script type="text/javascript"> CodeMirror.commands.autocomplete = function(cm) { cm.showHint({hint: CodeMirror.hint.nubis}); } function jumpToLine(i) { var editor = $("#routing").data("CodeMirrorInstance"); // editor.getLineHandle does not help as it does not return the reference of line. editor.setCursor(i); window.setTimeout(function() { editor.setLineClass(i, null, "center-me"); var line = $(".CodeMirror-lines .center-me"); var h = line.parent(); $(".CodeMirror-scroll").scrollTop(0).scrollTop(line.offset().top - $(".CodeMirror-scroll").offset().top - Math.round($(".CodeMirror-scroll").height()/2)); }, 200); } $(document).ready(function() { function words(str) { var obj = [], words = str.split(" "); for (var i = 0; i < words.length; ++i) { obj[i] = words[i]; } return obj; } var keywords = words("cardinal card group subgroup endgroup endsubgroup empty nonresponse dk rf do enddo endif for and array if then elseif else in mod not or to inline inspect fill"); var mirrorchanged = false; var editor = CodeMirror.fromTextArea(document.getElementById("routing"), {mode: "text/x-nubis", lineNumbers: true, extraKeys: {"Ctrl-Space": "autocomplete"}}); $("#routing").data("CodeMirrorInstance", editor); editor.on("dblclick", function(cm, event) { if (event.ctrlKey) { if (mirrorchanged == false) { $("#editform").dirtyForms("setClean"); } var sel = cm.getSelection().toLowerCase(); if ($.inArray(sel, keywords) == -1) { $("#action").val(sel); $("#hiddenform").submit(); } } }); editor.on("change", function(from, to, text, removed, origin) { $("#routing").dirtyForms("setDirty"); mirrorchanged = true; }); function format() { var totalLines = editor.lineCount(); editor.autoFormatRange({line:0, ch:0}, {line:totalLines}); } var historyeditor = CodeMirror.fromTextArea(document.getElementById("historycontent"), {mode: "text/x-nubis", lineNumbers: true}); $("#historyModal").on("show.bs.modal", function (event) { event.stopImmediatePropagation(); var element = $(event.relatedTarget); // element that triggered the modal var recipient = element.data("trackid"); // Extract info from data-* attributes $.get("index.php?' . POST_PARAM_SMS_AJAX . '=' . SMS_AJAX_CALL . '&p=sysadmin.history.getentry&trid=" + recipient, null, function (data) { historyeditor.setValue(data.trim()); }, "text"); }); // jump to line ' . $extra . ' }); </script>'; } $returnStr .= '<div class="modal fade" id="compiledModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">' . Language::labelRoutingCompiledCode() . '\'' . $section->getName() . '\'</h4> </div> <div class="modal-body"> <div class="form-group"> <textarea style="width: 100%; height: 100%;" rows=30 class="form-control">' . $section->getCompiledCode() . '</textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> '; // history modal if (sizeof($history) > 0) { $returnStr .= '<div class="modal fade" id="historyModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">' . Language::labelRoutingHistory() . $section->getName() . '</h4> </div> <div class="modal-body"> <div class="form-group"> <textarea id=historycontent style="width: 100%; height: 100%;"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal -->'; } $returnStr .= '<div class="modal fade" id="listModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Variables in \'' . $section->getName() . '\'</h4> </div> <div class="modal-body"> <div class="form-group"> <textarea style="width: 100%; height: 400px;" rows=30 class="form-control">'; $vars = $survey->getVariableDescriptives($section->getSeid()); foreach ($vars as $v) { $returnStr .= $v->getName() . "\r\n"; } $returnStr .= '</textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> '; return $returnStr; }
function showReportsParadataSection($seid) { $survey = new Survey($_SESSION['SUID']); $section = $survey->getSection($seid); $headers[] = array('link' => setSessionParamsHref(array('page' => 'researcher.reports'), Language::headerOutput()), 'label' => Language::headerOutputData()); $headers[] = array('link' => setSessionParamsHref(array('page' => 'researcher.reports.statistics'), Language::headerOutputStatistics()), 'label' => Language::headerOutputStatistics()); $headers[] = array('link' => setSessionParamsHref(array('page' => 'researcher.reports.paradata'), Language::headerOutputStatisticsParadata()), 'label' => Language::headerOutputStatisticsParadata()); $headers[] = array('link' => setSessionParamsHref(array('page' => 'researcher.reports.paradata', 'suid' => $suid), $survey->getName()), 'label' => $survey->getName()); $headers[] = array('link' => '', 'label' => $section->getName()); $returnStr = $this->showResearchHeader(Language::messageSMSTitle()); $returnStr .= '<div id="wrap">'; $returnStr .= $this->showNavBar(); $returnStr .= '<div class="container"><p>'; $returnStr .= '<ol class="breadcrumb">'; $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'researcher.reports'), Language::headerReports()) . '</li>'; $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'researcher.reports.paradata'), Language::headerReportsParadata()) . '</li>'; $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'researcher.reports.paradata', 'suid' => $suid), $survey->getName()) . '</li>'; $returnStr .= '<li class="active">' . $section->getName() . '</li>'; $returnStr .= '</ol>'; $variables = $survey->getVariableDescriptives($seid); foreach ($variables as $variable) { if (!inArray($variable->getAnswerType(), array(ANSWER_TYPE_NONE, ANSWER_TYPE_SECTION))) { $returnStr .= '<a href="index.php?r=' . setSessionsParamString(array('page' => 'researcher.reports.paradata.variable', 'seid' => $seid, 'vsid' => $variable->getVsid())) . '" class="list-group-item">' . $variable->getName() . ' ' . $variable->getDescription() . '</a>'; } } $returnStr .= '</p></div> </div>'; //container and wrap $returnStr .= $this->showBottomBar(); $returnStr .= $this->showFooter(false); return $returnStr; }
function copy($newsuid = "", $suffix = 2, $types = true) { /* copy section */ global $db; $query = "select max(seid) as max from " . Config::dbSurvey() . "_sections"; $r = $db->selectQuery($query); $row = $db->getRow($r); $seid = $row["max"] + 1; $oldseid = $this->getSeid(); $oldsuid = $this->getSuid(); $this->setObjectName($seid); $this->setSeid($seid); if ($suffix == 2) { $this->setName($this->getName() . "_cl"); } if ($newsuid != "") { $this->setSuid($newsuid); } /* set position */ $query = "select max(position) as max from " . Config::dbSurvey() . "_sections where suid=" . $this->getSuid(); $r = $db->selectQuery($query); $row = $db->getRow($r); $pos = $row["max"] + 1; $this->setPosition($pos); $this->save(); /* copy variables */ $survey = new Survey($_SESSION['SUID']); $vars = $survey->getVariableDescriptives($oldseid); foreach ($vars as $var) { if ($suffix == 2) { $var->copy($var->getName() . "_cl", $newsuid, $this->getSeid(), $types); } else { $var->copy($var->getName(), $newsuid, $this->getSeid(), $types); } } /* copy routing */ $query = "insert into " . Config::dbSurvey() . "_routing (suid, seid, rgid, rule, ts) select " . $this->getSuid() . "," . $this->getSeid() . ", rgid, rule, ts from " . Config::dbSurvey() . "_routing where suid=" . $oldsuid . " and seid=" . $oldseid; $db->executeQuery($query); }